# --- T2-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
# 
# T2 SDE: package/.../gnomesu/features.patch
# Copyright (C) 2004 - 2007 The T2 SDE Project
# 
# More information can be found in the files COPYING and README.
# 
# This patch file is dual-licensed. It is available under the license the
# patched project is licensed under, as long as it is an OpenSource license
# as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
# of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
# --- T2-COPYRIGHT-NOTE-END ---

This feature patch was primarily developed for the Archivista Scan Server Box,
however it should be useful for others as well.

First we do not want to let the joe user see cryptic commands to be executed
when asked for authentication (always done when a command was supplied now)

Second for some special cases (like setting passwords) we want to retrieve the
current password to injet into e.g. MySQL and co (-p).

  - Rene Rebe <rene@exactcode.de>

diff -u gnomesu-0.3.1/src/xsu.c gnomesu-0.3.1-fixed/src/xsu.c
--- gnomesu-0.3.1/src/xsu.c	2003-04-10 14:03:14.000000000 +0000
+++ gnomesu-0.3.1-fixed/src/xsu.c	2005-09-05 22:58:12.000000000 +0000
@@ -126,7 +126,10 @@
 		buffer = g_strdup_printf("%s%s;%s", SET_DISPL_ENV, displ_host, command);
 		g_free(displ_host);
 	} 
-	else 
+	else if (show_password) {
+		buffer = g_strdup_printf("PASSWD=\"%s\" %s", password, command);
+	}
+	else
 	{
 		buffer = g_strdup_printf("%s", command);
 	}
@@ -371,13 +377,16 @@
 		if(g_strdup(argv[1]))	// there was a first argument
 		{
 			/* As long as the first item is not a switch set the first item as the command */
-			if ((strcmp(argv[1], "-u")) && (strcmp(argv[1], "--username")) && (strcmp(argv[1], "-m")) && (strcmp (argv[1], "-c")) && (strcmp (argv[1], "--command")) && (strcmp(argv[1], "--message")) && (strcmp(argv[1], "-t")) && (strcmp(argv[1], "--title")))
+			if ((strcmp(argv[1], "-u")) && (strcmp(argv[1], "--username")) && (strcmp(argv[1], "-m")) && (strcmp (argv[1], "-c")) && (strcmp (argv[1], "--command")) && (strcmp(argv[1], "--message")) && (strcmp(argv[1], "-t")) && (strcmp(argv[1], "--title")) && (strcmp(argv[1], "-p")))
 			{
 				arg_command = g_strdup(argv[1]);
 				command_in=TRUE;
 			}		
 		}
 
+		if (!strcmp (argv[x], "-p"))
+			show_password=TRUE;
+
 		// -c switch for backwards compatibility with xsu	
 		if ((!strcmp (argv[x], "-c")) || (!strcmp (argv[x], "--command")))
 		{
@@ -542,7 +554,9 @@
 	if (command_in)
 	{
 		gtk_entry_set_text(GTK_ENTRY(gtk_command_textbox),arg_command);
-		//gtk_entry_set_editable(GTK_ENTRY(gtk_command_textbox), FALSE);
+		gtk_entry_set_editable(GTK_ENTRY(gtk_command_textbox), FALSE);
+		gtk_widget_hide (gtk_commandtxt_label);
+		gtk_widget_hide (gtk_command_textbox);
 		gtk_widget_grab_focus (gtk_password_textbox);
 	} else {
 		gtk_widget_grab_focus (gtk_command_textbox);
diff -u gnomesu-0.3.1/src/xsu.h gnomesu-0.3.1-fixed/src/xsu.h
--- gnomesu-0.3.1/src/xsu.h	2003-01-07 21:01:09.000000000 +0000
+++ gnomesu-0.3.1-fixed/src/xsu.h	2005-09-05 22:27:38.000000000 +0000
@@ -77,6 +77,7 @@
 GtkTooltips *tooltips;
 
 gchar *arg_message, *arg_title, *displ_host;
+gboolean show_password=FALSE;
 
 gboolean message_in=FALSE,
 		 title_in=FALSE,
