~ubuntu-branches/ubuntu/lucid/devicekit-disks/lucid

« back to all changes in this revision

Viewing changes to debian/patches/00git_fstab_unmount.patch

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-08-27 16:56:47 UTC
  • Revision ID: james.westby@ubuntu.com-20090827165647-dz04acftvht2pebx
Tags: 006-0ubuntu3
Add 00git_fstab_unmount.patch: Cherrypick upstream change which fixes
unmounting of CD-ROMs if /etc/fstab controls the drive. (LP: #417964)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
From e57f8698b52a9eaf5c848b5f5e27af3eee80b7b9 Mon Sep 17 00:00:00 2001
 
2
From: David Zeuthen <davidz@redhat.com>
 
3
Date: Mon, 17 Aug 2009 20:48:09 +0000
 
4
Subject: Bug 22914 – Require password to eject a CD or DVD mounted by the same user
 
5
 
 
6
Apparently this got messed up in the port to polkit1.
 
7
---
 
8
diff --git a/src/devkit-disks-device.c b/src/devkit-disks-device.c
 
9
index 06898c0..dac22e7 100644
 
10
--- a/src/devkit-disks-device.c
 
11
+++ b/src/devkit-disks-device.c
 
12
@@ -4853,6 +4853,8 @@ devkit_disks_device_filesystem_unmount_authorized_cb (DevkitDisksDaemon     *dae
 
13
         GError *error;
 
14
         gboolean force_unmount;
 
15
         char *mount_path;
 
16
+        uid_t uid;
 
17
+        gchar uid_buf[32];
 
18
 
 
19
         mount_path = NULL;
 
20
 
 
21
@@ -4877,10 +4879,10 @@ devkit_disks_device_filesystem_unmount_authorized_cb (DevkitDisksDaemon     *dae
 
22
                 }
 
23
         }
 
24
 
 
25
+        devkit_disks_daemon_local_get_uid (device->priv->daemon, &uid, context);
 
26
+        g_snprintf (uid_buf, sizeof uid_buf, "%d", uid);
 
27
+
 
28
         if (!devkit_disks_mount_file_has_device (device->priv->device_file, NULL, NULL)) {
 
29
-                /* Check if the device is referenced in /etc/fstab; if so, attempt to
 
30
-                 * unmount the device as uid 0 (since the user has acquired .unmount-others already)
 
31
-                 */
 
32
                 if (is_device_in_fstab (device, &mount_path)) {
 
33
 
 
34
                         n = 0;
 
35
@@ -4890,10 +4892,14 @@ devkit_disks_device_filesystem_unmount_authorized_cb (DevkitDisksDaemon     *dae
 
36
                         else
 
37
                                 argv[n++] = "unmount";
 
38
                         argv[n++] = device->priv->device_file;
 
39
-                        argv[n++] = "0";
 
40
+                        argv[n++] = uid_buf;
 
41
                         argv[n++] = NULL;
 
42
                         goto run_job;
 
43
                 }
 
44
+
 
45
+                /* otherwise the user will have the .unmount-others authorization per the logic in
 
46
+                 * devkit_disks_device_filesystem_unmount()
 
47
+                 */
 
48
         }
 
49
 
 
50
         mount_path = g_strdup (((gchar **) device->priv->device_mount_paths->pdata)[0]);
 
51
@@ -4930,9 +4936,8 @@ devkit_disks_device_filesystem_unmount (DevkitDisksDevice     *device,
 
52
                                         char                 **options,
 
53
                                         DBusGMethodInvocation *context)
 
54
 {
 
55
-        uid_t uid;
 
56
-        uid_t uid_of_mount;
 
57
         const gchar *action_id;
 
58
+        uid_t uid_of_mount;
 
59
 
 
60
         if (!device->priv->device_is_mounted ||
 
61
             device->priv->device_mount_paths->len == 0) {
 
62
@@ -4942,15 +4947,18 @@ devkit_disks_device_filesystem_unmount (DevkitDisksDevice     *device,
 
63
                 goto out;
 
64
         }
 
65
 
 
66
+        /* if device is in /etc/fstab, then we'll run unmount as the calling user */
 
67
+        action_id = NULL;
 
68
         if (!devkit_disks_mount_file_has_device (device->priv->device_file, &uid_of_mount, NULL)) {
 
69
-                uid_of_mount = 0;
 
70
-        }
 
71
-
 
72
-        devkit_disks_daemon_local_get_uid (device->priv->daemon, &uid, context);
 
73
-        if (uid_of_mount != uid) {
 
74
-                action_id = "org.freedesktop.devicekit.disks.filesystem-unmount-others";
 
75
+                if (!is_device_in_fstab (device, NULL)) {
 
76
+                        action_id = "org.freedesktop.devicekit.disks.filesystem-unmount-others";
 
77
+                }
 
78
         } else {
 
79
-                action_id = NULL;
 
80
+                uid_t uid;
 
81
+                devkit_disks_daemon_local_get_uid (device->priv->daemon, &uid, context);
 
82
+                if (uid_of_mount != uid) {
 
83
+                        action_id = "org.freedesktop.devicekit.disks.filesystem-unmount-others";
 
84
+                }
 
85
         }
 
86
 
 
87
         devkit_disks_daemon_local_check_auth (device->priv->daemon,
 
88
--
 
89
cgit v0.8.2