GNOME Bugzilla – Bug 513912
Nautilus is following symbolic links when emptying trash
Last modified: 2008-03-10 16:16:07 UTC
Please describe the problem: When a symbolic link to a folder is moved to trash in Nautilus, the contents of the folder that it links to are then erased when the trash is emptied. For example, Wine creates a link '~/.wine/dos_devices/z:' to the root filesystem. If ~/.wine is moved to trash, and the trash is emptied, everything that you can write to in your root filesystem is then deleted (including the contents of your home folder). I've confirmed this by creating a test folder in my home directory containing empty files, linking to the folder (using ln -s), moving the link to trash and then emptying the trash. The contents of the folder are deleted. This is on Ubuntu Hardy (Nautilus version 2.21.90-0ubuntu1) Steps to reproduce: 1. mkdir ~/test 2. touch ~/test/empty_file 3. ln -s ~/test ~/link 4. Using, Nautilus, move ~/link to trash 5. Navigate to Deleted Items, then empty the trash Actual results: The file 'empty_file' has been deleted from ~/test Expected results: The files in ~/test should remain untouched Does this happen every time? Yes Other information:
Confirmed. This needs to be fixed ASAP as it is definitely a severe bug that could delete data that shouldn't be. rm doesnt follow symlinks this way normally so neither should nautilus.
Created attachment 104360 [details] [review] GLocalFileEnumerator should obey the NOFOLLOW_SYMLINKS flag This is actually a bug in Glib/GIO, not Nautilus. For some reason, the local file enumerator completely ignores the NOFOLLOW_SYMLINKS flag. Nobody responded in IRC when I asked what the expected behavior is, so I assume that enumerating a symlink with NOFOLLOW_SYMLINKS set should return no results. Patch to glib is written accordingly.
That patch is wrong. NOFOLLOW_SYMLINKS means information about child files should be reported for symlinks, not the files they point to (i.e. lstat(), not stat()).
2008-02-04 Alexander Larsson <alexl@redhat.com> * libnautilus-private/nautilus-file-operations.c: Don't follow symlinks when emptying trash (#513912)
*** Bug 521242 has been marked as a duplicate of this bug. ***