man-pages/man3/sd_bus_creds_new_from_pid.3.html
2021-03-31 01:06:50 +01:00

346 lines
10 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of SD_BUS_CREDS_NEW_FROM_PID</TITLE>
</HEAD><BODY>
<H1>SD_BUS_CREDS_NEW_FROM_PID</H1>
Section: sd_bus_creds_new_from_pid (3)<BR>Updated: <BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
sd_bus_creds_new_from_pid, sd_bus_creds_get_mask, sd_bus_creds_get_augmented_mask, sd_bus_creds_ref, sd_bus_creds_unref, sd_bus_creds_unrefp - Retrieve credentials object for the specified PID
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<P>
<B>
</B><PRE>
#include &lt;<A HREF="file:///usr/include/systemd/sd-bus.h">systemd/sd-bus.h</A>&gt;
</PRE>
<DL COMPACT>
<DT id="1">
<B>int sd_bus_creds_new_from_pid(pid_t&nbsp;</B><I>pid</I><B>, uint64_t&nbsp;</B><I>creds_mask</I><B>, sd_bus_creds&nbsp;**</B><I>ret</I><B>);</B>
<DT id="2">
<B>uint64_t sd_bus_creds_get_mask(sd_bus_creds&nbsp;*</B><I>c</I><B>);</B>
<DT id="3">
<B>uint64_t sd_bus_creds_get_augmented_mask(sd_bus_creds&nbsp;*</B><I>c</I><B>);</B>
<DT id="4">
<B>sd_bus_creds *sd_bus_creds_ref(sd_bus_creds&nbsp;*</B><I>c</I><B>);</B>
<DT id="5">
<B>sd_bus_creds *sd_bus_creds_unref(sd_bus_creds&nbsp;*</B><I>c</I><B>);</B>
<DT id="6">
<B>void sd_bus_creds_unrefp(sd_bus_creds&nbsp;**</B><I>c</I><B>);</B>
</DL>
<P>
<B>SD_BUS_CREDS_PID</B>,
<B>SD_BUS_CREDS_PPID</B>,
<B>SD_BUS_CREDS_TID</B>,
<B>SD_BUS_CREDS_UID</B>,
<B>SD_BUS_CREDS_EUID</B>,
<B>SD_BUS_CREDS_SUID</B>,
<B>SD_BUS_CREDS_FSUID</B>,
<B>SD_BUS_CREDS_GID</B>,
<B>SD_BUS_CREDS_EGID</B>,
<B>SD_BUS_CREDS_SGID</B>,
<B>SD_BUS_CREDS_FSGID</B>,
<B>SD_BUS_CREDS_SUPPLEMENTARY_GIDS</B>,
<B>SD_BUS_CREDS_COMM</B>,
<B>SD_BUS_CREDS_TID_COMM</B>,
<B>SD_BUS_CREDS_EXE</B>,
<B>SD_BUS_CREDS_CMDLINE</B>,
<B>SD_BUS_CREDS_CGROUP</B>,
<B>SD_BUS_CREDS_UNIT</B>,
<B>SD_BUS_CREDS_SLICE</B>,
<B>SD_BUS_CREDS_USER_UNIT</B>,
<B>SD_BUS_CREDS_USER_SLICE</B>,
<B>SD_BUS_CREDS_SESSION</B>,
<B>SD_BUS_CREDS_OWNER_UID</B>,
<B>SD_BUS_CREDS_EFFECTIVE_CAPS</B>,
<B>SD_BUS_CREDS_PERMITTED_CAPS</B>,
<B>SD_BUS_CREDS_INHERITABLE_CAPS</B>,
<B>SD_BUS_CREDS_BOUNDING_CAPS</B>,
<B>SD_BUS_CREDS_SELINUX_CONTEXT</B>,
<B>SD_BUS_CREDS_AUDIT_SESSION_ID</B>,
<B>SD_BUS_CREDS_AUDIT_LOGIN_UID</B>,
<B>SD_BUS_CREDS_TTY</B>,
<B>SD_BUS_CREDS_UNIQUE_NAME</B>,
<B>SD_BUS_CREDS_WELL_KNOWN_NAMES</B>,
<B>SD_BUS_CREDS_DESCRIPTION</B>,
<B>SD_BUS_CREDS_AUGMENT</B>,
<B>_SD_BUS_CREDS_ALL</B>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
<P>
<B>sd_bus_creds_new_from_pid()</B>
<DD>creates a new credentials object and fills it with information about the process
<I>pid</I>. The pointer to this object will be stored in the
<I>ret</I>
pointer. Note that credential objects may also be created and retrieved via
<B><A HREF="/cgi-bin/man/man2html?3+sd_bus_get_name_creds">sd_bus_get_name_creds</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+sd_bus_get_owner_creds">sd_bus_get_owner_creds</A></B>(3)
and
<B><A HREF="/cgi-bin/man/man2html?3+sd_bus_message_get_creds">sd_bus_message_get_creds</A></B>(3).
<P>
The information that will be stored is determined by
<I>creds_mask</I>. It may contain a subset of ORed constants
<B>SD_BUS_CREDS_PID</B>,
<B>SD_BUS_CREDS_PPID</B>,
<B>SD_BUS_CREDS_TID</B>,
<B>SD_BUS_CREDS_UID</B>,
<B>SD_BUS_CREDS_EUID</B>,
<B>SD_BUS_CREDS_SUID</B>,
<B>SD_BUS_CREDS_FSUID</B>,
<B>SD_BUS_CREDS_GID</B>,
<B>SD_BUS_CREDS_EGID</B>,
<B>SD_BUS_CREDS_SGID</B>,
<B>SD_BUS_CREDS_FSGID</B>,
<B>SD_BUS_CREDS_SUPPLEMENTARY_GIDS</B>,
<B>SD_BUS_CREDS_COMM</B>,
<B>SD_BUS_CREDS_TID_COMM</B>,
<B>SD_BUS_CREDS_EXE</B>,
<B>SD_BUS_CREDS_CMDLINE</B>,
<B>SD_BUS_CREDS_CGROUP</B>,
<B>SD_BUS_CREDS_UNIT</B>,
<B>SD_BUS_CREDS_SLICE</B>,
<B>SD_BUS_CREDS_USER_UNIT</B>,
<B>SD_BUS_CREDS_USER_SLICE</B>,
<B>SD_BUS_CREDS_SESSION</B>,
<B>SD_BUS_CREDS_OWNER_UID</B>,
<B>SD_BUS_CREDS_EFFECTIVE_CAPS</B>,
<B>SD_BUS_CREDS_PERMITTED_CAPS</B>,
<B>SD_BUS_CREDS_INHERITABLE_CAPS</B>,
<B>SD_BUS_CREDS_BOUNDING_CAPS</B>,
<B>SD_BUS_CREDS_SELINUX_CONTEXT</B>,
<B>SD_BUS_CREDS_AUDIT_SESSION_ID</B>,
<B>SD_BUS_CREDS_AUDIT_LOGIN_UID</B>,
<B>SD_BUS_CREDS_TTY</B>,
<B>SD_BUS_CREDS_UNIQUE_NAME</B>,
<B>SD_BUS_CREDS_WELL_KNOWN_NAMES</B>, and
<B>SD_BUS_CREDS_DESCRIPTION</B>. Use the special value
<B>_SD_BUS_CREDS_ALL</B>
to request all supported fields. The
<B>SD_BUS_CREDS_AUGMENT</B>
constant may not be ORed into the mask for invocations of
<B>sd_bus_creds_new_from_pid()</B>.
<P>
Fields can be retrieved from the credentials object using
<B><A HREF="/cgi-bin/man/man2html?3+sd_bus_creds_get_pid">sd_bus_creds_get_pid</A></B>(3)
and other functions which correspond directly to the constants listed above.
<P>
A mask of fields which were actually successfully retrieved can be retrieved with
<B>sd_bus_creds_get_mask()</B>. If the credentials object was created with
<B>sd_bus_creds_new_from_pid()</B>, this will be a subset of fields requested in
<I>creds_mask</I>.
<P>
Similar to
<B>sd_bus_creds_get_mask()</B>, the function
<B>sd_bus_creds_get_augmented_mask()</B>
returns a bitmask of field constants. The mask indicates which credential fields have been retrieved in a non-atomic fashion. For credential objects created via
<B>sd_bus_creds_new_from_pid()</B>, this mask will be identical to the mask returned by
<B>sd_bus_creds_get_mask()</B>. However, for credential objects retrieved via
<B>sd_bus_get_name_creds()</B>, this mask will be set for the credential fields that could not be determined atomically at peer connection time, and which were later added by reading augmenting credential data from
/proc. Similarly, for credential objects retrieved via
<B>sd_bus_get_owner_creds()</B>, the mask is set for the fields that could not be determined atomically at bus creation time, but have been augmented. Similarly, for credential objects retrieved via
<B>sd_bus_message_get_creds()</B>, the mask is set for the fields that could not be determined atomically at message sending time, but have been augmented. The mask returned by
<B>sd_bus_creds_get_augmented_mask()</B>
is always a subset of (or identical to) the mask returned by
<B>sd_bus_creds_get_mask()</B>
for the same object. The latter call hence returns all credential fields available in the credential object, the former then marks the subset of those that have been augmented. Note that augmented fields are unsuitable for authorization decisions, as they may be retrieved at different times, thus being subject to races. Hence, augmented fields should be used exclusively for informational purposes.
<P>
<B>sd_bus_creds_ref()</B>
creates a new reference to the credentials object
<I>c</I>. This object will not be destroyed until
<B>sd_bus_creds_unref()</B>
has been called as many times plus once more. Once the reference count has dropped to zero,
<I>c</I>
cannot be used anymore, so further calls to
<B>sd_bus_creds_ref(c)</B>
or
<B>sd_bus_creds_unref(c)</B>
are illegal.
<P>
<B>sd_bus_creds_unref()</B>
destroys a reference to
<I>c</I>.
<P>
<B>sd_bus_creds_unrefp()</B>
is similar to
<B>sd_bus_creds_unref()</B>
but takes a pointer to a pointer to an
<B>sd_bus_creds</B>
object. This call is useful in conjunction with GCC's and LLVM's
m[blue]<B>Clean-up Variable Attribute</B>m[]<FONT SIZE="-2">[1]</FONT>. Note that this function is defined as inline function.
<P>
<B>sd_bus_creds_ref()</B>,
<B>sd_bus_creds_unref()</B>
and
<B>sd_bus_creds_unrefp()</B>
execute no operation if the passed in bus credentials object is
<B>NULL</B>.
<A NAME="lbAE">&nbsp;</A>
<H2>RETURN VALUE</H2>
<P>
On success,
<B>sd_bus_creds_new_from_pid()</B>
returns 0 or a positive integer. On failure, it returns a negative errno-style error code.
<P>
<B>sd_bus_creds_get_mask()</B>
returns the mask of successfully acquired fields.
<P>
<B>sd_bus_creds_get_augmented_mask()</B>
returns the mask of fields that have been augmented from data in
/proc, and are thus not suitable for authorization decisions.
<P>
<B>sd_bus_creds_ref()</B>
always returns the argument.
<P>
<B>sd_bus_creds_unref()</B>
always returns
<B>NULL</B>.
<A NAME="lbAF">&nbsp;</A>
<H2>REFERENCE OWNERSHIP</H2>
<P>
Function
<B>sd_bus_creds_new_from_pid()</B>
creates a new object and the caller owns the sole reference. When not needed anymore, this reference should be destroyed with
<B><A HREF="/cgi-bin/man/man2html?3+sd_bus_creds_unref">sd_bus_creds_unref</A></B>(3).
<A NAME="lbAG">&nbsp;</A>
<H3>Errors</H3>
<P>
Returned errors may indicate the following problems:
<P>
<B>-ESRCH</B>
<DL COMPACT><DT id="7"><DD>
Specified
<I>pid</I>
could not be found.
</DL>
<P>
<B>-EINVAL</B>
<DL COMPACT><DT id="8"><DD>
Specified parameter is invalid (<B>NULL</B>
in case of output parameters).
</DL>
<P>
<B>-ENOMEM</B>
<DL COMPACT><DT id="9"><DD>
Memory allocation failed.
</DL>
<P>
<B>-EOPNOTSUPP</B>
<DL COMPACT><DT id="10"><DD>
One of the requested fields is unknown to the local system.
</DL>
<A NAME="lbAH">&nbsp;</A>
<H2>NOTES</H2>
<P>
These APIs are implemented as a shared library, which can be compiled and linked to with the
<B>libsystemd</B>&nbsp;<B><A HREF="/cgi-bin/man/man2html?1+pkg-config">pkg-config</A></B>(1)
file.
<A NAME="lbAI">&nbsp;</A>
<H2>SEE ALSO</H2>
<P>
<B><A HREF="/cgi-bin/man/man2html?1+systemd">systemd</A></B>(1),
<B><A HREF="/cgi-bin/man/man2html?3+sd-bus">sd-bus</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+sd_bus_creds_get_pid">sd_bus_creds_get_pid</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+sd_bus_get_name_creds">sd_bus_get_name_creds</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+sd_bus_get_owner_creds">sd_bus_get_owner_creds</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+sd_bus_message_get_creds">sd_bus_message_get_creds</A></B>(3)
<A NAME="lbAJ">&nbsp;</A>
<H2>NOTES</H2>
<DL COMPACT>
<DT id="11"> 1.<DD>
Clean-up Variable Attribute
<DL COMPACT><DT id="12"><DD>
<A HREF="https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html">https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html</A>
</DL>
<P>
</DL>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="13"><A HREF="#lbAB">NAME</A><DD>
<DT id="14"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="15"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="16"><A HREF="#lbAE">RETURN VALUE</A><DD>
<DT id="17"><A HREF="#lbAF">REFERENCE OWNERSHIP</A><DD>
<DL>
<DT id="18"><A HREF="#lbAG">Errors</A><DD>
</DL>
<DT id="19"><A HREF="#lbAH">NOTES</A><DD>
<DT id="20"><A HREF="#lbAI">SEE ALSO</A><DD>
<DT id="21"><A HREF="#lbAJ">NOTES</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:54 GMT, March 31, 2021
</BODY>
</HTML>