[gnome-commander/gcmd-1-4] Added support for user terminal as root, finally fixing bgo#737088



commit 52ae40239f4f4e0a9158e49bf662ce2976f6f8f7
Author: Uwe Scholz <uwescholz src gnome org>
Date:   Sat Oct 11 08:22:12 2014 +0200

    Added support for user terminal as root, finally fixing bgo#737088

 src/gnome-cmd-user-actions.cc |   28 +++++++++++++++-------------
 1 files changed, 15 insertions(+), 13 deletions(-)
---
diff --git a/src/gnome-cmd-user-actions.cc b/src/gnome-cmd-user-actions.cc
index 069ad8a..d86854b 100644
--- a/src/gnome-cmd-user-actions.cc
+++ b/src/gnome-cmd-user-actions.cc
@@ -1229,24 +1229,25 @@ void command_open_terminal (GtkMenuItem *menuitem, gpointer not_used)
     g_free (dpath);
 }
 
+/** 
+ * Combines the command stored in gnome_cmd_data.options.termopen with a
+ * command for a GUI for root login screen. The command is executed in
+ * the active directory afterwards.
+ */
 void command_open_terminal_as_root (GtkMenuItem *menuitem, gpointer not_used)
 {
+    
     int argc = 1;
-    char **argv = g_new0 (char *, argc+1);
-
-    argv[0] = gnome_util_user_shell ();
+    char **argv = g_new0 (char *, argc+1);  //initialize argv
+    gchar *command;
 
-    gnome_prepend_terminal_to_vector (&argc, &argv);
+    command = g_strdup (gnome_cmd_data.options.termopen);
+    // Parse the termopen string to get the number of arguments in argc
+    g_shell_parse_argv (command, &argc, &argv, NULL);
+    g_free (argv);
 
-    // Insert quotes into the string of argv to get, e.g.
-    // /usr/bin/gksu 'roxterm -e /bin/bash' instead of
-    // /usr/bin/gksu roxterm -e /bin/bash
-    // (the second case doesn't work in some cases)
-    gchar *cmd = g_strjoinv (" ", argv);
-    g_strfreev (argv);
-    argc = 1;
     argv = g_new0 (char *, argc+1);
-    argv[0] = cmd;
+    argv[0] = command;
 
     if (gnome_cmd_prepend_su_to_vector (argc, argv))
     {
@@ -1261,7 +1262,8 @@ void command_open_terminal_as_root (GtkMenuItem *menuitem, gpointer not_used)
     else
         gnome_cmd_show_message (NULL, _("xdg-su, gksu, gnomesu, kdesu or beesu is not found."));
 
-    g_strfreev (argv);
+    g_free (argv);
+    g_free (command);
 }
 
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]