Index: ChangeLog =================================================================== --- ChangeLog (revisão 132) +++ ChangeLog (cópia de trabalho) @@ -1,5 +1,12 @@ 2005-01-17 Gustavo Noronha Silva + * gksu/gksu.c: + - added support for a /etc/gksu.conf file, which will make some + of the options available for default setting by the admin - + still needs some polishing, it is trying to address several + Debian bugs. See http://bugs.debian.org/271567 for the + discussion. + * man/gksu.1: - updated to document the change to return codes for gksu Index: gksu/gksu.c =================================================================== --- gksu/gksu.c (revisão 131) +++ gksu/gksu.c (cópia de trabalho) @@ -2,6 +2,8 @@ #include #include #include +#include +#include #include #include #include @@ -18,6 +20,12 @@ #include "util.h" +/* GLOBALS */ +gboolean print_pass = FALSE; +gboolean grab = TRUE; +gboolean sudo_mode = FALSE; +gboolean message_changed = FALSE; + struct option long_opts[] = { /* * { name has_arg *flag val } @@ -34,6 +42,7 @@ {"disable-grab", no_argument, NULL, 'g'}, {"ssh-fwd", no_argument, NULL, 's'}, {"debug", no_argument, NULL, 'd'}, + {"sudo-mode",no_argument, NULL, 'S'}, {0, 0, 0, 0} }; @@ -169,18 +178,68 @@ gdk_flush(); } +void +read_config_file_options (GksuContext *context) +{ + int fconf; + GIOChannel *channel; + gchar *buffer, **tmp, *key, *value; + + fconf = open ("/etc/gksu.conf", O_RDONLY); + if (fconf == -1) + return; + + channel = g_io_channel_unix_new (fconf); + while (TRUE) + { + g_io_channel_read_line (channel, &buffer, NULL, NULL, NULL); + if (buffer == NULL) + break; + + /* remove comments */ + tmp = g_strsplit (buffer, "#", 2); + g_free (buffer); + + buffer = g_strdup (tmp[0]); + g_strfreev (tmp); + + /* check if we still have a key/value pair */ + tmp = g_strsplit (buffer, "=", 2); + g_free (buffer); + if (tmp[1] == NULL || tmp[0] == NULL) + { + g_strfreev (tmp); + continue; + } + + key = tmp[0]; + value = tmp[1]; + + g_strstrip (key); + g_strstrip (value); + + if (!strcmp ("disable-grab", key)) + { + if (!strcasecmp ("yes", value)) + grab = FALSE; + } + else if (!strcmp ("sudo-mode", key)) + { + if (!strcasecmp ("yes", value)) + sudo_mode = FALSE; + } + + g_strfreev (tmp); + } + g_io_channel_shutdown (channel, TRUE, NULL); +} + int main (int argc, char **argv) { GtkWidget *dialog; GksuContext *context; - gboolean print_pass = FALSE; - gboolean grab = TRUE; - gboolean sudo_mode = FALSE; - - gboolean message_changed = FALSE; - gchar *password = NULL; GError *error = NULL; @@ -236,7 +295,8 @@ dialog = gksuui_dialog_new (); context = gksu_context_new (); - while ((c = getopt_long(newargc, newargv, "?hu:lpm:kt:i:gds", long_opts, NULL)) + read_config_file_options (context); + while ((c = getopt_long(newargc, newargv, "?hu:lpm:kt:i:gdsS", long_opts, NULL)) != EOF) { switch (c) @@ -288,6 +348,9 @@ case 's': gksu_context_set_ssh_fwd (context, TRUE); break; + case 'S': + sudo_mode = TRUE; + break; } }