1PKEXEC(1)                           pkexec                           PKEXEC(1)
2
3
4

NAME

6       pkexec - Execute a command as another user
7

SYNOPSIS

9       pkexec [--version] [--disable-internal-agent] [--help]
10
11       pkexec [--keep-cwd] [--user username] PROGRAM [ARGUMENTS...]
12

DESCRIPTION

14       pkexec allows an authorized user to execute PROGRAM as another user. If
15       PROGRAM is not specified, the default shell will be run. If username is
16       not specified, then the program will be executed as the administrative
17       super user, root.
18

RETURN VALUE

20       Upon successful completion, the return value is the return value of
21       PROGRAM. If the calling process is not authorized or an authorization
22       could not be obtained through authentication or an error occured,
23       pkexec exits with a return value of 127. If the authorization could not
24       be obtained because the user dismissed the authentication dialog,
25       pkexec exits with a return value of 126.
26

AUTHENTICATION AGENT

28       pkexec, like any other polkit application, will use the authentication
29       agent registered for the calling process or session. However, if no
30       authentication agent is available, then pkexec will register its own
31       textual authentication agent. This behavior can be turned off by
32       passing the --disable-internal-agent option.
33

SECURITY NOTES

35       Executing a program as another user is a privileged operation. By
36       default the action to check for (see the section called “ACTION AND
37       AUTHORIZATIONS”) requires administrator authentication. In addition,
38       the authentication dialog presented to the user will display the full
39       path to the program to be executed so the user is aware of what will
40       happen.
41
42       The environment that PROGRAM will run it, will be set to a minimal
43       known and safe environment in order to avoid injecting code through
44       LD_LIBRARY_PATH or similar mechanisms. In addition the PKEXEC_UID
45       environment variable is set to the user id of the process invoking
46       pkexec. As a result, pkexec will not by default allow you to run X11
47       applications as another user since the $DISPLAY and $XAUTHORITY
48       environment variables are not set. These two variables will be retained
49       if the org.freedesktop.policykit.exec.allow_gui annotation on an action
50       is set to a nonempty value; this is discouraged, though, and should
51       only be used for legacy programs.
52
53       pkexec will run PROGRAM in username's home directory, unless --keep-cwd
54       is used to override this behavior
55
56       Note that pkexec does no validation of the ARGUMENTS passed to PROGRAM.
57       In the normal case (where administrator authentication is required
58       every time pkexec is used), this is not a problem since if the user is
59       an administrator he might as well just run pkexec bash to get root.
60
61       However, if an action is used for which the user can retain
62       authorization (or if the user is implicitly authorized) this could be a
63       security hole. Therefore, as a rule of thumb, programs for which the
64       default required authorization is changed, should never implicitly
65       trust user input (e.g. like any other well-written suid program).
66

ACTION AND AUTHORIZATIONS

68       By default, the org.freedesktop.policykit.exec action is used. To use
69       another action, use the org.freedesktop.policykit.exec.path annotation
70       on an action with the value set to the full path of the program. In
71       addition to specifying the program, the authentication message,
72       description, icon and defaults can be specified. If the
73       org.freedesktop.policykit.exec.argv1 annotation is present, the action
74       will only be picked if the first argument to the program matches the
75       value of the annotation.
76
77       Note that authentication messages may reference variables (see the
78       section called “VARIABLES”), for example $(user) will be expanded to
79       the value of the user variable.
80

WRAPPER USAGE

82       To avoid modifying existing software to prefix their command-line
83       invocations with pkexec, it's possible to use pkexec in a she-bang
84       wrapper[1] like this:
85
86           #!/usr/bin/pkexec /usr/bin/python
87
88           import os
89           import sys
90
91           print "Hello, I'm running as uid %d"%(os.getuid())
92
93           for n in range(len(sys.argv)):
94               print "arg[%d]=`%s'"%(n, sys.argv[n])
95
96       If this script is installed into /usr/bin/my-pk-test, then the
97       following annotations
98
99             [...]
100             <annotate key="org.freedesktop.policykit.exec.path">/usr/bin/python</annotate>
101             <annotate key="org.freedesktop.policykit.exec.argv1">/usr/bin/my-pk-test</annotate>
102             [...]
103
104       can be used to select the appropriate polkit action. Be careful to get
105       the latter annotation right, otherwise it will match any pkexec
106       invocation of /usr/bin/python scripts.
107

VARIABLES

109       The following variables are set by pkexec. They can be used in
110       authorization rules and messages shown in authentication dialogs:
111
112       program
113           Fully qualified path to the program to be executed. Example:
114           “/bin/cat”
115
116       command_line
117           The requested command-line (do not use this for any security
118           checks, it is not secure). Example: “cat /srv/xyz/foobar”
119
120       user
121           The user name of the user to execute the program as. Example:
122           “davidz”
123
124       user.gecos
125           The full name of the user to execute the program as. Example:
126           “David Zeuthen”
127
128       user.display
129           A representation of the user to execute the program as that is
130           suitable for display in an authentication dialog. Is typically set
131           to a combination of the user name and the full name. Example:
132           “David Zeuthen (davidz)”
133

AUTHOR

135       Written by David Zeuthen <davidz@redhat.com> with a lot of help from
136       many others.
137

BUGS

139       Please send bug reports to either the distribution or the polkit-devel
140       mailing list, see the link
141       http://lists.freedesktop.org/mailman/listinfo/polkit-devel on how to
142       subscribe.
143

SEE ALSO

145       polkit(8), polkitd(8), pkaction(1), pkcheck(1), pkttyagent(1)
146

NOTES

148        1. she-bang wrapper
149           http://en.wikipedia.org/wiki/Shebang_(Unix)
150
151
152
153polkit                             May 2009                          PKEXEC(1)
Impressum