Index: ChangeLog =================================================================== --- ChangeLog (revisão 133) +++ ChangeLog (cópia de trabalho) @@ -1,3 +1,15 @@ +2005-01-18 Gustavo Noronha Silva + + * gksu/gksu.c: + - added --prompt, -P, which will show a window asking + if the user wishes the screen to be grabed, also added + to /etc/gksu.conf parsing + - made -P, -g and -S accept optional arguments so you + can turn then on or off regardless of the default set + on /etc/gksu.conf + - added force-grab option to /etc/gksu.conf, to force + grabing whatever the user chooses + 2005-01-17 Gustavo Noronha Silva * gksu/gksu.c: Index: gksu/gksu.c =================================================================== --- gksu/gksu.c (revisão 133) +++ gksu/gksu.c (cópia de trabalho) @@ -22,9 +22,11 @@ /* GLOBALS */ gboolean print_pass = FALSE; +gboolean force_grab = FALSE; gboolean grab = TRUE; gboolean sudo_mode = FALSE; gboolean message_changed = FALSE; +gboolean prompt = FALSE; struct option long_opts[] = { /* @@ -39,10 +41,11 @@ {"message", required_argument, NULL, 'm'}, {"title", required_argument, NULL, 't'}, {"icon", required_argument, NULL, 'i'}, - {"disable-grab", no_argument, NULL, 'g'}, + {"disable-grab", optional_argument, NULL, 'g'}, {"ssh-fwd", no_argument, NULL, 's'}, {"debug", no_argument, NULL, 'd'}, - {"sudo-mode",no_argument, NULL, 'S'}, + {"sudo-mode", optional_argument, NULL, 'S'}, + {"prompt", optional_argument, NULL, 'P'}, {0, 0, 0, 0} }; @@ -223,11 +226,21 @@ if (!strcasecmp ("yes", value)) grab = FALSE; } + else if (!strcmp ("force-grab", key)) + { + if (!strcasecmp ("yes", value)) + force_grab = TRUE; + } else if (!strcmp ("sudo-mode", key)) { if (!strcasecmp ("yes", value)) sudo_mode = FALSE; } + else if (!strcmp ("prompt", key)) + { + if (!strcasecmp ("yes", value)) + prompt = FALSE; + } g_strfreev (tmp); } @@ -296,7 +309,7 @@ context = gksu_context_new (); read_config_file_options (context); - while ((c = getopt_long(newargc, newargv, "?hu:lpm:kt:i:gdsS", long_opts, NULL)) + while ((c = getopt_long(newargc, newargv, "?hu:lpm:kt:i:gdsS::P::", long_opts, NULL)) != EOF) { switch (c) @@ -341,6 +354,20 @@ break; case 'g': grab = FALSE; + + if (optarg != NULL) + { + if (!strcasecmp (optarg, "yes")); /* ignore, already set */ + else if (!strcasecmp (optarg, "no")) + grab = FALSE; + else + { + fprintf (stderr, _("Option not accepted for --disable-grab: %s\n"), + optarg); + return 1; + } + } + break; case 'd': gksu_context_set_debug (context, TRUE); @@ -350,10 +377,63 @@ break; case 'S': sudo_mode = TRUE; + + if (optarg != NULL) + { + if (!strcasecmp (optarg, "yes")); /* ignore, already set */ + else if (!strcasecmp (optarg, "no")) + sudo_mode = FALSE; + else + { + fprintf (stderr, _("Option not accepted for --sudo-mode: %s\n"), + optarg); + return 1; + } + } + break; + case 'P': + prompt = TRUE; + + if (optarg != NULL) + { + if (!strcasecmp (optarg, "yes")); /* ignore, already set */ + else if (!strcasecmp (optarg, "no")) + prompt = FALSE; + else + { + fprintf (stderr, _("Option not accepted for --prompt: %s\n"), + optarg); + return 1; + } + } + + break; } } + if (force_grab) + grab = TRUE; + + if (prompt && (!grab)) + { + GtkWidget *d; + + d = gtk_message_dialog_new_with_markup (NULL, 0, GTK_MESSAGE_QUESTION, + GTK_BUTTONS_YES_NO, + _("Would you like your screen to be \"grabed\"\n" + "while you enter the password?" + "\n\n" + "This means all applications will be paused to avoid\n" + "a malicious application to eavesdrop your password\n" + "while you type it.")); + + if (gtk_dialog_run (GTK_DIALOG(d)) == GTK_RESPONSE_YES) + grab = TRUE; + + gtk_widget_destroy (d); + } + if (print_pass) { if (!gksuui_dialog_get_message (GKSUUI_DIALOG(dialog))) @@ -368,6 +448,7 @@ if (grab) grab_keyboard_and_mouse (dialog); + retvalue = gtk_dialog_run (GTK_DIALOG(dialog)); gtk_widget_hide (dialog); if (grab)