File gnome-mount-old-hal.patch of Package gnome-mount
--- configure.in
+++ configure.in
@@ -83,12 +83,12 @@
fi
AM_CONDITIONAL(ENABLE_NAUTILUS_EXTENSION, test "x$enable_nautilus_extension" = "xyes")
-PKG_CHECK_MODULES(GNOME_MOUNT, gconf-2.0 gnome-keyring-1 >= 0.4 dbus-glib-1 >= 0.31 hal-storage >= 0.5.8.1 gtk+-2.0 >= 2.8.0)
+PKG_CHECK_MODULES(GNOME_MOUNT, gconf-2.0 gnome-keyring-1 >= 0.4 dbus-glib-1 >= 0.31 hal-storage >= 0.5.6 gtk+-2.0 >= 2.8.0)
AC_SUBST(GNOME_MOUNT_CFLAGS)
AC_SUBST(GNOME_MOUNT_LIBS)
if test "x$enable_nautilus_extension" = "xyes"; then
- PKG_CHECK_MODULES(GNOME_MOUNT_PROPERTIES, libgnomeui-2.0 >= 2.1.5 libglade-2.0 hal-storage >= 0.5.8.1 dbus-1 >= 0.60 dbus-glib-1 >= 0.60 gtk+-2.0 >= 2.8.0)
+ PKG_CHECK_MODULES(GNOME_MOUNT_PROPERTIES, libgnomeui-2.0 >= 2.1.5 libglade-2.0 hal-storage >= 0.5.6 dbus-1 >= 0.60 dbus-glib-1 >= 0.60 gtk+-2.0 >= 2.8.0)
AC_SUBST(GNOME_MOUNT_PROPERTIES_CFLAGS)
AC_SUBST(GNOME_MOUNT_PROPERTIES_LIBS)
--- src/gnome-mount.c
+++ src/gnome-mount.c
@@ -1560,38 +1560,25 @@
char *vendor;
char *drive_name;
DBusPendingCall *pending_return;
- gboolean is_ro;
ret = FALSE;
g_debug ("Unmounting %s", udi);
- is_ro = FALSE;
-
model = NULL;
vendor = NULL;
if (drive != NULL) {
model = g_strdup (libhal_drive_get_model (drive));
vendor = g_strdup (libhal_drive_get_vendor (drive));
- if (libhal_drive_get_type (drive) == LIBHAL_DRIVE_TYPE_CDROM) {
- is_ro = TRUE;
- }
} else if (volume != NULL) {
drive = libhal_drive_from_udi (hal_ctx,
libhal_volume_get_storage_device_udi (volume));
if (drive != NULL) {
model = g_strdup (libhal_drive_get_model (drive));
vendor = g_strdup (libhal_drive_get_vendor (drive));
- if (libhal_drive_get_type (drive) == LIBHAL_DRIVE_TYPE_CDROM) {
- is_ro = TRUE;
- }
libhal_drive_free (drive);
drive = NULL;
}
-
- if (!is_ro) {
- is_ro = libhal_volume_is_mounted_read_only (volume);
- }
}
if (vendor != NULL && model != NULL)
@@ -1695,9 +1682,7 @@
* So put up a dialog after some time that tells the user we're flushing
* the cache.
*/
- if (!is_ro) {
- unmount_cache_timeout_start (drive_name, FALSE);
- }
+ unmount_cache_timeout_start (drive_name, FALSE);
/* it also means we can't use dbus_connection_send_with_reply_and_block() as
* that function doesn't enter the mainloop
@@ -1722,9 +1707,7 @@
dbus_error_init (&error);
if (dbus_set_error_from_message (&error, reply)) {
- if (!is_ro) {
- unmount_cache_timeout_cancel (FALSE);
- }
+ unmount_cache_timeout_cancel (FALSE);
g_warning ("Unmount failed for %s: %s : %s\n", udi, error.name, error.message);
show_error_dialog_unmount (udi, volume, drive, error.name, error.message);
dbus_error_free (&error);
@@ -1732,9 +1715,7 @@
}
g_print (_("Unmounted %s\n"), get_dev_file (volume, drive));
- if (!is_ro) {
- unmount_cache_timeout_cancel (TRUE);
- }
+ unmount_cache_timeout_cancel (TRUE);
ret = TRUE;
out:
@@ -1764,39 +1745,26 @@
char *model;
char *vendor;
char *drive_name;
- gboolean is_ro;
DBusPendingCall *pending_return;
ret = FALSE;
g_debug ("Ejecting %s", udi);
- is_ro = FALSE;
-
model = NULL;
vendor = NULL;
if (drive != NULL) {
model = g_strdup (libhal_drive_get_model (drive));
vendor = g_strdup (libhal_drive_get_vendor (drive));
- if (libhal_drive_get_type (drive) == LIBHAL_DRIVE_TYPE_CDROM) {
- is_ro = TRUE;
- }
} else if (volume != NULL) {
drive = libhal_drive_from_udi (hal_ctx,
libhal_volume_get_storage_device_udi (volume));
if (drive != NULL) {
model = g_strdup (libhal_drive_get_model (drive));
vendor = g_strdup (libhal_drive_get_vendor (drive));
- if (libhal_drive_get_type (drive) == LIBHAL_DRIVE_TYPE_CDROM) {
- is_ro = TRUE;
- }
libhal_drive_free (drive);
drive = NULL;
}
-
- if (!is_ro) {
- is_ro = libhal_volume_is_mounted_read_only (volume);
- }
}
if (vendor != NULL && model != NULL)
@@ -1899,9 +1867,7 @@
* So put up a dialog after some time that tells the user we're flushing
* the cache.
*/
- if (!is_ro) {
- unmount_cache_timeout_start (drive_name, TRUE);
- }
+ unmount_cache_timeout_start (drive_name, TRUE);
/* it also means we can't use dbus_connection_send_with_reply_and_block() as
* that function doesn't enter the mainloop
@@ -1926,9 +1892,7 @@
dbus_error_init (&error);
if (dbus_set_error_from_message (&error, reply)) {
- if (!is_ro) {
- unmount_cache_timeout_cancel (FALSE);
- }
+ unmount_cache_timeout_cancel (FALSE);
g_warning ("Eject failed for %s: %s : %s\n", udi, error.name, error.message);
show_error_dialog_eject (udi, volume, drive, error.name, error.message);
dbus_error_free (&error);
@@ -1936,9 +1900,7 @@
}
g_print (_("Ejected %s\n"), get_dev_file (volume, drive));
- if (!is_ro) {
- unmount_cache_timeout_cancel (TRUE);
- }
+ unmount_cache_timeout_cancel (TRUE);
ret = TRUE;
@@ -2157,192 +2119,6 @@
return result;
}
-static gboolean
-setup_crypto (const char *udi, LibHalVolume *volume, LibHalDrive *drive,
- const char *password, gboolean *password_error)
-{
- gboolean ret = FALSE;
- DBusMessage *msg = NULL;
- DBusMessage *reply = NULL;
- DBusError error;
-
- *password_error = FALSE;
-
- g_debug ("Setting up %s for crypto", udi);
-
- msg = dbus_message_new_method_call ("org.freedesktop.Hal", udi,
- "org.freedesktop.Hal.Device.Volume.Crypto",
- "Setup");
- if (msg == NULL) {
- g_warning ("Could not create dbus message for %s", udi);
- goto out;
- }
-
- if (!dbus_message_append_args (msg,
- DBUS_TYPE_STRING, &password,
- DBUS_TYPE_INVALID)) {
- g_warning ("Could not append args to dbus message for %s", udi);
- goto out;
- }
-
- dbus_error_init (&error);
- if (!(reply = dbus_connection_send_with_reply_and_block (dbus_connection, msg, DBUS_TIMEOUT, &error)) ||
- dbus_error_is_set (&error)) {
- g_warning ("Setup failed for %s: %s : %s\n", udi, error.name, error.message);
- if (strcmp (error.name, "org.freedesktop.Hal.Device.Volume.Crypto.SetupPasswordError") == 0) {
- *password_error = TRUE;
- }
- dbus_error_free (&error);
- goto out;
- }
-
-
- ret = TRUE;
-
- g_print (_("Setup clear-text device for %s.\n"), get_dev_file (volume, drive));
-
-out:
- if (msg != NULL)
- dbus_message_unref (msg);
- if (reply != NULL)
- dbus_message_unref (reply);
-
- return ret;
-}
-
-static gboolean
-teardown_crypto (const char *udi, LibHalVolume *volume, LibHalDrive *drive)
-{
- gboolean ret = FALSE;
- DBusMessage *msg = NULL;
- DBusMessage *reply = NULL;
- DBusError error;
- char *clear_udi;
-
- g_debug ("Tearing down %s for crypto", udi);
-
- clear_udi = libhal_volume_crypto_get_clear_volume_udi (hal_ctx, volume);
- if (clear_udi != NULL) {
- LibHalVolume *clear_volume;
- gboolean unmount_child_failed;
-
- unmount_child_failed = FALSE;
-
- clear_volume = libhal_volume_from_udi (hal_ctx, clear_udi);
- if (clear_volume != NULL) {
- if (libhal_volume_is_mounted (clear_volume)) {
- if (!volume_unmount (clear_udi, clear_volume, NULL))
- unmount_child_failed = TRUE;
- }
- libhal_volume_free (clear_volume);
- }
- free (clear_udi);
-
- if (unmount_child_failed)
- goto out;
- }
-
-
- msg = dbus_message_new_method_call ("org.freedesktop.Hal", udi,
- "org.freedesktop.Hal.Device.Volume.Crypto",
- "Teardown");
- if (msg == NULL) {
- g_warning ("Could not create dbus message for %s", udi);
- goto out;
- }
-
- if (!dbus_message_append_args (msg,
- DBUS_TYPE_INVALID)) {
- g_warning ("Could not append args to dbus message for %s", udi);
- goto out;
- }
-
- dbus_error_init (&error);
- if (!(reply = dbus_connection_send_with_reply_and_block (dbus_connection, msg, DBUS_TIMEOUT, &error)) ||
- dbus_error_is_set (&error)) {
- g_warning ("Teardown failed for %s: %s : %s\n", udi, error.name, error.message);
- dbus_error_free (&error);
- goto out;
- }
-
- g_print (_("Teared down clear-text device for %s.\n"), get_dev_file (volume, drive));
-
- ret = TRUE;
-
-out:
- if (msg != NULL)
- dbus_message_unref (msg);
- if (reply != NULL)
- dbus_message_unref (reply);
-
- return ret;
-}
-
-static const char *crypto_setup_backing_udi = NULL;
-static int crypto_setup_rc = 1;
-
-static void
-crypto_setup_device_removed (LibHalContext *ctx, const char *udi)
-{
- g_debug ("In crypto_setup_device_removed for %s", udi);
-
- if (strcmp (udi, crypto_setup_backing_udi) == 0) {
- g_debug ("Backing volume removed! Exiting..");
- gtk_exit (1);
- }
-}
-
-static void
-crypto_setup_device_added (LibHalContext *ctx, const char *udi)
-{
- const char *backing_udi;
- DBusError error;
- LibHalVolume *volume;
-
- g_debug ("In crypto_setup_device_added for %s", udi);
-
- backing_udi = NULL;
- volume = libhal_volume_from_udi (hal_ctx, udi);
- if (volume != NULL) {
- backing_udi = libhal_volume_crypto_get_backing_volume_udi (volume);
- if (backing_udi != NULL) {
- if (strcmp (backing_udi, crypto_setup_backing_udi) == 0) {
- LibHalVolumeUsage fsuage;
-
- g_debug ("%s is backed by %s - will mount", udi, backing_udi);
-
- g_print (_("Clear text device is %s. Mounting.\n"), get_dev_file (volume, NULL));
-
- fsuage = libhal_volume_get_fsusage (volume);
-
- if (fsuage == LIBHAL_VOLUME_USAGE_MOUNTABLE_FILESYSTEM) {
- if (volume_mount (udi, volume, NULL))
- crypto_setup_rc = 0;
- } else {
- g_warning ("%s does not have a mountable filesystem", udi);
- }
-
- notify_parent (crypto_setup_rc == 0);
- gtk_main_quit ();
- }
- }
-
- libhal_volume_free (volume);
- }
-
-}
-
-static gboolean
-crypto_setup_timeout (gpointer data)
-{
- g_warning ("Timeout for waiting for cleartext device... Exiting.");
- notify_parent (FALSE);
- gtk_main_quit ();
-
- return FALSE;
-}
-
-
static void
my_empty_log_handler (const gchar *log_domain,
GLogLevelFlags log_level,
@@ -2576,8 +2352,6 @@
LibHalVolume *volume = NULL;
const char *udi;
char *resolved_device_file = NULL;
- static gboolean opt_connect_crypto = FALSE;
- static gboolean opt_disconnect_crypto = FALSE;
static gboolean opt_verbose = FALSE;
static gboolean opt_unmount = FALSE;
static gboolean opt_eject = FALSE;
@@ -2599,8 +2373,6 @@
{ "no-ui", 'n', 0, G_OPTION_ARG_NONE, &opt_noui, "Don't show any dialogs", NULL},
{ "block", 'b', 0, G_OPTION_ARG_NONE, &opt_block, "Allow gnome-mount to block for UI", NULL},
{ "unmount", 'u', 0, G_OPTION_ARG_NONE, &opt_unmount, "Unmount", NULL},
- { "connect-crypto", 0, 0, G_OPTION_ARG_NONE, &opt_connect_crypto, "Setup crypto device", NULL},
- { "disconnect-crypto", 0, 0, G_OPTION_ARG_NONE, &opt_disconnect_crypto, "Tear down crypto device", NULL},
{ "eject", 'e', 0, G_OPTION_ARG_NONE, &opt_eject, "Eject", NULL},
{ "hal-udi", 'h', 0, G_OPTION_ARG_STRING, &opt_hal_udi, "Mount by HAL UDI", NULL},
{ "device", 'd', 0, G_OPTION_ARG_STRING, &opt_device_file, "Mount by device file", NULL},
@@ -2633,10 +2405,6 @@
extra_mount_options_from_command_line = g_strdup (opt_extra_mount_options);
fstype_from_command_line = g_strdup (opt_fstype);
- if (opt_disconnect_crypto) {
- opt_unmount = TRUE;
- }
-
/* these options are only meaningful from the commandline */
if (opt_display_settings ||
opt_write_settings ||
@@ -2857,27 +2625,12 @@
fsusage = LIBHAL_VOLUME_USAGE_UNKNOWN;
}
- if (fsusage == LIBHAL_VOLUME_USAGE_CRYPTO) {
- if (teardown_crypto (udi, volume, drive))
- rc = 0;
- } else {
+ {
if (volume_unmount (udi, volume, drive)) {
/* as a convenience also tear down the crypto backing volume if appropriate */
if (volume != NULL) {
- const char *backing_udi;
- backing_udi = libhal_volume_crypto_get_backing_volume_udi (volume);
- if (backing_udi != NULL) {
- LibHalVolume *backing_volume;
- backing_volume = libhal_volume_from_udi (hal_ctx, backing_udi);
- if (backing_volume != NULL) {
- if (teardown_crypto (backing_udi, backing_volume, NULL))
- rc = 0;
- libhal_volume_free (backing_volume);
- }
- } else {
rc = 0;
- }
}
}
}
@@ -2894,70 +2647,7 @@
fsusage = LIBHAL_VOLUME_USAGE_UNKNOWN;
}
- if (fsusage == LIBHAL_VOLUME_USAGE_CRYPTO) {
- char *password;
- gboolean password_error;
- gboolean setup_success;
- char *clear_udi;
- gboolean password_retry;
- int password_num_tries;
-
- /* see if we're already setup */
- clear_udi = libhal_volume_crypto_get_clear_volume_udi (hal_ctx, volume);
- if (clear_udi != NULL) {
- g_warning (_("Crypto volume '%s' is already setup with clear volume '%s'"),
- udi, clear_udi);
-
- free (clear_udi);
- goto out;
- }
-
- g_debug ("Crypto volume - UDI '%s'", udi);
-
- setup_success = FALSE;
-
- /* we need this to catch when the cleartext device is added */
- crypto_setup_backing_udi = udi;
- libhal_ctx_set_device_added (hal_ctx, crypto_setup_device_added);
- /* we need to catch this if the backing device is removed (to remove the password dialog) */
- libhal_ctx_set_device_removed (hal_ctx, crypto_setup_device_removed);
-
- password_retry = FALSE;
- password_num_tries = 0;
- retry_password:
- password = get_password (udi, volume, drive, password_retry);
- password_num_tries++;
- if (password != NULL) {
- setup_success = setup_crypto (udi, volume, drive, password, &password_error);
- if (!setup_success && password_error) {
- g_warning (_("Bad crypto password"));
- if (!opt_nodisplay && password_num_tries < 3) {
- g_free (password);
- password_retry = TRUE;
- goto retry_password;
- } else {
- g_warning (_("Bailing out..."));
- }
- }
- }
-
- /* mount the clear volume except if --connect-crypto was explicitly passed */
- if (setup_success && !opt_connect_crypto) {
-
- /* wait as we try to mount the cleartext volume */
- g_debug ("Waiting for cleartext volume backed by %s..", udi);
- /* add a timeout as we don't want to wait forever */
- g_timeout_add (10 * 1000, crypto_setup_timeout, NULL);
- gtk_main();
-
- rc = crypto_setup_rc;
- }
-
- g_free (password);
-
- goto out;
-
- } else if (fsusage == LIBHAL_VOLUME_USAGE_MOUNTABLE_FILESYSTEM ||
+ if (fsusage == LIBHAL_VOLUME_USAGE_MOUNTABLE_FILESYSTEM ||
fsusage == LIBHAL_VOLUME_USAGE_UNKNOWN) {
if (volume_mount (udi, volume, drive))
rc = 0;