[Xfce4-commits] <xfce4-mount-plugin:master> Remove use_sudo option, after all "experienced users" can use custom mount commands.

Landry Breuil noreply at xfce.org
Mon Apr 23 17:28:01 CEST 2012


Updating branch refs/heads/master
         to e70555df5cd7651d6f38d4eeb565be5da325e33f (commit)
       from 3a6b8288a68d90590e40d5110ed06da0cd014574 (commit)

commit e70555df5cd7651d6f38d4eeb565be5da325e33f
Author: Landry Breuil <landry at xfce.org>
Date:   Mon Apr 23 17:23:18 2012 +0200

    Remove use_sudo option, after all "experienced users" can use custom mount commands.
    
    This can also lead to confusion/hangs if an user wants to use sudo
    but didnt configure it to be passwordless (bug #8717)

 panel-plugin/devices.c      |   20 ++++----------------
 panel-plugin/devices.h      |    6 ++----
 panel-plugin/mount-plugin.c |   28 ++--------------------------
 panel-plugin/mount-plugin.h |    2 --
 4 files changed, 8 insertions(+), 48 deletions(-)

diff --git a/panel-plugin/devices.c b/panel-plugin/devices.c
index 090a66c..5f823b7 100644
--- a/panel-plugin/devices.c
+++ b/panel-plugin/devices.c
@@ -236,7 +236,7 @@ disk_free(t_disk **pdisk)
  * Return exit status of the mount command
  */
 void
-disk_mount (t_disk *pdisk, char *on_mount_cmd, char* mount_command, gboolean eject, gboolean use_sudo)
+disk_mount (t_disk *pdisk, char *on_mount_cmd, char* mount_command, gboolean eject)
 {
     gchar *tmp = NULL, *cmd = NULL;
     gchar *output = NULL, *erroutput = NULL;
@@ -246,7 +246,7 @@ disk_mount (t_disk *pdisk, char *on_mount_cmd, char* mount_command, gboolean eje
 
     if (pdisk != NULL)
     {
-        DBG("disk_mount: dev=%s, mountpoint=%s, mount_command=%s, on_mount_cmd=%s, eject=%d, use_sudo=%d", pdisk->device, pdisk->mount_point, mount_command, on_mount_cmd, eject, use_sudo);
+        DBG("disk_mount: dev=%s, mountpoint=%s, mount_command=%s, on_mount_cmd=%s, eject=%d", pdisk->device, pdisk->mount_point, mount_command, on_mount_cmd, eject);
         if (eject) {
 #ifdef __OpenBSD__
 /* hack: on OpenBSD, eject(1) -t expects cd0/cd1 (or rcd0c/rcd1c), if passed /dev/cdXa it will spit 'No medium found' */
@@ -272,12 +272,6 @@ disk_mount (t_disk *pdisk, char *on_mount_cmd, char* mount_command, gboolean eje
         deviceprintf (&tmp, mount_command, pdisk->device);
         mountpointprintf (&cmd, tmp, pdisk->mount_point);
         /* cmd contains mount_command device mount_point */
-        if (use_sudo) {
-            g_free(tmp);
-            tmp = g_strdup(cmd);
-            g_free(cmd);
-            cmd = g_strconcat ("sudo ", tmp, NULL);
-        }
         val = g_spawn_command_line_sync (cmd, &output, &erroutput, &exit_status, &error);
         DBG("cmd: '%s', returned %d, exit_status=%d", cmd, val, exit_status);
         if (val == FALSE || exit_status != 0)
@@ -309,7 +303,7 @@ out:
  * Return exit status of the umount command.
  */
 void
-disk_umount (t_disk *pdisk, char* umount_command, gboolean show_message_dialog, gboolean eject, gboolean use_sudo)
+disk_umount (t_disk *pdisk, char* umount_command, gboolean show_message_dialog, gboolean eject)
 {
     gchar *tmp = NULL, *cmd = NULL;
     gchar *output = NULL, *erroutput = NULL;
@@ -320,16 +314,10 @@ disk_umount (t_disk *pdisk, char* umount_command, gboolean show_message_dialog,
     if (pdisk != NULL)
     {
 
-        DBG("disk_umount: dev=%s, mountpoint=%s, umount_command=%s, show_message_dialog=%d, eject=%d, use_sudo=%d", pdisk->device, pdisk->mount_point, umount_command, show_message_dialog, eject, use_sudo);
+        DBG("disk_umount: dev=%s, mountpoint=%s, umount_command=%s, show_message_dialog=%d, eject=%d", pdisk->device, pdisk->mount_point, umount_command, show_message_dialog, eject);
         deviceprintf(&tmp, umount_command, pdisk->device);
         mountpointprintf(&cmd, tmp, pdisk->mount_point);
         /* cmd contains umount_command device mount_point */
-        if (use_sudo) {
-            g_free(tmp);
-            tmp = g_strdup(cmd);
-            g_free(cmd);
-            cmd = g_strconcat ("sudo ", tmp, NULL);
-        }
         val = g_spawn_command_line_sync (cmd, &output, &erroutput, &exit_status, &error);
         DBG("cmd: '%s', returned %d, exit_status=%d", cmd, val, exit_status);
         if (val == FALSE || exit_status != 0)
diff --git a/panel-plugin/devices.h b/panel-plugin/devices.h
index 5b917b0..040bc64 100644
--- a/panel-plugin/devices.h
+++ b/panel-plugin/devices.h
@@ -93,9 +93,8 @@ char * get_size_human_readable(float size);
  * @param on_mount_cmd    Command to execute after successfully mounting the device
  * @param mount_command    Command to use for mounting the device, still containing placeholders like \%d and \%m.
  * @param eject            Whether to inject the device before mounting.
- * @param use_sudo         Whether to use sudo to run the mount command.
  */
-void disk_mount (t_disk *pdisk, char *on_mount_cmd, char* mount_command, gboolean eject, gboolean use_sudo);
+void disk_mount (t_disk *pdisk, char *on_mount_cmd, char* mount_command, gboolean eject);
 
 
 /**
@@ -104,9 +103,8 @@ void disk_mount (t_disk *pdisk, char *on_mount_cmd, char* mount_command, gboolea
  * @param umount_command    Command to use for unmounting the device, still containing placeholders like \%d and \%m.
  * @param show_message_dialog Whether to show a dialog upon successful umount for device removal
  * @param eject            Whether to eject the device after unmounting.
- * @param use_sudo         Whether to use sudo to run the umount command.
  */
-void disk_umount (t_disk *pdisk, char* umount_command, gboolean show_message_dialog, gboolean eject, gboolean use_sudo);
+void disk_umount (t_disk *pdisk, char* umount_command, gboolean show_message_dialog, gboolean eject);
 
 
 /**
diff --git a/panel-plugin/mount-plugin.c b/panel-plugin/mount-plugin.c
index 25ae2a1..894ebf4 100644
--- a/panel-plugin/mount-plugin.c
+++ b/panel-plugin/mount-plugin.c
@@ -49,10 +49,10 @@ on_activate_disk_display (GtkWidget *widget, t_disk * disk)
 
     if (disk != NULL) {
         if (disk->mount_info != NULL) { /* disk is mounted */
-            disk_umount (disk, mt->umount_command, mt->message_dialog, eject, mt->use_sudo);
+            disk_umount (disk, mt->umount_command, mt->message_dialog, eject);
         }
         else { /* disk is not mounted */
-            disk_mount (disk, mt->on_mount_cmd, mt->mount_command, eject, mt->use_sudo);
+            disk_mount (disk, mt->on_mount_cmd, mt->mount_command, eject);
         }
     }
 
@@ -379,8 +379,6 @@ mounter_read_config (XfcePanelPlugin *plugin, t_mounter *mt)
     mt->umount_command = g_strdup(xfce_rc_read_entry(rc, "umount_command", DEFAULT_UMOUNT_COMMAND));
     mt->excluded_filesystems = g_strdup(xfce_rc_read_entry(rc, "excluded_filesystems", ""));
 
-    mt->use_sudo = xfce_rc_read_bool_entry(rc, "use_sudo", FALSE);
-
     /* before 0.6.0 those booleans were stored as string "1".. handle/merge legacy configs */
     if (xfce_rc_has_entry(rc, "message_dialog"))
         mt->message_dialog = atoi(xfce_rc_read_entry(rc, "message_dialog", NULL));
@@ -442,7 +440,6 @@ mounter_write_config (XfcePanelPlugin *plugin, t_mounter *mt)
     xfce_rc_write_bool_entry (rc, "exclude_selected_filesystems", mt->exclude_FSs);
     xfce_rc_write_bool_entry (rc, "exclude_devicenames_in_menu", mt->exclude_devicenames);
     xfce_rc_write_bool_entry (rc, "eject_cddrives", mt->eject_drives);
-    xfce_rc_write_bool_entry (rc, "use_sudo", mt->use_sudo);
 
     xfce_rc_close (rc);
 
@@ -469,7 +466,6 @@ create_mounter_control (XfcePanelPlugin *plugin)
     mounter->exclude_FSs = FALSE;
     mounter->eject_drives = FALSE;
     mounter->exclude_devicenames = FALSE;
-    mounter->use_sudo = FALSE;
 
     mounter->plugin = plugin;
 
@@ -549,9 +545,6 @@ mounter_apply_options (t_mounter_dialog *md)
     mt->eject_drives = gtk_toggle_button_get_active
             (GTK_TOGGLE_BUTTON(md->show_eject_drives));
 
-    mt->use_sudo = gtk_toggle_button_get_active
-            (GTK_TOGGLE_BUTTON(md->show_use_sudo));
-
     mt->exclude_FSs = gtk_toggle_button_get_active
             (GTK_TOGGLE_BUTTON(md->show_exclude_FSs));
 
@@ -751,23 +744,6 @@ mounter_create_options (XfcePanelPlugin *plugin, t_mounter *mt)
     gtk_container_border_width (GTK_CONTAINER(_vbox), BORDER);
     gtk_widget_show (_vbox);
 
-        /* use sudo checkbox */
-    _eventbox = gtk_event_box_new ();
-    gtk_box_pack_start (GTK_BOX (_vbox), GTK_WIDGET(_eventbox),
-                        FALSE, FALSE, 0);
-    gtk_widget_show (_eventbox);
-    gtk_tooltips_set_tip ( GTK_TOOLTIPS(tip), _eventbox,
-        _("Activate this option to use sudo(8) to run mount/umount commands. Needs to be configured without password."),
-        NULL );
-
-    md->show_use_sudo = gtk_check_button_new_with_mnemonic (
-                                _("Use _sudo") );
-
-    gtk_widget_show (md->show_use_sudo);
-    gtk_container_add (GTK_CONTAINER (_eventbox), md->show_use_sudo );
-    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(md->show_use_sudo),
-                                mt->use_sudo);
-
         /* After-mount command */
     _eventbox = gtk_event_box_new ();
     gtk_box_pack_start (GTK_BOX (_vbox), GTK_WIDGET(_eventbox),
diff --git a/panel-plugin/mount-plugin.h b/panel-plugin/mount-plugin.h
index 8371a54..54f7181 100644
--- a/panel-plugin/mount-plugin.h
+++ b/panel-plugin/mount-plugin.h
@@ -63,7 +63,6 @@ typedef struct
     gboolean exclude_FSs;
     gboolean exclude_devicenames;
     gboolean eject_drives;
-    gboolean use_sudo;
     gboolean showed_fstab_dialog;
     GtkWidget *button;
     GtkWidget *image;
@@ -106,7 +105,6 @@ typedef struct
     GtkWidget *show_include_NFSs;
     GtkWidget *show_exclude_FSs;
     GtkWidget *show_eject_drives;
-    GtkWidget *show_use_sudo;
     GtkWidget *show_exclude_devicenames;
     GtkWidget *string_excluded_filesystems;
 }


More information about the Xfce4-commits mailing list