From: David Zeuthen Date: Mon, 28 Apr 2008 22:38:49 +0000 (+0000) Subject: Avoid displaying mounts in a subdirectory not accessible to the user X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=27dba4c28b9276a4ce3c67e1777fa259931b1d82;p=dana%2Fcg-glib.git Avoid displaying mounts in a subdirectory not accessible to the user 2008-04-28 David Zeuthen * gunixmounts.c (g_unix_mount_guess_should_display): Avoid displaying mounts in a subdirectory not accessible to the user (#526320). svn path=/trunk/; revision=6872 --- diff --git a/gio/ChangeLog b/gio/ChangeLog index 435cd37e..65644982 100644 --- a/gio/ChangeLog +++ b/gio/ChangeLog @@ -1,3 +1,9 @@ +2008-04-28 David Zeuthen + + * gunixmounts.c (g_unix_mount_guess_should_display): Avoid + displaying mounts in a subdirectory not accessible to the + user (#526320). + 2008-04-22 Michael Natterer * Makefile.am: fix library versioning (it was 0.0.0). diff --git a/gio/gunixmounts.c b/gio/gunixmounts.c index 577338c8..1713df30 100644 --- a/gio/gunixmounts.c +++ b/gio/gunixmounts.c @@ -44,6 +44,7 @@ #include #include #include +#include #include "gunixmounts.h" #include "gfile.h" @@ -1887,8 +1888,24 @@ g_unix_mount_guess_should_display (GUnixMountEntry *mount_entry) mount_path = mount_entry->mount_path; if (mount_path != NULL) { - if (g_str_has_prefix (mount_path, "/media/")) + if (g_str_has_prefix (mount_path, "/media/")) { + char *path; + /* Avoid displaying mounts that are not accessible to the user. + * + * See http://bugzilla.gnome.org/show_bug.cgi?id=526320 for why we + * want to avoid g_access() for every mount point. + */ + path = g_path_get_dirname (mount_path); + if (g_str_has_prefix (path, "/media/")) + { + if (g_access (path, R_OK|X_OK) != 0) { + g_free (path); + return FALSE; + } + } + g_free (path); return TRUE; + } if (g_str_has_prefix (mount_path, g_get_home_dir ()) && mount_path[strlen (g_get_home_dir())] == G_DIR_SEPARATOR) return TRUE;