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 [--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       Note that pkexec does no validation of the ARGUMENTS passed to PROGRAM.
54       In the normal case (where administrator authentication is required
55       every time pkexec is used), this is not a problem since if the user is
56       an administrator he might as well just run pkexec bash to get root.
57
58       However, if an action is used for which the user can retain
59       authorization (or if the user is implicitly authorized) this could be a
60       security hole. Therefore, as a rule of thumb, programs for which the
61       default required authorization is changed, should never implicitly
62       trust user input (e.g. like any other well-written suid program).
63

ACTION AND AUTHORIZATIONS

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

WRAPPER USAGE

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

VARIABLES

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

AUTHOR

132       Written by David Zeuthen <davidz@redhat.com> with a lot of help from
133       many others.
134

BUGS

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

SEE ALSO

142       polkit(8), polkitd(8), pkaction(1), pkcheck(1), pkttyagent(1)
143

NOTES

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