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 771431 - trashwatcher.c: symlinks in the path to $HOME
trashwatcher.c: symlinks in the path to $HOME
Status: RESOLVED FIXED
Product: gvfs
Classification: Core
Component: daemon
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gvfs-maint
gvfs-maint
Depends on: 772160
Blocks:
 
 
Reported: 2016-09-14 14:05 UTC by Owen Taylor
Modified: 2016-12-12 13:48 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
trash: Correctly determine filesystem type for paths containing symlinks (7.72 KB, patch)
2016-09-16 13:49 UTC, Ondrej Holy
none Details | Review
trash: Correctly determine filesystem type for paths containing symlinks (1.50 KB, patch)
2016-09-29 09:59 UTC, Ondrej Holy
none Details | Review
trash: Correctly determine fs type for paths with symlinks (2.06 KB, patch)
2016-10-14 09:14 UTC, Ondrej Holy
none Details | Review
trash: Correctly determine fs type for paths with symlinks (1.86 KB, patch)
2016-10-25 07:07 UTC, Ondrej Holy
committed Details | Review

Description Owen Taylor 2016-09-14 14:05:27 UTC
[ Was mentioned in passing in 771384 ]

If, for example, /home is a symlink to /mnt/nvfsvolume/home, and the users's $HOME is /home/someuser, then the code in gvfs/daemon/trashlib/trashwatcher.c won't correctly recognize that $HOME is on NFS. 

find_mount_entry_for_file() just walks up the path literally removing trailing components, so it will look at /home/someuser, /home, and /, find the mount at /, and decide that $HOME is local.
Comment 1 Ondrej Holy 2016-09-16 13:49:41 UTC
Created attachment 335701 [details] [review]
trash: Correctly determine filesystem type for paths containing symlinks

If, for example, "/home" is a symlink to "/mnt/home", and the users's $HOME
is "/home/user", then the code won't correctly recognize unix mount, because
it just walks up the path removing trailing components. Consequently, "/" is
used to determine filesystem type instead of "/mnt/home". It will cause
problems if "/mnt/home" is e.g. NFS, which is handled differently than local
filesystem.
Comment 2 Ondrej Holy 2016-09-16 13:50:19 UTC
So, I have proposed patch to fix this, which uses copy-and-pasted functions from GLib, which are used in g_local_file_trash among others. Maybe would be good to provide some GLib API for it instead of copying, e.g. g_unix_mount_for (path), will discuss it...
Comment 3 Ondrej Holy 2016-09-29 09:59:32 UTC
Created attachment 336491 [details] [review]
trash: Correctly determine filesystem type for paths containing symlinks

If, for example, "/home" is a symlink to "/mnt/home", and the users's $HOME
is "/home/user", then the code won't correctly recognize unix mount, because
it just walks up the path removing trailing components. Consequently, "/" is
used to determine filesystem type instead of "/mnt/home". It will cause
problems if "/mnt/home" is e.g. NFS, which is handled differently than local
filesystem.
Comment 4 Ondrej Holy 2016-10-14 09:14:46 UTC
Created attachment 337693 [details] [review]
trash: Correctly determine fs type for paths with symlinks

If, for example, "/home" is a symlink to "/mnt/home", and the users's $HOME
is "/home/user", then the code won't correctly recognize unix mount, because
it just walks up the path removing trailing components. Consequently, "/" is
used to determine filesystem type instead of "/mnt/home". It will cause
problems if "/mnt/home" is e.g. NFS, which is handled differently than local
filesystem.

It uses newly added g_unix_mount_for. Bump GLib dependency accordingly.
Comment 5 Ondrej Holy 2016-10-14 09:15:44 UTC
Attachment 337693 [details] pushed as 6c0adcc - trash: Correctly determine fs type for paths with symlinks
Comment 6 Ondrej Holy 2016-10-25 07:06:20 UTC
Comment on attachment 337693 [details] [review]
trash: Correctly determine fs type for paths with symlinks

I reverted the commit before 1.31.1 release, because I realized that it doesn't work correctly if the home trash folder doesn't exist yet...

The proper fix involves changes in GLib...
Comment 7 Ondrej Holy 2016-10-25 07:07:50 UTC
Created attachment 338384 [details] [review]
trash: Correctly determine fs type for paths with symlinks

If, for example, "/home" is a symlink to "/mnt/home", and the users's $HOME
is "/home/user", then the code won't correctly recognize unix mount, because
it just walks up the path removing trailing components. Consequently, "/" is
used to determine filesystem type instead of "/mnt/home". It will cause
problems if "/mnt/home" is e.g. NFS, which is handled differently than local
filesystem.

It uses newly added g_unix_mount_for. Bump GLib dependency accordingly.
Comment 8 Ondrej Holy 2016-12-12 13:48:01 UTC
Attachment 338384 [details] pushed as 63b4509 - trash: Correctly determine fs type for paths with symlinks

The glib dependency has been already pushed, so push this also..