PolicyKit: Branch 'master'
David Zeuthen
david at kemper.freedesktop.org
Tue Jul 24 22:43:18 EEST 2007
doc/TODO | 4 ++
doc/spec/polkit-spec-configuration.xml | 16 +++++------
polkit-grant/polkit-grant-helper.c | 43 ++++++++++++++++---------------
polkit-grant/polkit-grant.h | 2 -
polkit/polkit-result.c | 6 ++--
polkit/polkit-result.h | 45 +++++++++++++++++++--------------
tools/polkit-grant.c | 26 +++++++++----------
7 files changed, 76 insertions(+), 66 deletions(-)
New commits:
diff-tree 4b20f49298850060274e4bba842181b7c033d1e7 (from 074949c084e4bdb92a6a0d23329512d2c07112d3)
Author: David Zeuthen <davidz at redhat.com>
Date: Tue Jul 24 15:41:58 2007 -0400
switch from VIA_ROOT to VIA_ADMIN
In the future PolicyKit will be able to be built such that VIA_ADMIN
either means 1) ask for root password; or 2) ask for a user in the
'wheel' group to authenticate. Right now it's only the former.
diff --git a/doc/TODO b/doc/TODO
index db4e272..1505e38 100644
--- a/doc/TODO
+++ b/doc/TODO
@@ -25,7 +25,7 @@
- Make sure API coverage is 100%
- Have support for systems that don't use the root account; e.g.
- instead of authenticating as root, authenticate any user in
+ instead of authenticating as root, authenticate a user in
e.g. the 'wheel' group. Probably means we need a combobox in the UI
bits (e.g. PolicyKit-gnome + friends) for selecting the user to
auth as.
@@ -74,5 +74,7 @@
The is a bit like Objects mentioned in the spec (and what we used
to have as PolKitResource) but a bit more blurry. It may just work.
+ - Be more forgiving about bad policy files and bad config files. Hard problem.
+
- Go to 1.0 soon
diff --git a/doc/spec/polkit-spec-configuration.xml b/doc/spec/polkit-spec-configuration.xml
index a96b340..b2fb7f3 100644
--- a/doc/spec/polkit-spec-configuration.xml
+++ b/doc/spec/polkit-spec-configuration.xml
@@ -30,7 +30,7 @@
<description>Let the example Tweak</description>
<defaults>
<allow_inactive>no</allow_inactive>
- <allow_active>auth_root</allow_active>
+ <allow_active>auth_admin</allow_active>
</defaults>
</policy>
@@ -38,7 +38,7 @@
<description>Twiddle</description>
<defaults>
<allow_inactive>no</allow_inactive>
- <allow_active>auth_root_keep_always</allow_active>
+ <allow_active>auth_admin_keep_always</allow_active>
</defaults>
</policy>
@@ -67,7 +67,7 @@
<description>Mount file systems from internal drives</description>
<defaults>
<allow_inactive>no</allow_inactive>
- <allow_active>auth_root_keep_always</allow_active>
+ <allow_active>auth_admin_keep_always</allow_active>
</defaults>
</policy>
@@ -75,7 +75,7 @@
<description>Unmount file systems mounted by other users</description>
<defaults>
<allow_inactive>no</allow_inactive>
- <allow_active>auth_root_keep_always</allow_active>
+ <allow_active>auth_admin_keep_always</allow_active>
</defaults>
</policy>
@@ -144,17 +144,17 @@
</listitem>
<listitem>
<para>
- <emphasis>auth_root</emphasis>
+ <emphasis>auth_admin</emphasis>
</para>
</listitem>
<listitem>
<para>
- <emphasis>auth_root_keep_session</emphasis>
+ <emphasis>auth_admin_keep_session</emphasis>
</para>
</listitem>
<listitem>
<para>
- <emphasis>auth_root_keep_always</emphasis>
+ <emphasis>auth_admin_keep_always</emphasis>
</para>
</listitem>
<listitem>
@@ -170,7 +170,7 @@
return <emphasis>yes</emphasis> for local active sessions and
the Action
<literal>dialup-connect-untrusted</literal> to perhaps
- return <emphasis>auth_root_keep_session</emphasis>. See
+ return <emphasis>auth_admin_keep_session</emphasis>. See
<xref linkend="beyond-defaults"/> for how individual machines
and sites can customize this.
</para>
diff --git a/polkit-grant/polkit-grant-helper.c b/polkit-grant/polkit-grant-helper.c
index f428dab..eeebd18 100644
--- a/polkit-grant/polkit-grant-helper.c
+++ b/polkit-grant/polkit-grant-helper.c
@@ -240,9 +240,9 @@ verify_with_polkit (const char *dbus_nam
*result = polkit_context_can_caller_do_action (pol_ctx, action, caller);
- if (*result != POLKIT_RESULT_ONLY_VIA_ROOT_AUTH &&
- *result != POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_SESSION &&
- *result != POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_ALWAYS &&
+ if (*result != POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH &&
+ *result != POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_SESSION &&
+ *result != POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_ALWAYS &&
*result != POLKIT_RESULT_ONLY_VIA_SELF_AUTH &&
*result != POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION &&
*result != POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS) {
@@ -284,19 +284,19 @@ get_and_validate_override_details (PolKi
*
*/
switch (*result) {
- case POLKIT_RESULT_ONLY_VIA_ROOT_AUTH:
- if (desired_result != POLKIT_RESULT_ONLY_VIA_ROOT_AUTH)
+ case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH:
+ if (desired_result != POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH)
goto error;
break;
- case POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_SESSION:
- if (desired_result != POLKIT_RESULT_ONLY_VIA_ROOT_AUTH &&
- desired_result != POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_SESSION)
+ case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_SESSION:
+ if (desired_result != POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH &&
+ desired_result != POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_SESSION)
goto error;
break;
- case POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_ALWAYS:
- if (desired_result != POLKIT_RESULT_ONLY_VIA_ROOT_AUTH &&
- desired_result != POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_SESSION &&
- desired_result != POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_ALWAYS)
+ case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_ALWAYS:
+ if (desired_result != POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH &&
+ desired_result != POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_SESSION &&
+ desired_result != POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_ALWAYS)
goto error;
break;
@@ -433,9 +433,10 @@ main (int argc, char *argv[])
fflush (stdout);
/* figure out what user to auth */
- if (result == POLKIT_RESULT_ONLY_VIA_ROOT_AUTH ||
- result == POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_SESSION ||
- result == POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_ALWAYS) {
+ if (result == POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH ||
+ result == POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_SESSION ||
+ result == POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_ALWAYS) {
+ /* TODO: with wheel support, figure out what user to auth */
user_to_auth = "root";
} else {
user_to_auth = invoking_user_name;
@@ -466,18 +467,18 @@ main (int argc, char *argv[])
action_name, session_objpath, caller_pid);
switch (result) {
- case POLKIT_RESULT_ONLY_VIA_ROOT_AUTH:
+ case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH:
case POLKIT_RESULT_ONLY_VIA_SELF_AUTH:
dbres = _polkit_grantdb_write_pid (action_name, caller_pid);
break;
- case POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_SESSION:
+ case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_SESSION:
case POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION:
dbres = _polkit_grantdb_write_keep_session (action_name, session_objpath);
break;
case POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS:
- case POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_ALWAYS:
+ case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_ALWAYS:
dbres = _polkit_grantdb_write_keep_always (action_name, invoking_user_id);
break;
@@ -518,20 +519,20 @@ main (int argc, char *argv[])
g_free (resource_str_to_hash);
switch (result) {
- case POLKIT_RESULT_ONLY_VIA_ROOT_AUTH:
+ case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH:
case POLKIT_RESULT_ONLY_VIA_SELF_AUTH:
grant_file = g_strdup_printf (PACKAGE_LOCALSTATE_DIR "/run/PolicyKit/dbus_%s_%d_%s_%u.grant",
dbus_name, invoking_user_id, action_name, resource_hash);
break;
- case POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_SESSION:
+ case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_SESSION:
case POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION:
grant_file = g_strdup_printf (PACKAGE_LOCALSTATE_DIR "/run/PolicyKit/session_%s_%d_%s_%u.grant",
session_name, invoking_user_id, action_name, resource_hash);
break;
case POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS:
- case POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_ALWAYS:
+ case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_ALWAYS:
grant_file = g_strdup_printf (PACKAGE_LOCALSTATE_DIR "/lib/PolicyKit/uid_%d_%s_%u.grant",
invoking_user_id, action_name, resource_hash);
break;
diff --git a/polkit-grant/polkit-grant.h b/polkit-grant/polkit-grant.h
index 63c6e79..5211b6f 100644
--- a/polkit-grant/polkit-grant.h
+++ b/polkit-grant/polkit-grant.h
@@ -180,7 +180,7 @@ typedef void (*PolKitGrantConversationTe
* </programlisting>
*
* Of course, these examples also applies to
- * #POLKIT_RESULT_ONLY_VIA_ROOT_AUTH and friends.
+ * #POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH and friends.
*
* Returns: the desired type of what privilege to obtain; note that it
* won't work asking for more privileges than what @grant_type
diff --git a/polkit/polkit-result.c b/polkit/polkit-result.c
index 9193c73..a5335dc 100644
--- a/polkit/polkit-result.c
+++ b/polkit/polkit-result.c
@@ -55,9 +55,9 @@ static const struct {
{POLKIT_RESULT_UNKNOWN_ACTION, "unknown"},
{POLKIT_RESULT_NOT_AUTHORIZED_TO_KNOW, "not_authorized"},
{POLKIT_RESULT_NO, "no"},
- {POLKIT_RESULT_ONLY_VIA_ROOT_AUTH, "auth_root"},
- {POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_SESSION, "auth_root_keep_session"},
- {POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_ALWAYS, "auth_root_keep_always"},
+ {POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH, "auth_admin"},
+ {POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_SESSION, "auth_admin_keep_session"},
+ {POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_ALWAYS, "auth_admin_keep_always"},
{POLKIT_RESULT_ONLY_VIA_SELF_AUTH, "auth_self"},
{POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION, "auth_self_keep_session"},
{POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS, "auth_self_keep_always"},
diff --git a/polkit/polkit-result.h b/polkit/polkit-result.h
index 475154e..60aefc2 100644
--- a/polkit/polkit-result.h
+++ b/polkit/polkit-result.h
@@ -37,25 +37,32 @@
* @POLKIT_RESULT_UNKNOWN_ACTION: The passed action is unknown.
* @POLKIT_RESULT_NOT_AUTHORIZED_TO_KNOW: The caller of polkit is not sufficiently privilege to know the answer.
* @POLKIT_RESULT_NO: Access denied.
- * @POLKIT_RESULT_ONLY_VIA_ROOT_AUTH: Access denied, but authentication of the caller as
- * root will grant access to the resource... but the access isn't permanent
- * @POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_SESSION: Access denied, but authentication of the caller as
- * root will grant access to the resource for the remainder of the session
- * @POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_ALWAYS: Access denied, but authentication of the caller as
- * root will grant access to the resource in the future.
- * @POLKIT_RESULT_ONLY_VIA_SELF_AUTH: Access denied, but authentication of the caller as
- * himself will grant access to the resource... but the access isn't permanent
- * @POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION: Access denied, but authentication of the caller as
- * himself will grant access to the resource for the remainder of the session
- * @POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS: Access denied, but authentication of the caller as
- * himself will grant access to the resource in the future.
+ * @POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH: Access denied, but
+ * authentication by the caller as administrator (e.g. root or a
+ * member in the wheel group depending on configuration) will grant
+ * access to the process the caller is originating from.
+ * @POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_SESSION: Access denied, but
+ * authentication by the caller as administrator (e.g. root or a
+ * member in the wheel group depending on configuration) will grant
+ * access for the remainder of the session
+ * @POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_ALWAYS: Access denied, but
+ * authentication by the caller as administrator (e.g. root or a
+ * member in the wheel group depending on configuration) will grant
+ * access in the future.
+ * @POLKIT_RESULT_ONLY_VIA_SELF_AUTH: Access denied, but
+ * authentication by the caller as himself will grant access to the
+ * process the caller is originating from.
+ * @POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION: Access denied, but
+ * authentication by the caller as himself will grant access to the
+ * resource for the remainder of the session
+ * @POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS: Access denied, but
+ * authentication by the caller as himself will grant access to the
+ * resource in the future.
* @POLKIT_RESULT_YES: Access granted.
* @POLKIT_RESULT_N_RESULTS: Number of result codes
*
- * Result codes from queries to PolicyKit. These are ordered and we
- * say that a result A is "more strict" than a result B, if A has a
- * lower numerical value. (e.g. #POLKIT_RESULT_NO is more strict
- * than #POLKIT_RESULT_YES).
+ * Result codes from queries to PolicyKit. This enumeration may grow
+ * in the future.
*/
typedef enum
{
@@ -63,9 +70,9 @@ typedef enum
POLKIT_RESULT_NOT_AUTHORIZED_TO_KNOW,
POLKIT_RESULT_NO,
- POLKIT_RESULT_ONLY_VIA_ROOT_AUTH,
- POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_SESSION,
- POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_ALWAYS,
+ POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH,
+ POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_SESSION,
+ POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_ALWAYS,
POLKIT_RESULT_ONLY_VIA_SELF_AUTH,
POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION,
diff --git a/tools/polkit-grant.c b/tools/polkit-grant.c
index 0bf2665..b83c7d3 100644
--- a/tools/polkit-grant.c
+++ b/tools/polkit-grant.c
@@ -68,10 +68,10 @@ static void
conversation_type (PolKitGrant *polkit_grant, PolKitResult auth_type, void *user_data)
{
switch (auth_type) {
- case POLKIT_RESULT_ONLY_VIA_ROOT_AUTH:
- case POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_SESSION:
- case POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_ALWAYS:
- printf ("Authentication as root is required.\n");
+ 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");
break;
case POLKIT_RESULT_ONLY_VIA_SELF_AUTH:
@@ -151,10 +151,10 @@ conversation_override_grant_type (PolKit
PolKitResult overridden_auth_type;
switch (auth_type) {
- case POLKIT_RESULT_ONLY_VIA_ROOT_AUTH:
+ case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH:
case POLKIT_RESULT_ONLY_VIA_SELF_AUTH:
break;
- case POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_SESSION:
+ case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_SESSION:
case POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION:
printf ("Keep this privilege for the session? [no/session]?\n");
getline (&lineptr, &linelen, stdin);
@@ -168,7 +168,7 @@ conversation_override_grant_type (PolKit
}
free (lineptr);
break;
- case POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_ALWAYS:
+ case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_ALWAYS:
case POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS:
printf ("Keep this privilege for the session or always? [no/session/always]?\n");
getline (&lineptr, &linelen, stdin);
@@ -190,14 +190,14 @@ conversation_override_grant_type (PolKit
}
switch (auth_type) {
- case POLKIT_RESULT_ONLY_VIA_ROOT_AUTH:
- case POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_SESSION:
- case POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_ALWAYS:
- overridden_auth_type = POLKIT_RESULT_ONLY_VIA_ROOT_AUTH;
+ 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:
+ overridden_auth_type = POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH;
if (keep_session)
- overridden_auth_type = POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_SESSION;
+ overridden_auth_type = POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_SESSION;
else if (keep_always)
- overridden_auth_type = POLKIT_RESULT_ONLY_VIA_ROOT_AUTH_KEEP_ALWAYS;
+ overridden_auth_type = POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_ALWAYS;
break;
case POLKIT_RESULT_ONLY_VIA_SELF_AUTH:
More information about the hal-commit
mailing list