blob: 959656b158a1c1680d2972879baacdebf80ef16f (
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
https://gitlab.freedesktop.org/polkit/polkit/-/commit/7d4b52c4d71c46049d87a0775de695ea914f3f1b
https://gitlab.freedesktop.org/polkit/polkit/-/merge_requests/113
https://bugs.gentoo.org/827884
From: Matt Turner <mattst88@gmail.com>
Date: Tue, 3 May 2022 12:54:37 +0000
Subject: [PATCH] pkexec: Allow --version and --help even if not setuid root
--- a/src/programs/pkexec.c
+++ b/src/programs/pkexec.c
@@ -514,27 +514,6 @@ main (int argc, char *argv[])
/* Disable remote file access from GIO. */
setenv ("GIO_USE_VFS", "local", 1);
- /* check for correct invocation */
- if (geteuid () != 0)
- {
- g_printerr ("pkexec must be setuid root\n");
- goto out;
- }
-
- original_user_name = g_strdup (g_get_user_name ());
- if (original_user_name == NULL)
- {
- g_printerr ("Error getting user name.\n");
- goto out;
- }
-
- if ((original_cwd = g_get_current_dir ()) == NULL)
- {
- g_printerr ("Error getting cwd: %s\n",
- g_strerror (errno));
- goto out;
- }
-
/* First process options and find the command-line to invoke. Avoid using fancy library routines
* that depend on environtment variables since we haven't cleared the environment just yet.
*/
@@ -595,6 +574,27 @@ main (int argc, char *argv[])
goto out;
}
+ /* check for correct invocation */
+ if (geteuid () != 0)
+ {
+ g_printerr ("pkexec must be setuid root\n");
+ goto out;
+ }
+
+ original_user_name = g_strdup (g_get_user_name ());
+ if (original_user_name == NULL)
+ {
+ g_printerr ("Error getting user name.\n");
+ goto out;
+ }
+
+ if ((original_cwd = g_get_current_dir ()) == NULL)
+ {
+ g_printerr ("Error getting cwd: %s\n",
+ g_strerror (errno));
+ goto out;
+ }
+
if (opt_user == NULL)
opt_user = g_strdup ("root");
GitLab
|