summaryrefslogtreecommitdiff
path: root/monitor
diff options
context:
space:
mode:
authorDavid Zeuthen <zeuthen@gmail.com>2012-07-26 12:26:46 -0400
committerDavid Zeuthen <zeuthen@gmail.com>2012-07-26 12:26:46 -0400
commitb16b1476da08dc63b98cc25eebfddb48f50a5e82 (patch)
tree3d4822304e0e8f3f5ceb5da1d3a9ac4896be85d7 /monitor
parent5b09d7e4176998c642e7fdfec71c3c35993a01b2 (diff)
downloadgvfs-b16b1476da08dc63b98cc25eebfddb48f50a5e82.tar.gz
udisks2: move up loop device validation checks
We also want these checks to apply to e.g. LUKS devices. Signed-off-by: David Zeuthen <zeuthen@gmail.com>
Diffstat (limited to 'monitor')
-rw-r--r--monitor/udisks2/gvfsudisks2volumemonitor.c66
1 files changed, 33 insertions, 33 deletions
diff --git a/monitor/udisks2/gvfsudisks2volumemonitor.c b/monitor/udisks2/gvfsudisks2volumemonitor.c
index 3052beb1..f5cfd8f3 100644
--- a/monitor/udisks2/gvfsudisks2volumemonitor.c
+++ b/monitor/udisks2/gvfsudisks2volumemonitor.c
@@ -824,6 +824,39 @@ should_include_volume (GVfsUDisks2VolumeMonitor *monitor,
if (udisks_block_get_hint_ignore (block))
goto out;
+ /* If the device (or if a partition, its containing device) is a
+ * loop device, check the SetupByUid property - we don't want to
+ * show loop devices set up by other users
+ */
+#ifdef UDISKS_CHECK_VERSION
+# if UDISKS_CHECK_VERSION(1,97,0)
+ loop = udisks_client_get_loop_for_block (monitor->client, block);
+ if (loop != NULL)
+ {
+ GDBusObject *loop_object;
+ UDisksBlock *block_for_loop;
+ guint setup_by_uid;
+
+ setup_by_uid = udisks_loop_get_setup_by_uid (loop);
+ if (setup_by_uid != 0 && setup_by_uid != getuid ())
+ goto out;
+
+ /* Work-around bug in Linux where partitions of a loop
+ * device (e.g. /dev/loop0p1) are lingering even when the
+ * parent loop device (e.g. /dev/loop0) has been cleared
+ */
+ loop_object = g_dbus_interface_get_object (G_DBUS_INTERFACE (loop));
+ if (loop_object == NULL)
+ goto out;
+ block_for_loop = udisks_object_peek_block (UDISKS_OBJECT (loop_object));
+ if (block_for_loop == NULL)
+ goto out;
+ if (udisks_block_get_size (block_for_loop) == 0)
+ goto out;
+ }
+# endif
+#endif
+
/* ignore the volume if the drive is ignored */
udisks_drive = udisks_client_get_drive_for_block (monitor->client, block);
if (udisks_drive != NULL)
@@ -889,39 +922,6 @@ should_include_volume (GVfsUDisks2VolumeMonitor *monitor,
goto out;
}
- /* If the device (or if a partition, its containing device) is a
- * loop device, check the SetupByUid property - we don't want to
- * show loop devices set up by other users
- */
-#ifdef UDISKS_CHECK_VERSION
-# if UDISKS_CHECK_VERSION(1,97,0)
- loop = udisks_client_get_loop_for_block (monitor->client, block);
- if (loop != NULL)
- {
- GDBusObject *loop_object;
- UDisksBlock *block_for_loop;
- guint setup_by_uid;
-
- setup_by_uid = udisks_loop_get_setup_by_uid (loop);
- if (setup_by_uid != 0 && setup_by_uid != getuid ())
- goto out;
-
- /* Work-around bug in Linux where partitions of a loop
- * device (e.g. /dev/loop0p1) are lingering even when the
- * parent loop device (e.g. /dev/loop0) has been cleared
- */
- loop_object = g_dbus_interface_get_object (G_DBUS_INTERFACE (loop));
- if (loop_object == NULL)
- goto out;
- block_for_loop = udisks_object_peek_block (UDISKS_OBJECT (loop_object));
- if (block_for_loop == NULL)
- goto out;
- if (udisks_block_get_size (block_for_loop) == 0)
- goto out;
- }
-# endif
-#endif
-
/* otherwise, we're good to go */
ret = TRUE;