PolicyKit: Branch 'master'
David Zeuthen
david at kemper.freedesktop.org
Mon Aug 20 17:03:12 PDT 2007
tools/polkit-grant.c | 53 ++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 40 insertions(+), 13 deletions(-)
New commits:
diff-tree 6efff0882a712424eeee0d7644b213127b3eded6 (from 7090ddbacaabf318d7d87c9b93ce5805fa765c06)
Author: David Zeuthen <davidz at redhat.com>
Date: Mon Aug 20 19:59:10 2007 -0400
make polkit-grant(1) work with <define_admin_user /> feature
diff --git a/tools/polkit-grant.c b/tools/polkit-grant.c
index 24a2ca7..43e7005 100644
--- a/tools/polkit-grant.c
+++ b/tools/polkit-grant.c
@@ -71,7 +71,7 @@ conversation_type (PolKitGrant *polkit_g
case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH:
case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_SESSION:
case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_ALWAYS:
- printf ("Authentication as admin is required.\n");
+ printf ("Authentication as an administrative user is required.\n");
break;
case POLKIT_RESULT_ONLY_VIA_SELF_AUTH:
@@ -87,6 +87,25 @@ conversation_type (PolKitGrant *polkit_g
}
static char *
+conversation_select_admin_user (PolKitGrant *polkit_grant, char **admin_users, void *user_data)
+{
+ int n;
+ char *user;
+ char *lineptr = NULL;
+ size_t linelen = 0;
+
+ printf ("The following users qualify as administrative users:\n");
+ for (n = 0; admin_users[n] != NULL; n++) {
+ printf ("%s\n", admin_users[n]);
+ }
+ printf ("Select user: ");
+ getline (&lineptr, &linelen, stdin);
+ user = strdup (lineptr);
+ free (lineptr);
+ return user;
+}
+
+static char *
conversation_pam_prompt_echo_off (PolKitGrant *polkit_grant, const char *request, void *user_data)
{
char *lineptr = NULL;
@@ -113,6 +132,7 @@ conversation_pam_prompt_echo_off (PolKit
result = strdup (lineptr);
free (lineptr);
+ printf ("\n");
return result;
}
@@ -126,6 +146,7 @@ conversation_pam_prompt_echo_on (PolKitG
getline (&lineptr, &linelen, stdin);
result = strdup (lineptr);
free (lineptr);
+ printf ("\n");
return result;
}
@@ -346,6 +367,8 @@ main (int argc, char *argv[])
goto error;
}
+ printf ("Attempting to gain the privilege for %s.\n", action_id);
+
ud.loop = g_main_loop_new (NULL, TRUE);
dbus_error_init (&error);
@@ -377,17 +400,18 @@ main (int argc, char *argv[])
polkit_grant = polkit_grant_new ();
polkit_grant_set_functions (polkit_grant,
- add_io_watch,
- add_child_watch,
- remove_watch,
- conversation_type,
- conversation_pam_prompt_echo_off,
- conversation_pam_prompt_echo_on,
- conversation_pam_error_msg,
- conversation_pam_text_info,
- conversation_override_grant_type,
- conversation_done,
- &ud);
+ add_io_watch,
+ add_child_watch,
+ remove_watch,
+ conversation_type,
+ conversation_select_admin_user,
+ conversation_pam_prompt_echo_off,
+ conversation_pam_prompt_echo_on,
+ conversation_pam_error_msg,
+ conversation_pam_text_info,
+ conversation_override_grant_type,
+ conversation_done,
+ &ud);
if (!polkit_grant_initiate_auth (polkit_grant,
action,
@@ -399,7 +423,10 @@ main (int argc, char *argv[])
g_main_loop_run (ud.loop);
polkit_grant_unref (polkit_grant);
- printf ("Privilege grant done.. result=%d\n", ud.gained_privilege);
+ if (ud.gained_privilege)
+ printf ("Successfully gained the privilege for %s.\n", action_id);
+ else
+ printf ("Failed to gain the privilege for %s.\n", action_id);
ret = ud.gained_privilege ? 0 : 1;
More information about the hal-commit
mailing list