summaryrefslogtreecommitdiff
path: root/docs/man/pkexec.xml
blob: 236f9f1bcf0cb5bdd3f336695c0527ea6f4b6af9 (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
<?xml version="1.0"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
               "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
<!ENTITY version SYSTEM "../version.xml">
]>
<refentry id="pkexec.1" xmlns:xi="http://www.w3.org/2003/XInclude">
  <refentryinfo>
    <title>pkexec</title>
    <date>May 2009</date>
    <productname>polkit</productname>
  </refentryinfo>

  <refmeta>
    <refentrytitle>pkexec</refentrytitle>
    <manvolnum>1</manvolnum>
    <refmiscinfo class="version"></refmiscinfo>
  </refmeta>

  <refnamediv>
    <refname>pkexec</refname>
    <refpurpose>Execute a command as another user</refpurpose>
  </refnamediv>

  <refsynopsisdiv>
    <cmdsynopsis>
      <command>pkexec</command>
      <arg><option>--version</option></arg>
      <arg><option>--disable-internal-agent</option></arg>
      <arg><option>--help</option></arg>
    </cmdsynopsis>

    <cmdsynopsis>
      <command>pkexec</command>
      <group>
        <arg choice="plain">
          <option>--user</option>
          <replaceable>username</replaceable>
        </arg>
      </group>
      <arg choice="plain"><replaceable>PROGRAM</replaceable></arg>
      <group rep="repeat">
        <arg choice="plain"><replaceable>ARGUMENTS</replaceable></arg>
      </group>
    </cmdsynopsis>

  </refsynopsisdiv>

  <refsect1 id="pkexec-description"><title>DESCRIPTION</title>
    <para>
      <command>pkexec</command> allows an authorized user to
      execute <replaceable>PROGRAM</replaceable> as another
      user. If <replaceable>username</replaceable> is not specified,
      then the program will be executed as the administrative super
      user, <emphasis>root</emphasis>.
    </para>
  </refsect1>

  <refsect1 id="pkexec-return-value"><title>RETURN VALUE</title>
    <para>
      Upon successful completion, the return value is the return value
      of <replaceable>PROGRAM</replaceable>. If the calling process is
      not authorized or an authorization could not be obtained through
      authentication or an error occured, <command>pkexec</command>
      exits with a return value of 127. If the authorization could not
      be obtained because the user dismissed the authentication
      dialog, <command>pkexec</command> exits with a return value of
      126.
    </para>
  </refsect1>

  <refsect1 id="pkexec-auth-agent"><title>AUTHENTICATION AGENT</title>
    <para>
      <command>pkexec</command>, like any other polkit application,
      will use the authentication agent registered for the calling
      process or session. However, if no authentication agent is
      available, then <command>pkexec</command> will register its own
      textual authentication agent. This behavior can be turned off by
      passing the <option>--disable-internal-agent</option> option.
    </para>
  </refsect1>

  <refsect1 id="pkexec-security-notes"><title>SECURITY NOTES</title>
    <para>
      Executing a program as another user is a privileged
      operation. By default the action to check for (see
      <xref linkend="pkexec-action"/>) requires administrator
      authentication. In addition, the authentication dialog presented
      to the user will display the full path to the program to be
      executed so the user is aware of what will happen.
    </para>
    <para>
      The environment that <replaceable>PROGRAM</replaceable> will run
      it, will be set to a minimal known and safe environment in order
      to avoid injecting code
      through <literal>LD_LIBRARY_PATH</literal> or similar
      mechanisms. In addition the <literal>PKEXEC_UID</literal>
      environment variable is set to the user id of the process
      invoking <command>pkexec</command>. As a
      result, <command>pkexec</command> will not by default allow you to run
      X11 applications as another user since
      the <literal>$DISPLAY</literal> and <literal>$XAUTHORITY</literal>
      environment variables are not set. These two variables will be retained
      if the <emphasis>org.freedesktop.policykit.exec.allow_gui</emphasis> annotation
      on an action is set to a nonempty value; this is discouraged, though, and
      should only be used for legacy programs.
    </para>

    <para>
      Note that <command>pkexec</command> does no validation of
      the <replaceable>ARGUMENTS</replaceable> passed
      to <replaceable>PROGRAM</replaceable>. In the normal case (where
      administrator authentication is required every
      time <command>pkexec</command> is used), this is not a problem
      since if the user is an administrator he might as well just
      run <command>pkexec bash</command> to get root.
    </para>

    <para>
      However, if an action is used for which the user can retain
      authorization (or if the user is implicitly authorized) this
      could be a security hole. Therefore, as a rule of thumb,
      programs for which the default required authorization is
      changed, should <emphasis role='strong'>never</emphasis> implicitly trust user input (e.g. like any
      other well-written <emphasis>suid</emphasis> program).
    </para>
  </refsect1>

  <refsect1 id="pkexec-action"><title>ACTION AND AUTHORIZATIONS</title>
    <para>
      By default, the
      <emphasis>org.freedesktop.policykit.exec</emphasis> action is
      used. To use another action, use the
      <emphasis>org.freedesktop.policykit.exec.path</emphasis>
      annotation on an action with the value set to the full path of
      the program. In addition to specifying the program, the
      authentication message, description, icon and defaults can be
      specified.
    </para>
    <para>
      Note that authentication messages may reference variables (see
      <xref linkend="pkexec-variables"/>), for example
      <literal>$(user)</literal> will be expanded to the value of the
      <literal>user</literal> variable.
    </para>
  </refsect1>

  <refsect1 id="pkexec-variables"><title>VARIABLES</title>
    <para>
      The following variables are set by
      <command>pkexec</command>. They can be used in authorization
      rules and messages shown in authentication dialogs:
    </para>

    <variablelist>
      <varlistentry>
        <term><emphasis>program</emphasis></term>
        <listitem>
          <para>
            Fully qualified path to the program to be executed.
            Example: <quote>/bin/cat</quote>
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><emphasis>command_line</emphasis></term>
        <listitem>
          <para>
            The requested command-line (do not use this for any
            security checks, it is not secure).
            Example: <quote>cat /srv/xyz/foobar</quote>
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><emphasis>user</emphasis></term>
        <listitem>
          <para>
            The user name of the user to execute the program as.
            Example: <quote>davidz</quote>
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><emphasis>user.gecos</emphasis></term>
        <listitem>
          <para>
            The full name of the user to execute the program as.
            Example: <quote>David Zeuthen</quote>
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><emphasis>user.display</emphasis></term>
        <listitem>
          <para>
            A representation of the user to execute the program as
            that is suitable for display in an authentication dialog.
            Is typically set to a combination of the user name and the
            full name.
          </para>
        </listitem>
      </varlistentry>
    </variablelist>

  </refsect1>

  <refsect1 id="pkexec-author"><title>AUTHOR</title>
    <para>
      Written by David Zeuthen <email>davidz@redhat.com</email> with
      a lot of help from many others.
    </para>
  </refsect1>

  <refsect1 id="pkexec-bugs">
    <title>BUGS</title>
    <para>
      Please send bug reports to either the distribution or the
      polkit-devel mailing list,
      see the link <ulink url="http://lists.freedesktop.org/mailman/listinfo/polkit-devel"/>
      on how to subscribe.
    </para>
  </refsect1>

  <refsect1 id="pkexec-see-also">
    <title>SEE ALSO</title>
    <para>
      <link linkend="polkit.8"><citerefentry><refentrytitle>polkit</refentrytitle><manvolnum>8</manvolnum></citerefentry></link>,
      <link linkend="polkitd.8"><citerefentry><refentrytitle>polkitd</refentrytitle><manvolnum>8</manvolnum></citerefentry></link>,
      <link linkend="pkaction.1"><citerefentry><refentrytitle>pkaction</refentrytitle><manvolnum>1</manvolnum></citerefentry></link>,
      <link linkend="pkcheck.1"><citerefentry><refentrytitle>pkcheck</refentrytitle><manvolnum>1</manvolnum></citerefentry></link>,
      <link linkend="pkttyagent.1"><citerefentry><refentrytitle>pkttyagent</refentrytitle><manvolnum>1</manvolnum></citerefentry></link>
    </para>
  </refsect1>
</refentry>