Update to 1.13.0

This commit is contained in:
Tomas Bzatek 2012-05-02 13:22:09 +02:00
parent c5063823ee
commit f193471ae2
7 changed files with 7 additions and 1067 deletions

1
.gitignore vendored
View File

@ -24,3 +24,4 @@ gvfs-1.6.3.tar.bz2
/gvfs-1.12.0.tar.xz /gvfs-1.12.0.tar.xz
/gvfs-1.12.1.tar.xz /gvfs-1.12.1.tar.xz
/gvfs-1.12.2.tar.xz /gvfs-1.12.2.tar.xz
/gvfs-1.13.0.tar.xz

View File

@ -1,385 +0,0 @@
From 79f0ea7c0d5cb39cf1ab40afaea0e485aeb4bc49 Mon Sep 17 00:00:00 2001
From: David Zeuthen <davidz@redhat.com>
Date: Thu, 26 Apr 2012 14:35:37 -0400
Subject: [PATCH 7/9] udisks2: Support getting/storing LUKS encryption passphrase from keyring
Also use a nicer message when asking for the passphrase, e.g. use strings like
'SD04G (SD Card Reader)'
'WD 2500JB External (250 GB Hard Disk)'
instead of /dev/mmcblk0p1 or /dev/sdb1. If stored in the keyring, we
also use the following display name
'Encryption passphrase for $DRIVE'
where $DRIVE is of the above form. This makes it easy for the user to
manage (for example, delete) pass-phrases using seahorse(1).
This was discussed in bug 674161.
https://bugzilla.gnome.org/show_bug.cgi?id=674161
This commit adds/changes translatable strings but Tomas said he would
soon branch gvfs for gnome-3-at a point before this patch.
Signed-off-by: David Zeuthen <davidz@redhat.com>
---
monitor/udisks2/Makefile.am | 2 +
monitor/udisks2/gvfsudisks2volume.c | 225 ++++++++++++++++++++++++++++++++++-
2 files changed, 221 insertions(+), 6 deletions(-)
diff --git a/monitor/udisks2/Makefile.am b/monitor/udisks2/Makefile.am
index 776f670..c5ddd7c 100644
--- a/monitor/udisks2/Makefile.am
+++ b/monitor/udisks2/Makefile.am
@@ -20,6 +20,7 @@ gvfs_udisks2_volume_monitor_CFLAGS = \
$(UDISKS2_CFLAGS) \
$(GUDEV_CFLAGS) \
$(LIBSYSTEMD_LOGIN_CFLAGS) \
+ $(KEYRING_CFLAGS) \
-DGIO_MODULE_DIR=\"$(GIO_MODULE_DIR)\" \
-DGVFS_LOCALEDIR=\""$(localedir)"\" \
-DG_DISABLE_DEPRECATED \
@@ -34,6 +35,7 @@ gvfs_udisks2_volume_monitor_LDADD = \
$(UDISKS2_LIBS) \
$(GUDEV_LIBS) \
$(LIBSYSTEMD_LOGIN_LIBS) \
+ $(KEYRING_LIBS) \
$(top_builddir)/common/libgvfscommon.la \
$(top_builddir)/monitor/proxy/libgvfsproxyvolumemonitordaemon-noin.la \
$(NULL)
diff --git a/monitor/udisks2/gvfsudisks2volume.c b/monitor/udisks2/gvfsudisks2volume.c
index 3ef5895..bb5c687 100644
--- a/monitor/udisks2/gvfsudisks2volume.c
+++ b/monitor/udisks2/gvfsudisks2volume.c
@@ -31,6 +31,10 @@
#include <glib/gi18n-lib.h>
#include <gio/gio.h>
+#ifdef HAVE_KEYRING
+#include <gnome-keyring.h>
+#endif
+
#include "gvfsudisks2drive.h"
#include "gvfsudisks2volume.h"
#include "gvfsudisks2mount.h"
@@ -756,6 +760,17 @@ gvfs_udisks2_volume_get_activation_root (GVolume *_volume)
/* ---------------------------------------------------------------------------------------------------- */
+#ifdef HAVE_KEYRING
+static GnomeKeyringPasswordSchema luks_passphrase_schema =
+{
+ GNOME_KEYRING_ITEM_GENERIC_SECRET,
+ {
+ {"gvfs-luks-uuid", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING},
+ {NULL, 0}
+ }
+};
+#endif
+
struct MountData
{
GSimpleAsyncResult *simple;
@@ -769,9 +784,15 @@ struct MountData
gchar *passphrase;
+ gchar *passphrase_from_keyring;
+ GPasswordSave password_save;
+
+ gchar *uuid_of_encrypted_to_unlock;
+ gchar *desc_of_encrypted_to_unlock;
UDisksEncrypted *encrypted_to_unlock;
UDisksFilesystem *filesystem_to_mount;
+ gboolean checked_keyring;
};
static void
@@ -795,7 +816,10 @@ mount_data_free (MountData *data)
}
g_free (data->passphrase);
+ g_free (data->passphrase_from_keyring);
+ g_free (data->uuid_of_encrypted_to_unlock);
+ g_free (data->desc_of_encrypted_to_unlock);
g_clear_object (&data->encrypted_to_unlock);
g_clear_object (&data->filesystem_to_mount);
g_free (data);
@@ -912,6 +936,62 @@ do_mount (MountData *data)
/* ------------------------------ */
+#ifdef HAVE_KEYRING
+static void
+luks_store_passphrase_cb (GnomeKeyringResult result,
+ gpointer user_data)
+{
+ MountData *data = user_data;
+ if (result == GNOME_KEYRING_RESULT_OK)
+ {
+ /* everything is good */
+ do_mount (data);
+ }
+ else
+ {
+ /* report failure */
+ g_simple_async_result_set_error (data->simple,
+ G_IO_ERROR,
+ G_IO_ERROR_FAILED,
+ _("Error storing passphrase in keyring (error code %d)"),
+ result);
+ g_simple_async_result_complete (data->simple);
+ mount_data_free (data);
+ }
+}
+#endif
+
+
+static void do_unlock (MountData *data);
+
+
+#ifdef HAVE_KEYRING
+static void
+luks_delete_passphrase_cb (GnomeKeyringResult result,
+ gpointer user_data)
+{
+ MountData *data = user_data;
+ if (result == GNOME_KEYRING_RESULT_OK)
+ {
+ /* with the bad passphrase out of the way, try again */
+ g_free (data->passphrase);
+ data->passphrase = NULL;
+ do_unlock (data);
+ }
+ else
+ {
+ /* report failure */
+ g_simple_async_result_set_error (data->simple,
+ G_IO_ERROR,
+ G_IO_ERROR_FAILED,
+ _("Error deleting invalid passphrase from keyring (error code %d)"),
+ result);
+ g_simple_async_result_complete (data->simple);
+ mount_data_free (data);
+ }
+}
+#endif
+
static void
unlock_cb (GObject *source_object,
GAsyncResult *res,
@@ -927,6 +1007,26 @@ unlock_cb (GObject *source_object,
res,
&error))
{
+#ifdef HAVE_KEYRING
+ /* If this failed with a passphrase read from the keyring, try again
+ * this time prompting the user...
+ *
+ * TODO: ideally check against something like UDISKS_ERROR_PASSPHRASE_INVALID
+ * when such a thing is available in udisks
+ */
+ if (data->passphrase_from_keyring != NULL &&
+ g_strcmp0 (data->passphrase, data->passphrase_from_keyring) == 0)
+ {
+ /* nuke the invalid passphrase from keyring... */
+ gnome_keyring_delete_password (&luks_passphrase_schema,
+ luks_delete_passphrase_cb,
+ data,
+ NULL, /* GDestroyNotify */
+ "gvfs-luks-uuid", data->uuid_of_encrypted_to_unlock,
+ NULL); /* sentinel */
+ goto out;
+ }
+#endif
gvfs_udisks2_utils_udisks_error_to_gio_error (error);
g_simple_async_result_take_error (data->simple, error);
g_simple_async_result_complete (data->simple);
@@ -953,6 +1053,42 @@ unlock_cb (GObject *source_object,
goto out;
}
+#ifdef HAVE_KEYRING
+ /* passphrase worked - save it in the keyring if requested */
+ if (data->password_save != G_PASSWORD_SAVE_NEVER)
+ {
+ const gchar *keyring;
+ gchar *display_name;
+
+ switch (data->password_save)
+ {
+ case G_PASSWORD_SAVE_NEVER:
+ g_assert_not_reached ();
+ break;
+ case G_PASSWORD_SAVE_FOR_SESSION:
+ keyring = GNOME_KEYRING_SESSION;
+ break;
+ case G_PASSWORD_SAVE_PERMANENTLY:
+ keyring = GNOME_KEYRING_DEFAULT;
+ break;
+ }
+
+ display_name = g_strdup_printf (_("Encryption passphrase for %s"),
+ data->desc_of_encrypted_to_unlock);
+
+ gnome_keyring_store_password (&luks_passphrase_schema,
+ keyring,
+ display_name,
+ data->passphrase,
+ luks_store_passphrase_cb,
+ data,
+ NULL, /* GDestroyNotify */
+ "gvfs-luks-uuid", data->uuid_of_encrypted_to_unlock,
+ NULL); /* sentinel */
+ goto out;
+ }
+#endif
+
/* OK, ready to rock */
do_mount (data);
}
@@ -961,8 +1097,6 @@ unlock_cb (GObject *source_object,
g_free (cleartext_device);
}
-static void do_unlock (MountData *data);
-
static void
on_mount_operation_reply (GMountOperation *mount_operation,
GMountOperationResult result,
@@ -1005,6 +1139,9 @@ on_mount_operation_reply (GMountOperation *mount_operation,
}
data->passphrase = g_strdup (g_mount_operation_get_password (mount_operation));
+ data->password_save = g_mount_operation_get_password_save (mount_operation);
+
+ /* Don't save password in keyring just yet - check if it works first */
do_unlock (data);
@@ -1049,6 +1186,27 @@ has_crypttab_passphrase (MountData *data)
return ret;
}
+#ifdef HAVE_KEYRING
+static void
+luks_find_passphrase_cb (GnomeKeyringResult result,
+ const gchar *string,
+ gpointer user_data)
+{
+ MountData *data = user_data;
+
+ /* Don't fail if a keyring error occured - just continue and request
+ * the passphrase from the user...
+ */
+ if (result == GNOME_KEYRING_RESULT_OK)
+ {
+ data->passphrase = g_strdup (string);
+ data->passphrase_from_keyring = g_strdup (string);
+ }
+ /* try again */
+ do_unlock (data);
+}
+#endif
+
static void
do_unlock (MountData *data)
{
@@ -1065,6 +1223,21 @@ do_unlock (MountData *data)
{
gchar *message;
+#ifdef HAVE_KEYRING
+ /* check if the passphrase is in the user's keyring */
+ if (!data->checked_keyring)
+ {
+ data->checked_keyring = TRUE;
+ gnome_keyring_find_password (&luks_passphrase_schema,
+ luks_find_passphrase_cb,
+ data,
+ NULL, /* GDestroyNotify */
+ "gvfs-luks-uuid", data->uuid_of_encrypted_to_unlock,
+ NULL); /* sentinel */
+ goto out;
+ }
+#endif
+
if (data->mount_operation == NULL)
{
g_simple_async_result_set_error (data->simple,
@@ -1084,9 +1257,10 @@ do_unlock (MountData *data)
"aborted",
G_CALLBACK (on_mount_operation_aborted),
data);
- message = g_strdup_printf (_("Enter a password to unlock the volume\n"
- "The device %s contains encrypted data."),
- udisks_block_get_device (data->volume->block));
+ /* Translators: This is the message shown to users */
+ message = g_strdup_printf (_("Enter a passphrase to unlock the volume\n"
+ "The passphrase is needed to access encrypted data on %s."),
+ data->desc_of_encrypted_to_unlock);
/* NOTE: We (currently) don't offer the user to save the
* passphrase in the keyring or /etc/crypttab - compared to
@@ -1109,7 +1283,7 @@ do_unlock (MountData *data)
NULL,
NULL,
G_ASK_PASSWORD_NEED_PASSWORD |
- 0/*G_ASK_PASSWORD_SAVING_SUPPORTED*/);
+ G_ASK_PASSWORD_SAVING_SUPPORTED);
g_free (message);
goto out;
}
@@ -1209,6 +1383,45 @@ gvfs_udisks2_volume_mount (GVolume *_volume,
data->encrypted_to_unlock = udisks_object_get_encrypted (UDISKS_OBJECT (object));
if (data->encrypted_to_unlock != NULL)
{
+ UDisksDrive *udisks_drive;
+
+ /* This description is used in both the prompt and the display-name of
+ * the key stored in the user's keyring ...
+ *
+ * NOTE: we want a little bit more detail than what g_drive_get_name()
+ * gives us, since this is going to be used to refer to the device even
+ * when not plugged in
+ */
+ udisks_drive = udisks_client_get_drive_for_block (gvfs_udisks2_volume_monitor_get_udisks_client (volume->monitor),
+ block);
+ if (udisks_drive != NULL)
+ {
+ gchar *drive_name;
+ gchar *drive_desc;
+ udisks_client_get_drive_info (gvfs_udisks2_volume_monitor_get_udisks_client (volume->monitor),
+ udisks_drive,
+ &drive_name,
+ &drive_desc,
+ NULL, /* drive_icon */
+ NULL, /* media_desc */
+ NULL); /* media_icon */
+ /* Translators: this is used to describe the drive the encrypted media
+ * is on - the first %s is the name (such as 'WD 2500JB External'), the
+ * second %s is the description ('250 GB Hard Disk').
+ */
+ data->desc_of_encrypted_to_unlock = g_strdup_printf (_("%s (%s)"),
+ drive_name,
+ drive_desc);
+ g_free (drive_desc);
+ g_free (drive_name);
+ g_object_unref (udisks_drive);
+ }
+ else
+ {
+ data->desc_of_encrypted_to_unlock = udisks_block_dup_preferred_device (block);
+ }
+ data->uuid_of_encrypted_to_unlock = udisks_block_dup_id_uuid (block);
+
do_unlock (data);
goto out;
}
--
1.7.3.4

View File

@ -1,115 +0,0 @@
From 495bf23f972cb14aa55d15b7c9fe53bd610a0590 Mon Sep 17 00:00:00 2001
From: David Zeuthen <davidz@redhat.com>
Date: Mon, 23 Apr 2012 15:46:31 -0400
Subject: [PATCH 5/9] udisks2: don't automount if drive is shared across all seats
If we automount media in a drive assigned to all seats, then all
sessions on all seats will be notified of the new media... which is
definitely going to be annoying. Instead, just disable automounting on
such drives so the user manually have to mount it.
Of course, this depends on the shell doing the right thing. Which is:
only notifying the user when successfully auto-mounting in response to
a hotplug event. This is not currently the case, see
https://bugzilla.gnome.org/show_bug.cgi?id=660595#c19
for details about this bug.
Signed-off-by: David Zeuthen <davidz@redhat.com>
---
monitor/udisks2/gvfsudisks2utils.c | 7 ++++++-
monitor/udisks2/gvfsudisks2utils.h | 3 ++-
monitor/udisks2/gvfsudisks2volume.c | 8 ++++++--
monitor/udisks2/gvfsudisks2volumemonitor.c | 2 +-
4 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/monitor/udisks2/gvfsudisks2utils.c b/monitor/udisks2/gvfsudisks2utils.c
index 43d583a..d747a63 100644
--- a/monitor/udisks2/gvfsudisks2utils.c
+++ b/monitor/udisks2/gvfsudisks2utils.c
@@ -547,9 +547,11 @@ get_seat (void)
#endif
gboolean
-gvfs_udisks2_utils_is_drive_on_our_seat (UDisksDrive *drive)
+gvfs_udisks2_utils_is_drive_on_our_seat (UDisksDrive *drive,
+ gboolean *out_shared)
{
gboolean ret = FALSE;
+ gboolean shared = FALSE;
const gchar *seat;
const gchar *drive_seat = NULL;
@@ -584,6 +586,7 @@ gvfs_udisks2_utils_is_drive_on_our_seat (UDisksDrive *drive)
if (g_strcmp0 (drive_seat, "all") == 0)
{
ret = TRUE;
+ shared = TRUE;
goto out;
}
@@ -592,5 +595,7 @@ gvfs_udisks2_utils_is_drive_on_our_seat (UDisksDrive *drive)
ret = TRUE;
out:
+ if (out_shared != NULL)
+ *out_shared = shared;
return ret;
}
diff --git a/monitor/udisks2/gvfsudisks2utils.h b/monitor/udisks2/gvfsudisks2utils.h
index 1965883..41ce875 100644
--- a/monitor/udisks2/gvfsudisks2utils.h
+++ b/monitor/udisks2/gvfsudisks2utils.h
@@ -50,7 +50,8 @@ gboolean gvfs_udisks2_utils_spawn_finish (GAsyncResult *res,
gchar **out_standard_error,
GError **error);
-gboolean gvfs_udisks2_utils_is_drive_on_our_seat (UDisksDrive *drive);
+gboolean gvfs_udisks2_utils_is_drive_on_our_seat (UDisksDrive *drive,
+ gboolean *out_shared);
G_END_DECLS
diff --git a/monitor/udisks2/gvfsudisks2volume.c b/monitor/udisks2/gvfsudisks2volume.c
index a1c7fa4..3ef5895 100644
--- a/monitor/udisks2/gvfsudisks2volume.c
+++ b/monitor/udisks2/gvfsudisks2volume.c
@@ -269,6 +269,8 @@ update_volume (GVfsUDisks2Volume *volume)
GIcon *drive_icon;
gchar *media_desc;
GIcon *media_icon;
+ gboolean shared;
+
udisks_client_get_drive_info (gvfs_udisks2_volume_monitor_get_udisks_client (volume->monitor),
udisks_drive,
NULL, /* drive_name */
@@ -314,8 +316,10 @@ update_volume (GVfsUDisks2Volume *volume)
if (media_icon != NULL)
g_object_unref (media_icon);
- /* Only automount drives attached to the same seat as we're running on */
- if (gvfs_udisks2_utils_is_drive_on_our_seat (udisks_drive))
+ /* Only automount drives attached to the same seat as we're running on
+ * and if the drive is NOT shared across all seats
+ */
+ if (gvfs_udisks2_utils_is_drive_on_our_seat (udisks_drive, &shared) && !shared)
{
/* Only automount filesystems from drives of known types/interconnects:
*
diff --git a/monitor/udisks2/gvfsudisks2volumemonitor.c b/monitor/udisks2/gvfsudisks2volumemonitor.c
index 2826164..002ab3c 100644
--- a/monitor/udisks2/gvfsudisks2volumemonitor.c
+++ b/monitor/udisks2/gvfsudisks2volumemonitor.c
@@ -906,7 +906,7 @@ should_include_drive (GVfsUDisks2VolumeMonitor *monitor,
gboolean ret = TRUE;
/* Don't include drives on other seats */
- if (!gvfs_udisks2_utils_is_drive_on_our_seat (drive))
+ if (!gvfs_udisks2_utils_is_drive_on_our_seat (drive, NULL))
{
ret = FALSE;
goto out;
--
1.7.3.4

View File

@ -1,240 +0,0 @@
From 5c9ffd7bf5d08c3fe57e235d8001e0b9c23a2730 Mon Sep 17 00:00:00 2001
From: David Zeuthen <davidz@redhat.com>
Date: Sat, 21 Apr 2012 12:28:09 -0400
Subject: [PATCH 1/9] Don't set should_automount to TRUE for devices on other seats
This change uses the libsystemd-login library to obtain the seat we're
on and compares it against the Seat property on the D-Bus interface
org.freedesktop.UDisks2.Drive. This property is available in udisks
1.95.0, see
http://cgit.freedesktop.org/udisks/commit/?id=91106cdc7622d9674f6083dcb524407f026a36c7
Also, since we're still on the stable branch and not everyone may be
using systemd, make this work without hard-requiring either
libsystemd-login or udisks 1.95.0.
Signed-off-by: David Zeuthen <davidz@redhat.com>
---
configure.ac | 22 ++++++
monitor/udisks2/Makefile.am | 2 +
monitor/udisks2/gvfsudisks2volume.c | 125 ++++++++++++++++++++++++++++-------
3 files changed, 124 insertions(+), 25 deletions(-)
diff --git a/configure.ac b/configure.ac
index 3b77b64..361b0d4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -239,6 +239,27 @@ fi
AM_CONDITIONAL(USE_UDISKS2, [test "$msg_udisks2" = "yes"])
+dnl **********************************
+dnl *** Check for libsystemd-login ***
+dnl **********************************
+
+AC_ARG_ENABLE(libsystemd_login, AS_HELP_STRING([--disable-libsystemd-login],[build without liblibsystemd-login]))
+msg_libsystemd_login=no
+LIBSYSTEMD_LOGIN_LIBS=
+LIBSYSTEMD_LOGIN_CFLAGS=
+LIBSYSTEMD_LOGIN_REQUIRED=44
+
+if test "x$enable_libsystemd_login" != "xno"; then
+ PKG_CHECK_EXISTS([libsystemd-login >= $LIBSYSTEMD_LOGIN_REQUIRED], msg_libsystemd_login=yes)
+
+ if test "x$msg_libsystemd_login" = "xyes"; then
+ PKG_CHECK_MODULES([LIBSYSTEMD_LOGIN],[libsystemd-login >= $LIBSYSTEMD_LOGIN_REQUIRED])
+ AC_DEFINE(HAVE_LIBSYSTEMD_LOGIN, 1, [Define to 1 if liblibsystemd_login is available])
+ fi
+fi
+
+AM_CONDITIONAL(USE_LIBSYSTEMD_LOGIN, [test "$msg_libsystemd_login" = "yes"])
+
dnl **********************
dnl *** Check for HAL ***
dnl **********************
@@ -783,6 +804,7 @@ echo "
Build HAL volume monitor: $msg_hal (with fast init path: $have_hal_fast_init)
Build GDU volume monitor: $msg_gdu
Build udisks2 volume monitor: $msg_udisks2
+ Use libsystem-login: $msg_libsystemd_login
GNOME Keyring support: $msg_keyring
Bash-completion support: $msg_bash_completion
"
diff --git a/monitor/udisks2/Makefile.am b/monitor/udisks2/Makefile.am
index f919df6..776f670 100644
--- a/monitor/udisks2/Makefile.am
+++ b/monitor/udisks2/Makefile.am
@@ -19,6 +19,7 @@ gvfs_udisks2_volume_monitor_CFLAGS = \
$(GLIB_CFLAGS) \
$(UDISKS2_CFLAGS) \
$(GUDEV_CFLAGS) \
+ $(LIBSYSTEMD_LOGIN_CFLAGS) \
-DGIO_MODULE_DIR=\"$(GIO_MODULE_DIR)\" \
-DGVFS_LOCALEDIR=\""$(localedir)"\" \
-DG_DISABLE_DEPRECATED \
@@ -32,6 +33,7 @@ gvfs_udisks2_volume_monitor_LDADD = \
$(GLIB_LIBS) \
$(UDISKS2_LIBS) \
$(GUDEV_LIBS) \
+ $(LIBSYSTEMD_LOGIN_LIBS) \
$(top_builddir)/common/libgvfscommon.la \
$(top_builddir)/monitor/proxy/libgvfsproxyvolumemonitordaemon-noin.la \
$(NULL)
diff --git a/monitor/udisks2/gvfsudisks2volume.c b/monitor/udisks2/gvfsudisks2volume.c
index 89c2413..243dc14 100644
--- a/monitor/udisks2/gvfsudisks2volume.c
+++ b/monitor/udisks2/gvfsudisks2volume.c
@@ -36,6 +36,41 @@
#include "gvfsudisks2mount.h"
#include "gvfsudisks2utils.h"
+
+#if defined(HAVE_LIBSYSTEMD_LOGIN)
+#include <systemd/sd-login.h>
+
+static const gchar *
+get_seat (void)
+{
+ static gsize once = 0;
+ static char *seat = NULL;
+
+ if (g_once_init_enter (&once))
+ {
+ char *session = NULL;
+ if (sd_pid_get_session (getpid (), &session) == 0)
+ {
+ sd_session_get_seat (session, &seat);
+ /* we intentionally leak seat here... */
+ }
+ g_once_init_leave (&once, (gsize) 1);
+ }
+ return seat;
+}
+
+#else
+
+static const gchar *
+get_seat (void)
+{
+ return NULL;
+}
+
+#endif
+
+
+
typedef struct _GVfsUDisks2VolumeClass GVfsUDisks2VolumeClass;
struct _GVfsUDisks2VolumeClass
@@ -178,6 +213,43 @@ apply_options_from_fstab (GVfsUDisks2Volume *volume,
}
static gboolean
+drive_is_on_our_seat (UDisksDrive *drive)
+{
+ gboolean ret = FALSE;
+ const gchar *seat;
+ const gchar *drive_seat = NULL;
+
+ /* assume our own seat if we don't have seat-support or it doesn't work */
+ seat = get_seat ();
+ if (seat == NULL)
+ {
+ ret = TRUE;
+ goto out;
+ }
+
+ /* Assume seat0 if a) device is not tagged; or b) udisks does not
+ * have seat-support.
+ *
+ * Note that seat support was added in udisks 1.95.0 (and so was the
+ * UDISKS_CHECK_VERSION macro) - for now, be compatible with older
+ * versions instead of bumping requirement in configure.ac
+ */
+#ifdef UDISKS_CHECK_VERSION
+# if UDISKS_CHECK_VERSION(1,95,0)
+ drive_seat = udisks_drive_get_seat (drive);
+# endif
+#endif
+ if (drive_seat == NULL || strlen (drive_seat) == 0)
+ drive_seat = "seat0";
+
+ if (g_strcmp0 (seat, drive_seat) == 0)
+ ret = TRUE;
+
+ out:
+ return ret;
+}
+
+static gboolean
update_volume (GVfsUDisks2Volume *volume)
{
gboolean changed;
@@ -314,35 +386,38 @@ update_volume (GVfsUDisks2Volume *volume)
if (media_icon != NULL)
g_object_unref (media_icon);
- /* Only automount filesystems from drives of known types/interconnects:
- *
- * - USB
- * - Firewire
- * - sdio
- * - optical discs
- *
- * The mantra here is "be careful" - we really don't want to
- * automount filesystems from all devices in a SAN etc - We
- * REALLY need to be CAREFUL here.
- *
- * Fortunately udisks provides a property just for this.
- */
- if (udisks_block_get_hint_auto (volume->block))
+ /* Only automount drives attached to the same seat as we're running on */
+ if (drive_is_on_our_seat (udisks_drive))
{
- gboolean just_plugged_in = FALSE;
- /* Also, if a volume (partition) appear _much later_ than when media was inserted it
- * can only be because the media was repartitioned. We don't want to automount
- * such volumes. So only mark volumes appearing just after their drive.
+ /* Only automount filesystems from drives of known types/interconnects:
*
- * There's a catch here - if the volume was discovered at coldplug-time (typically
- * when the user desktop session started), we can't use this heuristic
+ * - USB
+ * - Firewire
+ * - sdio
+ * - optical discs
+ *
+ * The mantra here is "be careful" - we really don't want to
+ * automount filesystems from all devices in a SAN etc - We
+ * REALLY need to be CAREFUL here.
+ *
+ * Fortunately udisks provides a property just for this.
*/
- if (g_get_real_time () - udisks_drive_get_time_media_detected (udisks_drive) < 5 * G_USEC_PER_SEC)
- just_plugged_in = TRUE;
- if (volume->coldplug || just_plugged_in)
- volume->should_automount = TRUE;
+ if (udisks_block_get_hint_auto (volume->block))
+ {
+ gboolean just_plugged_in = FALSE;
+ /* Also, if a volume (partition) appear _much later_ than when media was inserted it
+ * can only be because the media was repartitioned. We don't want to automount
+ * such volumes. So only mark volumes appearing just after their drive.
+ *
+ * There's a catch here - if the volume was discovered at coldplug-time (typically
+ * when the user desktop session started), we can't use this heuristic
+ */
+ if (g_get_real_time () - udisks_drive_get_time_media_detected (udisks_drive) < 5 * G_USEC_PER_SEC)
+ just_plugged_in = TRUE;
+ if (volume->coldplug || just_plugged_in)
+ volume->should_automount = TRUE;
+ }
}
-
g_object_unref (udisks_drive);
}
--
1.7.3.4

View File

@ -1,314 +0,0 @@
From c241b86cc74ce8ca13d9ee2b8d0b7cf15850cf71 Mon Sep 17 00:00:00 2001
From: David Zeuthen <davidz@redhat.com>
Date: Sun, 22 Apr 2012 11:48:19 -0400
Subject: [PATCH 4/9] udisks2: don't show drives from other seats and special-case seat "all"
If Drive:seat is "all" it means the drive is available on all seats.
Signed-off-by: David Zeuthen <davidz@redhat.com>
---
monitor/udisks2/gvfsudisks2utils.c | 83 ++++++++++++++++++++++++++++
monitor/udisks2/gvfsudisks2utils.h | 2 +
monitor/udisks2/gvfsudisks2volume.c | 74 +------------------------
monitor/udisks2/gvfsudisks2volumemonitor.c | 47 ++++++++++++---
4 files changed, 123 insertions(+), 83 deletions(-)
diff --git a/monitor/udisks2/gvfsudisks2utils.c b/monitor/udisks2/gvfsudisks2utils.c
index 0dc8abe..43d583a 100644
--- a/monitor/udisks2/gvfsudisks2utils.c
+++ b/monitor/udisks2/gvfsudisks2utils.c
@@ -511,3 +511,86 @@ gvfs_udisks2_utils_spawn_finish (GAsyncResult *res,
return ret;
}
+/* ---------------------------------------------------------------------------------------------------- */
+
+#if defined(HAVE_LIBSYSTEMD_LOGIN)
+#include <systemd/sd-login.h>
+
+static const gchar *
+get_seat (void)
+{
+ static gsize once = 0;
+ static char *seat = NULL;
+
+ if (g_once_init_enter (&once))
+ {
+ char *session = NULL;
+ if (sd_pid_get_session (getpid (), &session) == 0)
+ {
+ sd_session_get_seat (session, &seat);
+ free (session);
+ /* we intentionally leak seat here... */
+ }
+ g_once_init_leave (&once, (gsize) 1);
+ }
+ return seat;
+}
+
+#else
+
+static const gchar *
+get_seat (void)
+{
+ return NULL;
+}
+
+#endif
+
+gboolean
+gvfs_udisks2_utils_is_drive_on_our_seat (UDisksDrive *drive)
+{
+ gboolean ret = FALSE;
+ const gchar *seat;
+ const gchar *drive_seat = NULL;
+
+ /* assume our own seat if we don't have seat-support or it doesn't work */
+ seat = get_seat ();
+ if (seat == NULL)
+ {
+ ret = TRUE;
+ goto out;
+ }
+
+ /* If the device is not tagged, assume that udisks does not have
+ * working seat-support... so just assume it's available at our
+ * seat.
+ *
+ * Note that seat support was added in udisks 1.95.0 (and so was the
+ * UDISKS_CHECK_VERSION macro) - for now, be compatible with older
+ * versions instead of bumping requirement in configure.ac
+ */
+#ifdef UDISKS_CHECK_VERSION
+# if UDISKS_CHECK_VERSION(1,95,0)
+ drive_seat = udisks_drive_get_seat (drive);
+# endif
+#endif
+ if (drive_seat == NULL || strlen (drive_seat) == 0)
+ {
+ ret = TRUE;
+ goto out;
+ }
+
+ /* "all" is special, it means the device is available on any seat */
+ if (g_strcmp0 (drive_seat, "all") == 0)
+ {
+ ret = TRUE;
+ goto out;
+ }
+
+ /* Otherwise, check if it's on our seat */
+ if (g_strcmp0 (seat, drive_seat) == 0)
+ ret = TRUE;
+
+ out:
+ return ret;
+}
diff --git a/monitor/udisks2/gvfsudisks2utils.h b/monitor/udisks2/gvfsudisks2utils.h
index 2b6dc3c..1965883 100644
--- a/monitor/udisks2/gvfsudisks2utils.h
+++ b/monitor/udisks2/gvfsudisks2utils.h
@@ -50,6 +50,8 @@ gboolean gvfs_udisks2_utils_spawn_finish (GAsyncResult *res,
gchar **out_standard_error,
GError **error);
+gboolean gvfs_udisks2_utils_is_drive_on_our_seat (UDisksDrive *drive);
+
G_END_DECLS
diff --git a/monitor/udisks2/gvfsudisks2volume.c b/monitor/udisks2/gvfsudisks2volume.c
index 243dc14..a1c7fa4 100644
--- a/monitor/udisks2/gvfsudisks2volume.c
+++ b/monitor/udisks2/gvfsudisks2volume.c
@@ -36,41 +36,6 @@
#include "gvfsudisks2mount.h"
#include "gvfsudisks2utils.h"
-
-#if defined(HAVE_LIBSYSTEMD_LOGIN)
-#include <systemd/sd-login.h>
-
-static const gchar *
-get_seat (void)
-{
- static gsize once = 0;
- static char *seat = NULL;
-
- if (g_once_init_enter (&once))
- {
- char *session = NULL;
- if (sd_pid_get_session (getpid (), &session) == 0)
- {
- sd_session_get_seat (session, &seat);
- /* we intentionally leak seat here... */
- }
- g_once_init_leave (&once, (gsize) 1);
- }
- return seat;
-}
-
-#else
-
-static const gchar *
-get_seat (void)
-{
- return NULL;
-}
-
-#endif
-
-
-
typedef struct _GVfsUDisks2VolumeClass GVfsUDisks2VolumeClass;
struct _GVfsUDisks2VolumeClass
@@ -213,43 +178,6 @@ apply_options_from_fstab (GVfsUDisks2Volume *volume,
}
static gboolean
-drive_is_on_our_seat (UDisksDrive *drive)
-{
- gboolean ret = FALSE;
- const gchar *seat;
- const gchar *drive_seat = NULL;
-
- /* assume our own seat if we don't have seat-support or it doesn't work */
- seat = get_seat ();
- if (seat == NULL)
- {
- ret = TRUE;
- goto out;
- }
-
- /* Assume seat0 if a) device is not tagged; or b) udisks does not
- * have seat-support.
- *
- * Note that seat support was added in udisks 1.95.0 (and so was the
- * UDISKS_CHECK_VERSION macro) - for now, be compatible with older
- * versions instead of bumping requirement in configure.ac
- */
-#ifdef UDISKS_CHECK_VERSION
-# if UDISKS_CHECK_VERSION(1,95,0)
- drive_seat = udisks_drive_get_seat (drive);
-# endif
-#endif
- if (drive_seat == NULL || strlen (drive_seat) == 0)
- drive_seat = "seat0";
-
- if (g_strcmp0 (seat, drive_seat) == 0)
- ret = TRUE;
-
- out:
- return ret;
-}
-
-static gboolean
update_volume (GVfsUDisks2Volume *volume)
{
gboolean changed;
@@ -387,7 +315,7 @@ update_volume (GVfsUDisks2Volume *volume)
g_object_unref (media_icon);
/* Only automount drives attached to the same seat as we're running on */
- if (drive_is_on_our_seat (udisks_drive))
+ if (gvfs_udisks2_utils_is_drive_on_our_seat (udisks_drive))
{
/* Only automount filesystems from drives of known types/interconnects:
*
diff --git a/monitor/udisks2/gvfsudisks2volumemonitor.c b/monitor/udisks2/gvfsudisks2volumemonitor.c
index 1ea86b2..2826164 100644
--- a/monitor/udisks2/gvfsudisks2volumemonitor.c
+++ b/monitor/udisks2/gvfsudisks2volumemonitor.c
@@ -805,6 +805,9 @@ should_include_volume_check_configuration (GVfsUDisks2VolumeMonitor *monitor,
return ret;
}
+static gboolean should_include_drive (GVfsUDisks2VolumeMonitor *monitor,
+ UDisksDrive *drive);
+
static gboolean
should_include_volume (GVfsUDisks2VolumeMonitor *monitor,
UDisksBlock *block,
@@ -813,12 +816,23 @@ should_include_volume (GVfsUDisks2VolumeMonitor *monitor,
gboolean ret = FALSE;
GDBusObject *object;
UDisksFilesystem *filesystem;
+ UDisksDrive *udisks_drive = NULL;
const gchar* const *mount_points;
/* Block:Ignore trumps everything */
if (udisks_block_get_hint_ignore (block))
goto out;
+ /* ignore the volume if the drive is ignored */
+ udisks_drive = udisks_client_get_drive_for_block (monitor->client, block);
+ if (udisks_drive != NULL)
+ {
+ if (!should_include_drive (monitor, udisks_drive))
+ {
+ goto out;
+ }
+ }
+
/* show encrypted volumes... */
if (g_strcmp0 (udisks_block_get_id_type (block), "crypto_LUKS") == 0)
{
@@ -879,6 +893,7 @@ should_include_volume (GVfsUDisks2VolumeMonitor *monitor,
ret = TRUE;
out:
+ g_clear_object (&udisks_drive);
return ret;
}
@@ -888,17 +903,26 @@ static gboolean
should_include_drive (GVfsUDisks2VolumeMonitor *monitor,
UDisksDrive *drive)
{
- /* NOTE: For now, we just include all detected drives. This is
- * probably wrong - non-removable drives without anything visible
- * (such RAID components) should probably not be shown. Then again,
- * the GNOME 3 user interface doesn't really show GDrive instances
- * except for in the computer:/// location in Nautilus.
- *
- * Therefore, if device is non-removable, maybe only show it, if it
- * has more visible devices... this is the gdu volume monitor
- * behavior.
+ gboolean ret = TRUE;
+
+ /* Don't include drives on other seats */
+ if (!gvfs_udisks2_utils_is_drive_on_our_seat (drive))
+ {
+ ret = FALSE;
+ goto out;
+ }
+
+ /* NOTE: For now, we just include a drive no matter its
+ * content. This may be wrong ... for example non-removable drives
+ * without anything visible (such RAID components) should probably
+ * not be shown. Then again, the GNOME 3 user interface doesn't
+ * really show GDrive instances except for in the computer:///
+ * location in Nautilus....
*/
- return TRUE;
+
+ out:
+
+ return ret;
}
/* ---------------------------------------------------------------------------------------------------- */
@@ -1743,6 +1767,9 @@ update_discs (GVfsUDisks2VolumeMonitor *monitor,
if (udisks_drive == NULL)
continue;
+ if (!should_include_drive (monitor, udisks_drive))
+ continue;
+
/* only consider blank and audio discs */
if (!(udisks_drive_get_optical_blank (udisks_drive) ||
udisks_drive_get_optical_num_audio_tracks (udisks_drive) > 0))
--
1.7.3.4

View File

@ -1,12 +1,12 @@
Summary: Backends for the gio framework in GLib Summary: Backends for the gio framework in GLib
Name: gvfs Name: gvfs
Version: 1.12.2 Version: 1.13.0
Release: 1%{?dist} Release: 1%{?dist}
License: LGPLv2+ License: LGPLv2+
Group: System Environment/Libraries Group: System Environment/Libraries
URL: http://www.gtk.org URL: http://www.gtk.org
Source: http://download.gnome.org/sources/gvfs/1.12/gvfs-%{version}.tar.xz Source: http://download.gnome.org/sources/gvfs/1.13/gvfs-%{version}.tar.xz
BuildRequires: pkgconfig BuildRequires: pkgconfig
BuildRequires: glib2-devel >= 2.31.0 BuildRequires: glib2-devel >= 2.31.0
# for post-install update-gio-modules and overall functionality # for post-install update-gio-modules and overall functionality
@ -36,12 +36,6 @@ BuildRequires: libtool
# http://bugzilla.gnome.org/show_bug.cgi?id=567235 # http://bugzilla.gnome.org/show_bug.cgi?id=567235
Patch0: gvfs-archive-integration.patch Patch0: gvfs-archive-integration.patch
# from master
Patch1: gvfs-1.13.0-multiseat-dont-set-should_automount.patch
Patch2: gvfs-1.13.0-multiseat-dont-show-drives.patch
Patch3: gvfs-1.13.0-multiseat-dont-automount-if-shared.patch
Patch4: gvfs-1.13.0-multiseat-LUKS-encryption-pass.patch
Obsoletes: gnome-mount <= 0.8 Obsoletes: gnome-mount <= 0.8
Obsoletes: gnome-mount-nautilus-properties <= 0.8 Obsoletes: gnome-mount-nautilus-properties <= 0.8
@ -155,10 +149,6 @@ to applications using gvfs.
%prep %prep
%setup -q %setup -q
%patch0 -p1 -b .archive-integration %patch0 -p1 -b .archive-integration
%patch1 -p1 -b .multiseat-dont-set-should_automount
%patch2 -p1 -b .multiseat-dont-show-drives
%patch3 -p1 -b .multiseat-dont-automount-if-shared
%patch4 -p1 -b .multiseat-LUKS-encryption-pass
%build %build
@ -329,6 +319,9 @@ killall -USR1 gvfsd >&/dev/null || :
%{_datadir}/gvfs/mounts/afp-browse.mount %{_datadir}/gvfs/mounts/afp-browse.mount
%changelog %changelog
* Wed May 2 2012 Tomas Bzatek <tbzatek@redhat.com> - 1.13.0-1
- Update to 1.13.0
* Fri Apr 27 2012 Tomas Bzatek <tbzatek@redhat.com> - 1.12.2-1 * Fri Apr 27 2012 Tomas Bzatek <tbzatek@redhat.com> - 1.12.2-1
- Update to 1.12.2 - Update to 1.12.2
- Backport multiseat patches from master - Backport multiseat patches from master

View File

@ -1 +1 @@
fc828681caa5f26a39bfb661c40d29e9 gvfs-1.12.2.tar.xz 2af7c5a8eca4446d8b2ca19db6bb962c gvfs-1.13.0.tar.xz