From: Martin Pitt Date: Sun, 3 Apr 2011 21:02:46 +0000 (+0200) Subject: Support calling device_drive_eject() and device_filesystem_unmount() from daemon X-Git-Tag: upstream/2.1.2~558 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=378a755bbe24e1118caa6a278bcbc585213e7a05;p=platform%2Fupstream%2Fudisks2.git Support calling device_drive_eject() and device_filesystem_unmount() from daemon In device_drive_eject() and device_filesystem_unmount(), only specify a PolicyKit action if we actually have a D-BUS invocation context. If not, the method is called from within the daemon, so use a NULL PK action to avoid a crash. This is similar to device_drive_ata_smart_refresh_data(). Use the throw_error() wrapper instead of direct dbus_g_method_return_error(), to support NULL contexts. --- diff --git a/src/device.c b/src/device.c index 14d323a..a928fb5 100644 --- a/src/device.c +++ b/src/device.c @@ -6666,7 +6666,8 @@ filesystem_unmount_completed_cb (DBusGMethodInvocation *context, { /* update_info_mount_state() will update the mounts file and clean up the directory if needed */ update_info (device); - dbus_g_method_return (context); + if (context != NULL) + dbus_g_method_return (context); } else { @@ -6805,7 +6806,7 @@ device_filesystem_unmount (Device *device, action_id = NULL; if (!mount_file_has_device (device->priv->device_file, &uid_of_mount, NULL)) { - if (!is_device_in_fstab (device, NULL)) + if (context != NULL && !is_device_in_fstab (device, NULL)) { action_id = "org.freedesktop.udisks.filesystem-unmount-others"; } @@ -6814,7 +6815,7 @@ device_filesystem_unmount (Device *device, { uid_t uid; daemon_local_get_uid (device->priv->daemon, &uid, context); - if (uid_of_mount != uid) + if (context != NULL && uid_of_mount != uid) { action_id = "org.freedesktop.udisks.filesystem-unmount-others"; } @@ -7014,7 +7015,8 @@ drive_eject_completed_cb (DBusGMethodInvocation *context, if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { /* TODO: probably wait for has_media to change to FALSE */ - dbus_g_method_return (context); + if (context != NULL) + dbus_g_method_return (context); } else { @@ -7062,7 +7064,7 @@ device_drive_eject_authorized_cb (Daemon *daemon, if (device_local_is_busy (device, TRUE, &error)) { - dbus_g_method_return_error (context, error); + throw_error (context, ERROR_BUSY, error->message); g_error_free (error); goto out; } @@ -7107,7 +7109,7 @@ device_drive_eject (Device *device, daemon_local_check_auth (device->priv->daemon, device, - "org.freedesktop.udisks.drive-eject", + context ? "org.freedesktop.udisks.drive-eject" : NULL, "DriveEject", TRUE, device_drive_eject_authorized_cb,