rpms/DeviceKit-disks/devel devkit-disks-dump-option.patch, NONE, 1.1 devkit-disks-fstab-unmount.patch, NONE, 1.1 DeviceKit-disks.spec, 1.6, 1.7
David Zeuthen
davidz at fedoraproject.org
Wed Mar 4 19:29:56 UTC 2009
Author: davidz
Update of /cvs/pkgs/rpms/DeviceKit-disks/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv10594
Modified Files:
DeviceKit-disks.spec
Added Files:
devkit-disks-dump-option.patch
devkit-disks-fstab-unmount.patch
Log Message:
* Wed Mar 04 2009 David Zeuthen <davidz at redhat.com> - 003-3%{?dist}
- Add --dump option to devkit-disks(1) to help with debugging
- Allow authorized users to unmount /etc/fstab mounts
devkit-disks-dump-option.patch:
--- NEW FILE devkit-disks-dump-option.patch ---
>From 449994908141e6af9f8f6a5909923ff0d2cf1506 Mon Sep 17 00:00:00 2001
From: David Zeuthen <davidz at redhat.com>
Date: Wed, 04 Mar 2009 19:23:04 +0000
Subject: add a --dump option to devkit-disks(1)
---
diff --git a/doc/man/devkit-disks.xml b/doc/man/devkit-disks.xml
index 422ae94..de46bae 100644
--- a/doc/man/devkit-disks.xml
+++ b/doc/man/devkit-disks.xml
@@ -37,6 +37,15 @@
<title>OPTIONS</title>
<variablelist>
<varlistentry>
+ <term><option>--dump</option></term>
+ <listitem>
+ <para>
+ Dump all information about all devices. Please include this when filing bugs.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><option>--enumerate</option></term>
<listitem>
<para>
diff --git a/tools/devkit-disks-bash-completion.sh b/tools/devkit-disks-bash-completion.sh
index c163e54..656b91d 100644
--- a/tools/devkit-disks-bash-completion.sh
+++ b/tools/devkit-disks-bash-completion.sh
@@ -17,7 +17,7 @@ __devkit_disks() {
elif [ "${COMP_WORDS[$(($COMP_CWORD - 1))]}" = "--unmount" ] ; then
COMPREPLY=($(compgen -W "$(devkit-disks --enumerate)" -- $cur))
else
- COMPREPLY=($(IFS=: compgen -S' ' -W "--inhibit-polling:--inhibit-all-polling:--enumerate:--monitor:--monitor-detail:--show-info:--help:--mount:--mount-fstype:--mount-options:--unmount:--unmount-options" -- $cur))
+ COMPREPLY=($(IFS=: compgen -S' ' -W "--dump:--inhibit-polling:--inhibit-all-polling:--enumerate:--monitor:--monitor-detail:--show-info:--help:--mount:--mount-fstype:--mount-options:--unmount:--unmount-options" -- $cur))
fi
}
diff --git a/tools/devkit-disks.c b/tools/devkit-disks.c
index 5ad1d78..eb4bc9c 100644
--- a/tools/devkit-disks.c
+++ b/tools/devkit-disks.c
@@ -53,6 +53,7 @@ static DBusGConnection *bus = NULL;
static DBusGProxy *disks_proxy = NULL;
static GMainLoop *loop;
+static gboolean opt_dump = FALSE;
static gboolean opt_enumerate = FALSE;
static gboolean opt_monitor = FALSE;
static gboolean opt_monitor_detail = FALSE;
@@ -1239,6 +1240,12 @@ out:
/* ---------------------------------------------------------------------------------------------------- */
+static gint
+ptr_str_array_compare (const gchar **a, const gchar **b)
+{
+ return g_strcmp0 (*a, *b);
+}
+
int
main (int argc, char **argv)
{
@@ -1248,6 +1255,7 @@ main (int argc, char **argv)
unsigned int n;
static GOptionEntry entries [] = {
{ "enumerate", 0, 0, G_OPTION_ARG_NONE, &opt_enumerate, "Enumerate objects paths for devices", NULL },
+ { "dump", 0, 0, G_OPTION_ARG_NONE, &opt_dump, "Dump all information about all devices", NULL },
{ "monitor", 0, 0, G_OPTION_ARG_NONE, &opt_monitor, "Monitor activity from the disk daemon", NULL },
{ "monitor-detail", 0, 0, G_OPTION_ARG_NONE, &opt_monitor_detail, "Monitor with detail", NULL },
{ "show-info", 0, 0, G_OPTION_ARG_STRING, &opt_show_info, "Show information about object path", NULL },
@@ -1319,7 +1327,24 @@ main (int argc, char **argv)
G_TYPE_DOUBLE,
G_TYPE_INVALID);
- if (opt_enumerate) {
+ if (opt_dump) {
+ GPtrArray *devices;
+ if (!org_freedesktop_DeviceKit_Disks_enumerate_devices (disks_proxy, &devices, &error)) {
+ g_warning ("Couldn't enumerate devices: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
+ g_ptr_array_sort (devices, (GCompareFunc) ptr_str_array_compare);
+ g_print ("========================================================================\n");
+ for (n = 0; n < devices->len; n++) {
+ char *object_path = devices->pdata[n];
+ do_show_info (object_path);
+ g_print ("\n"
+ "========================================================================\n");
+ }
+ g_ptr_array_foreach (devices, (GFunc) g_free, NULL);
+ g_ptr_array_free (devices, TRUE);
+ } else if (opt_enumerate) {
GPtrArray *devices;
if (!org_freedesktop_DeviceKit_Disks_enumerate_devices (disks_proxy, &devices, &error)) {
g_warning ("Couldn't enumerate devices: %s", error->message);
--
cgit v0.8.2
devkit-disks-fstab-unmount.patch:
--- NEW FILE devkit-disks-fstab-unmount.patch ---
>From aeaba20d8675b42d2704b5f32d5e63574017950e Mon Sep 17 00:00:00 2001
From: David Zeuthen <davidz at redhat.com>
Date: Wed, 04 Mar 2009 15:11:08 +0000
Subject: allow users with appropriate authorizations to unmount all fstab mounts
---
diff --git a/src/devkit-disks-daemon.c b/src/devkit-disks-daemon.c
index 4a2582f..cac5440 100644
--- a/src/devkit-disks-daemon.c
+++ b/src/devkit-disks-daemon.c
@@ -1225,9 +1225,10 @@ devkit_disks_damon_local_check_auth (DevkitDisksDaemon *daemon,
uid = (uid_t) -1;
if (!polkit_caller_get_uid (pk_caller, &uid) || uid != 0) {
- throw_error (context,
- DEVKIT_DISKS_ERROR_INHIBITED,
- "Daemon is being inhibited");
+ if (context != NULL)
+ throw_error (context,
+ DEVKIT_DISKS_ERROR_INHIBITED,
+ "Daemon is being inhibited");
}
goto out;
}
@@ -1245,10 +1246,12 @@ devkit_disks_damon_local_check_auth (DevkitDisksDaemon *daemon,
dbus_error_init (&d_error);
polkit_dbus_error_generate (pk_action, pk_result, &d_error);
- error = NULL;
- dbus_set_g_error (&error, &d_error);
- dbus_g_method_return_error (context, error);
- g_error_free (error);
+ if (context != NULL) {
+ error = NULL;
+ dbus_set_g_error (&error, &d_error);
+ dbus_g_method_return_error (context, error);
+ g_error_free (error);
+ }
dbus_error_free (&d_error);
}
polkit_action_unref (pk_action);
diff --git a/src/devkit-disks-device.c b/src/devkit-disks-device.c
index bd2ec7f..c0748fc 100644
--- a/src/devkit-disks-device.c
+++ b/src/devkit-disks-device.c
@@ -4506,8 +4506,21 @@ devkit_disks_device_filesystem_unmount (DevkitDisksDevice *device,
* unmount the device as the user
*/
if (is_device_in_fstab (device, &mount_path)) {
+
+ /* If the user has the filesystem-unmount-others authorization, unmount
+ * as root. This is such that /etc/fstab mounts without the "user" option
+ * (or similar) can be unmounted.
+ */
+ if (devkit_disks_damon_local_check_auth (device->priv->daemon,
+ pk_caller,
+ "org.freedesktop.devicekit.disks.filesystem-unmount-others",
+ NULL)) {
+ snprintf (uid_buf, sizeof uid_buf, "%d", 0);
+ } else {
+ snprintf (uid_buf, sizeof uid_buf, "%d", uid);
+ }
+
n = 0;
- snprintf (uid_buf, sizeof uid_buf, "%d", uid);
argv[n++] = PACKAGE_LIBEXEC_DIR "/devkit-disks-helper-fstab-mounter";
if (force_unmount)
argv[n++] = "force_unmount";
--
cgit v0.8.2
Index: DeviceKit-disks.spec
===================================================================
RCS file: /cvs/pkgs/rpms/DeviceKit-disks/devel/DeviceKit-disks.spec,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- DeviceKit-disks.spec 3 Mar 2009 21:33:53 -0000 1.6
+++ DeviceKit-disks.spec 4 Mar 2009 19:29:25 -0000 1.7
@@ -11,7 +11,7 @@
Summary: Disk Management Service
Name: DeviceKit-disks
Version: 003
-Release: 2%{?dist}
+Release: 3%{?dist}
License: GPLv2+
Group: System Environment/Libraries
URL: http://gitweb.freedesktop.org/?p=users/david/DeviceKit-disks.git;a=summary
@@ -38,6 +38,8 @@
Conflicts: kernel < 2.6.25
Patch0: devkit-disks-use-devt-to-identify-mounts.patch
+Patch1: devkit-disks-dump-option.patch
+Patch2: devkit-disks-fstab-unmount.patch
%description
DeviceKit-disks provides a daemon, D-Bus API and command line tools
@@ -57,6 +59,8 @@
%setup -q
%patch0 -p1 -b .use-devt-for-mounts
+%patch1 -p1 -b .fstab-unmount
+%patch2 -p1 -b .dump-option
%build
%configure
@@ -111,6 +115,10 @@
%{_datadir}/gtk-doc/html/devkit-disks/*
%changelog
+* Wed Mar 04 2009 David Zeuthen <davidz at redhat.com> - 003-3%{?dist}
+- Add --dump option to devkit-disks(1) to help with debugging
+- Allow authorized users to unmount /etc/fstab mounts
+
* Tue Mar 03 2009 David Zeuthen <davidz at redhat.com> - 003-2%{?dist}
- Identify mounts using dev_t, not device files (#488258)
More information about the fedora-extras-commits
mailing list