After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 320688 - EOG can overwrite readonly files
EOG can overwrite readonly files
Status: RESOLVED FIXED
Product: eog
Classification: Core
Component: general
2.19.x
Other Linux
: Normal normal
: ---
Assigned To: EOG Maintainers
EOG Maintainers
Depends on:
Blocks:
 
 
Reported: 2005-11-04 11:41 UTC by spark
Modified: 2011-10-30 16:30 UTC
See Also:
GNOME target: ---
GNOME version: 2.19/2.20


Attachments
Proposed patch (5.84 KB, patch)
2006-04-17 13:00 UTC, Manjunath K V
needs-work Details | Review
Patch that makes EOG's save as behave similar to Gimps save as (when saving a -r-------- file) (1.72 KB, patch)
2011-03-02 17:36 UTC, Ian Hands
none Details | Review
Same as previous patch sans the stray newline I accidentally added (1.53 KB, patch)
2011-03-02 17:38 UTC, Ian Hands
none Details | Review
This patch adds a permissions denied dialog to save and save as... and it works :-) (2.03 KB, patch)
2011-03-02 18:46 UTC, Ian Hands
none Details | Review

Description spark 2005-11-04 11:41:13 UTC
Version details: 2.12.1

Somehow EOG can overwrite readonly files. To repro:

1. Save an image to the Desktop use change the permissions to 400 (read only)
2. Open another image in EOG
3. Click File -> Save As
4. Locate and select the image you previously saved to the desktop and click Save
5. At the Overwrite confirmation, click Overwrite.

Results: File is overwritten
Expected: Error is shown saying that the file is readonly. File is not overwritten.
Comment 1 Daniel Macks 2005-11-04 18:01:29 UTC
Maybe should be a warning (default to "do not overwrite") not an error. It's
perfectly legitimate (conceptually and in a general "legal unix" sense) to
overwrite a file in this manner, even though it's something that is often
surprising to new users.
Comment 2 spark 2005-11-04 18:18:27 UTC
I think it makes sense to be able to overwrite a file which you don't have
permission to write to. I think the point is that the behaviour _shouldn't_ be
suprising to users (even if it is possible using command line tools).
Comment 3 Lucas Rocha 2005-11-10 03:06:34 UTC
I confirm this in EOG 2.13.x. Maybe we should just warn the user the file is
readonly (gedit does this). So, (s)he can choose to continue or not. 
Comment 4 Manjunath K V 2006-04-17 13:00:51 UTC
Created attachment 63702 [details] [review]
Proposed patch
Comment 5 Manjunath K V 2006-04-17 13:03:02 UTC
Attaching a patch which does the below:

1. Displays a "Overwrite Confirmation dialog" if:
    - File is read-only
    - The user owns the file.
  
   The file will be overwritten if user selects "Overwrite" option.

2. Displays an information dialog if:
    - File is read-only
    - User is not the owner of the file.

    This dialog mentions that user is not the owner of the file and 
    hence cannot overwrite the read-only file.
Comment 6 Daniel Macks 2006-04-17 15:09:32 UTC
I (again/still) disagree with situation #2 in comment #5. Why not follow the same standard of unix file-permissions meanings as the whole rest of the world? In a collaborative environment, it's extremely common that one needs to write to files that one doesn't own.
Comment 7 Jen 2006-12-11 21:23:40 UTC
Is there any plan to include this patch, or similar, into a future release? I noticed that the proposed patch is the same way Gimp works.
Comment 8 Claudio Saavedra 2007-01-01 20:45:17 UTC
I think that if the OS allows users to overwrite files owned by someone else, EOG should let them do it. Asking for confirmation, just like in the case of read-only files, should be enough, IMHO.
Comment 9 Claudio Saavedra 2010-09-14 13:45:37 UTC
Comment on attachment 63702 [details] [review]
Proposed patch

Patch obsolete (not using gnomevfs anymore and the saving code has changed a lot since then).
Comment 10 Ian Hands 2011-03-02 17:36:51 UTC
Created attachment 182279 [details] [review]
Patch that makes EOG's save as behave similar to Gimps save as (when saving a -r-------- file)

I took a look at the Gimp's current method for handling read only files, as well as EOG's current behavior (current being what is on my RHEL6 box... not current as in from version control).

EOG (2.28.2) does not overwrite the file. I guess the program could chmod or rm then recreate the file (if you are the owner) to force a save.

Gimp (2.6.9) seems to preset a failed to save file dialog.

This patch brings "Save As" closer to the gimps "Save As" feature.
Comment 11 Ian Hands 2011-03-02 17:38:37 UTC
Created attachment 182280 [details] [review]
Same as previous patch sans the stray newline I accidentally added
Comment 12 Ian Hands 2011-03-02 18:23:01 UTC
(In reply to comment #11)
> Created an attachment (id=182280) [details] [review]
> Same as previous patch sans the stray newline I accidentally added

Wait this is fail.
if (g_access((gchar *)file, W_OK)) { ??

Should be something like 
if (!g_access((gchar *)file, W_OK)) { ??

Still working on this, also adding the permission denied message to eog_window_cmd_save.
Comment 13 Ian Hands 2011-03-02 18:46:41 UTC
Created attachment 182284 [details] [review]
This patch adds a permissions denied dialog to save and save as... and it works :-)
Comment 14 Felix Riemann 2011-10-30 16:30:28 UTC
Just noticed that we fixed this with the patch from bug 615376 (meaning this is already shipping with eog-3.2.x).
If an image is write-protected the user will be asked to SaveAs to a new location when he tries to save.

This is IMHO better than gedit's approach which disables its standard "Save" action alltogether in this situation.