summaryrefslogtreecommitdiff
path: root/extra/polkit/fix-empty-wheel.patch
blob: d6f99c43db7f1f781b6113f6f91d022e90f4ac91 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
From fa04223240d46641b0773dbf9f7d72f529046bea Mon Sep 17 00:00:00 2001
From: David Zeuthen <zeuthen@gmail.com>
Date: Tue, 18 Sep 2012 18:47:06 +0000
Subject: Fall back to authenticating as uid 0 if the list of admin identities is empty

For example, this can happen if the wheel group has no members. This
was reported in Red Hat bug 834494, see

 https://bugzilla.redhat.com/show_bug.cgi?id=834494

Signed-off-by: David Zeuthen <zeuthen@gmail.com>
---
diff --git a/src/polkitbackend/polkitbackendinteractiveauthority.c b/src/polkitbackend/polkitbackendinteractiveauthority.c
index 1d4a555..3bd2f0b 100644
--- a/src/polkitbackend/polkitbackendinteractiveauthority.c
+++ b/src/polkitbackend/polkitbackendinteractiveauthority.c
@@ -1293,15 +1293,11 @@ polkit_backend_interactive_authority_get_admin_identities (PolkitBackendInteract
                                                            PolkitDetails                     *details)
 {
   PolkitBackendInteractiveAuthorityClass *klass;
-  GList *ret;
+  GList *ret = NULL;
 
   klass = POLKIT_BACKEND_INTERACTIVE_AUTHORITY_GET_CLASS (authority);
 
-  if (klass->get_admin_identities == NULL)
-    {
-      ret = g_list_prepend (NULL, polkit_unix_user_new (0));
-    }
-  else
+  if (klass->get_admin_identities != NULL)
     {
       ret = klass->get_admin_identities (authority,
                                          caller,
@@ -2257,6 +2253,10 @@ authentication_agent_initiate_challenge (AuthenticationAgent         *agent,
         }
     }
 
+  /* Fall back to uid 0 if no users are available (rhbz #834494) */
+  if (user_identities == NULL)
+    user_identities = g_list_prepend (NULL, polkit_unix_user_new (0));
+
   session = authentication_session_new (agent,
                                         cookie,
                                         subject,
--
cgit v0.9.0.2-2-gbebe