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

NAME

6       pkexec - Execute a command as another user
7

SYNOPSIS

9       pkexec [--version] [--help]
10
11       pkexec [--user username] PROGRAM [ARGUMENTS...]
12

DESCRIPTION

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

RETURN VALUE

19       Upon successful completion, the return value is the return value of
20       PROGRAM. If the calling process is not authorized or an authorization
21       could not be obtained through authentication or an error occured,
22       pkexec exits with a return value of 127.
23

SECURITY NOTES

25       Executing a program as another user is a privileged operation. By
26       default the required authorization (See the section called “REQUIRED
27       AUTHORIZATIONS”) requires administrator authentication. In addition,
28       the authentication dialog presented to the user will display the full
29       path to the program to be executed so the user is aware of what will
30       happen:
31
32           [IMAGE][1]
33
34               +----------------------------------------------------------+
35               |                     Authenticate                     [X] |
36               +----------------------------------------------------------+
37               |                                                          |
38               |  [Icon]  Authentication is needed to run `/bin/bash´     |
39               |          as the super user                               |
40               |                                                          |
41               |          An application is attempting to perform an      |
42               |          action that requires privileges. Authentication |
43               |          as the super user is required to perform this   |
44               |          action.                                         |
45               |                                                          |
46               |          Password for root: [_________________________]  |
47               |                                                          |
48               | [V] Details:                                             |
49               |  Command: /bin/bash                                      |
50               |  Run As:  Super User (root)                              |
51               |  Action:  org.freedesktop.policykit.exec                 |
52               |  Vendor:  The PolicyKit Project                          |
53               |                                                          |
54               |                                  [Cancel] [Authenticate] |
55               +----------------------------------------------------------+
56
57       The environment that PROGRAM will run it, will be set to a minimal
58       known and safe environment in order to avoid injecting code through
59       LD_LIBRARY_PATH or similar mechanisms. In addition the PKEXEC_UID
60       environment variable is set to the user id of the process invoking
61       pkexec. As a result, pkexec will not allow you to run e.g. X11
62       applications as another user since the $DISPLAY environment variable is
63       not set.
64

REQUIRED AUTHORIZATIONS

66       By default, the org.freedesktop.policykit.exec authorization is
67       required unless an action definition file is present for the program in
68       question. To require another authorization, it can be specified using
69       the org.freedesktop.policykit.exec.path annotation on an action (See
70       the section called “EXAMPLE” for details).
71

EXAMPLE

73       To specify what kind of authorization is needed to execute the program
74       /usr/bin/pk-example-frobnicate as another user, simply write an action
75       definition file like this
76
77           <?xml version="1.0" encoding="UTF-8"?>
78           <!DOCTYPE policyconfig PUBLIC
79            "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
80            "http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
81           <policyconfig>
82
83             <vendor>Examples for the PolicyKit Project</vendor>
84             <vendor_url>http://hal.freedesktop.org/docs/PolicyKit/</vendor_url>
85
86             <action id="org.freedesktop.policykit.example.pkexec.run-frobnicate">
87               <description>Run the PolicyKit example program Frobnicate</description>
88               <description xml:lang="da">Kør PolicyKit eksemplet Frobnicate</description>
89               <message>Authentication is required to run the PolicyKit example program Frobnicate</message>
90               <message xml:lang="da">Autorisering er påkrævet for at afvikle PolicyKit eksemplet Frobnicate</message>
91               <icon_name>audio-x-generic</icon_name>
92               <defaults>
93                 <allow_any>no</allow_any>
94                 <allow_inactive>no</allow_inactive>
95                 <allow_active>auth_self_keep</allow_active>
96               </defaults>
97               <annotate key="org.freedesktop.policykit.exec.path">/usr/bin/pk-example-frobnicate</annotate>
98             </action>
99
100           </policyconfig>
101
102       and drop it in the /usr/share/polkit-1/actions directory under a
103       suitable name (e.g. matching the namespace of the action). Note that in
104       addition to specifying the program, the authentication message,
105       description, icon and defaults can be specified. For example, for the
106       action defined above, the following authentication dialog will be
107       shown:
108
109           [IMAGE][2]
110
111               +----------------------------------------------------------+
112               |                     Authenticate                     [X] |
113               +----------------------------------------------------------+
114               |                                                          |
115               |  [Icon]  Authentication is required to run the PolicyKit |
116               |          example program Frobnicate                      |
117               |                                                          |
118               |          An application is attempting to perform an      |
119               |          action that requires privileges. Authentication |
120               |          is required to perform this action.             |
121               |                                                          |
122               |          Password: [__________________________________]  |
123               |                                                          |
124               | [V] Details:                                             |
125               |  Command: /usr/bin/pk-example-frobnicate                 |
126               |  Run As:  Super User (root)                              |
127               |  Action:  org.fd.pk.example.pkexec.run-frobnicate        |
128               |  Vendor:  Examples for the PolicyKit Project             |
129               |                                                          |
130               |                                  [Cancel] [Authenticate] |
131               +----------------------------------------------------------+
132
133       If the user is using the da_DK locale, the dialog looks like this:
134
135           [IMAGE][3]
136
137               +----------------------------------------------------------+
138               |                     Autorisering                     [X] |
139               +----------------------------------------------------------+
140               |                                                          |
141               |  [Icon]  Autorisering er påkrævet for at afvikle         |
142               |          PolicyKit eksemplet Frobnicate                  |
143               |                                                          |
144               |          Et program forsøger at udføre en handling der   |
145               |          kræver privilegier. Autorisering er påkrævet.   |
146               |                                                          |
147               |          Kodeord: [___________________________________]  |
148               |                                                          |
149               | [V] Detaljer:                                            |
150               |  Bruger:   Super User (root)                             |
151               |  Program:  /usr/bin/pk-example-frobnicate                |
152               |  Handling: org.fd.pk.example.pkexec.run-frobnicate       |
153               |  Vendor:   Examples for the PolicyKit Project            |
154               |                                                          |
155               |                                [Annullér] [Autorisering] |
156               +----------------------------------------------------------+
157
158       Note that pkexec does no validation of the ARGUMENTS passed to PROGRAM.
159       In the normal case (where administrator authentication is required
160       every time pkexec is used), this is not a problem since if the user is
161       an administrator he might as well just run pkexec bash to get root.
162
163       However, if an action is used for which the user can retain
164       authorization (or if the user is implicitly authorized), such as with
165       pk-example-frobnicate above, this could be a security hole. Therefore,
166       as a rule of thumb, programs for which the default required
167       authorization is changed, should never implicitly trust user input
168       (e.g. like any other well-written suid program).
169

AUTHOR

171       Written by David Zeuthen davidz@redhat.com with a lot of help from many
172       others.
173

BUGS

175       Please send bug reports to either the distribution or the polkit-devel
176       mailing list, see the link
177       http://lists.freedesktop.org/mailman/listinfo/polkit-devel on how to
178       subscribe.
179

SEE ALSO

181       polkit(8), pkaction(1), pkcheck(1)
182

NOTES

184        1. /usr/share/gtk-doc/html/polkit-1/pkexec-bash.png
185
186        2. /usr/share/gtk-doc/html/polkit-1/pkexec-frobnicate.png
187
188        3. /usr/share/gtk-doc/html/polkit-1/pkexec-frobnicate-da.png
189
190
191
192polkit                             May 2009                          PKEXEC(1)
Impressum