<arg choice="plain">
<replaceable>pid,pid-start-time</replaceable>
</arg>
+ <arg choice="plain">
+ <replaceable>pid,pid-start-time,uid</replaceable>
+ </arg>
</group>
</arg>
<arg choice="plain">
<title>DESCRIPTION</title>
<para>
<command>pkcheck</command> is used to check whether a process, specified by
- either <option>--process</option> or <option>--system-bus-name</option>,
+ either <option>--process</option> (see below) or <option>--system-bus-name</option>,
is authorized for <replaceable>action</replaceable>. The <option>--detail</option>
option can be used zero or more times to pass details about <replaceable>action</replaceable>.
If <option>--allow-user-interaction</option> is passed, <command>pkcheck</command> blocks
<refsect1 id="pkcheck-notes">
<title>NOTES</title>
<para>
- Since process identifiers can be recycled, the caller should always use
- <replaceable>pid,pid-start-time</replaceable> to specify the process
- to check for authorization when using the <option>--process</option> option.
- The value of <replaceable>pid-start-time</replaceable>
- can be determined by consulting e.g. the
+ Do not use either the bare <replaceable>pid</replaceable> or
+ <replaceable>pid,start-time</replaceable> syntax forms for
+ <option>--process</option>. There are race conditions in both.
+ New code should always use
+ <replaceable>pid,pid-start-time,uid</replaceable>. The value of
+ <replaceable>start-time</replaceable> can be determined by
+ consulting e.g. the
<citerefentry><refentrytitle>proc</refentrytitle><manvolnum>5</manvolnum></citerefentry>
- file system depending on the operating system. If only <replaceable>pid</replaceable>
- is passed to the <option>--process</option> option, then <command>pkcheck</command>
- will look up the start time itself but note that this may be racy.
+ file system depending on the operating system. If fewer than 3
+ arguments are passed, <command>pkcheck</command> will attempt to
+ look up them up internally, but note that this may be racy.
+ </para>
+ <para>
+ If your program is a daemon with e.g. a custom Unix domain
+ socket, you should determine the <replaceable>uid</replaceable>
+ parameter via operating system mechanisms such as
+ <literal>PEERCRED</literal>.
</para>
</refsect1>
" -d, --details=KEY VALUE Add (KEY, VALUE) to information about the action\n"
" --enable-internal-agent Use an internal authentication agent if necessary\n"
" --list-temp List temporary authorizations for current session\n"
-" -p, --process=PID[,START_TIME] Check authorization of specified process\n"
+" -p, --process=PID[,START_TIME,UID] Check authorization of specified process\n"
" --revoke-temp Revoke all temporary authorizations for current session\n"
" -s, --system-bus-name=BUS_NAME Check authorization of owner of BUS_NAME\n"
" --version Show version\n"
else if (g_strcmp0 (argv[n], "--process") == 0 || g_strcmp0 (argv[n], "-p") == 0)
{
gint pid;
+ guint uid;
guint64 pid_start_time;
n++;
goto out;
}
- if (sscanf (argv[n], "%i,%" G_GUINT64_FORMAT, &pid, &pid_start_time) == 2)
+ if (sscanf (argv[n], "%i,%" G_GUINT64_FORMAT ",%u", &pid, &pid_start_time, &uid) == 3)
+ {
+ subject = polkit_unix_process_new_for_owner (pid, pid_start_time, uid);
+ }
+ else if (sscanf (argv[n], "%i,%" G_GUINT64_FORMAT, &pid, &pid_start_time) == 2)
{
subject = polkit_unix_process_new_full (pid, pid_start_time);
}