GNOME Bugzilla – Bug 152127
Panel accepts named pipe as background image.
Last modified: 2004-12-30 21:50:19 UTC
Description of Problem: Panels accept named pipes as background images. They block trying to open the pipe, but on providing data by cat'ing an image file into the pipe, the panel load completes but the background does not change. Steps to reproduce the problem: 1. Right click on panel and choose 'Properties' 2. Click on tab 'Background' 3. Select 'Background Image' 4. Type in a path name say '/home/picture-pipe' 5. Click on 'Close' 6. Right click on desktop and choose 'Open Terminal' 7. Run command 'cd /home/; mkfifo picture-pipe' 8. Use 'GIMP' or other graphics app to create any image file, say foo.png 9. Logout and Login again 10. Panel does not load. It blocks waiting for data on the pipe. 11. Switch to console, "CTRL+ALT+F1" 12. Login and run the command "cat foo.png > picture-pipe" 13. Switch back to desktop, "CTRL+ALT+F7" 14. The panel unblocks and hence loads up. Actual Results: The panel loads, but the background color is not changed to that of foo.png Expected Results: Either: The panel should refuse to accept special files as background images. Or: The panel should change it's background color after reading the pipe. How often does this happen? Always Additional Information:
Created attachment 31403 [details] [review] Proposed Patch
There is another problem which is very closely related to this particular bug. Description of the problem: Panel properties dialog does not wait for the user to complete the typing of a background image file name. Every keystroke is analyzed and the first matching filename is accepted. Steps to reproduce the problem: 1. Have an image file in the home directory and rename it as data_pic.png ( or any other extension like gif, jpeg etc ) 2. Right click on desktop and choose 'Open Terminal' 3. Run command 'cd ~ ; mkfifo data' 4. Right click on Panel and choose 'Properties'. Click on the 'Background' tab. 5. Select 'Background image' 6. Type the path of the image file i.e /home/user/data_pic.png in the entry provided. Actual Results: The user would not be able to type the full filename. After the user types 'data', the panel would block since it accepts 'data', the named pipe, as an image. Expected Results: Panel 'Properties' dialog should wait until the user completes the input. The changes should be accepted and , if possible, verified only after the user clicks on 'Close'. How often does this happen? Always The above patch takes care of this problem as well
static void load_background_file (PanelBackground *background) { - GError *error = NULL; - + GError *error = NULL; + struct stat buf; + gint ret; + if(!(ret=stat(background->image,&buf))) + { + if (S_ISREG(buf.st_mode)) You may want to use g_file_test(), check if G_FILE_TEST_EXISTS and G_FILE_TEST_IS_REGULAR. + { + background->loaded_image = + gdk_pixbuf_new_from_file (background->image, &error); ------- Additional Comment #2 From Vasista Sarma 2004-09-08 00:06 ------- The user would not be able to type the full filename. After the user types 'data', the panel would block since it accepts 'data', the named pipe, as an image. Yeah, its an instant apply dialog :-) what happens if there's was an previous image set?. It gets lost right?.
Created attachment 32061 [details] [review] Modified Patch Modified Patch Checks if the file exists and is regular then applies it to background
Thanks for the patch. It's in HEAD.