]> git.proxmox.com Git - systemd.git/blob - man/sd_bus_creds_get_comm.html
Imported Upstream version 214
[systemd.git] / man / sd_bus_creds_get_comm.html
1 <html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>sd_bus_creds_get_pid</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><style>
2 a.headerlink {
3 color: #c60f0f;
4 font-size: 0.8em;
5 padding: 0 4px 0 4px;
6 text-decoration: none;
7 visibility: hidden;
8 }
9
10 a.headerlink:hover {
11 background-color: #c60f0f;
12 color: white;
13 }
14
15 h1:hover > a.headerlink, h2:hover > a.headerlink, h3:hover > a.headerlink, dt:hover > a.headerlink {
16 visibility: visible;
17 }
18 </style><a href="index.html">Index </a>·
19 <a href="systemd.directives.html">Directives </a>·
20 <a href="../python-systemd/index.html">Python </a>·
21 <a href="../libudev/index.html">libudev </a>·
22 <a href="../libudev/index.html">gudev </a><span style="float:right">systemd 214</span><hr><div class="refentry"><a name="sd_bus_creds_get_pid"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>sd_bus_creds_get_pid, sd_bus_creds_get_pid_starttime, sd_bus_creds_get_tid, sd_bus_creds_get_uid, sd_bus_creds_get_gid, sd_bus_creds_get_comm, sd_bus_creds_get_tid_comm, sd_bus_creds_get_exe, sd_bus_creds_get_cmdline, sd_bus_creds_get_cgroup, sd_bus_creds_get_unit, sd_bus_creds_get_user_unit, sd_bus_creds_get_slice, sd_bus_creds_get_session, sd_bus_creds_get_owner_uid, sd_bus_creds_has_effective_cap, sd_bus_creds_has_permitted_cap, sd_bus_creds_has_inheritable_cap, sd_bus_creds_has_bounding_cap, sd_bus_creds_get_selinux_context, sd_bus_creds_get_audit_session_id, sd_bus_creds_get_audit_login_uid, sd_bus_creds_get_unique_name, sd_bus_creds_get_well_known_names — Retrieve fields from a credentials object</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="funcsynopsis"><pre class="funcsynopsisinfo">#include &lt;systemd/sd-bus.h&gt;</pre><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_bus_creds_get_pid</b>(</code></td><td>sd_bus_creds *<var class="pdparam">c</var>, </td></tr><tr><td> </td><td>pid_t *<var class="pdparam">pid</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_bus_creds_get_pid_starttime</b>(</code></td><td>sd_bus_creds *<var class="pdparam">c</var>, </td></tr><tr><td> </td><td>uint64_t *<var class="pdparam">usec</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_bus_creds_get_tid</b>(</code></td><td>sd_bus_creds *<var class="pdparam">c</var>, </td></tr><tr><td> </td><td>pid_t *<var class="pdparam">tid</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_bus_creds_get_pid</b>(</code></td><td>sd_bus_creds *<var class="pdparam">c</var>, </td></tr><tr><td> </td><td>uid_t *<var class="pdparam">uid</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_bus_creds_get_gid</b>(</code></td><td>sd_bus_creds *<var class="pdparam">c</var>, </td></tr><tr><td> </td><td>gid_t *<var class="pdparam">gid</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_bus_creds_get_comm</b>(</code></td><td>sd_bus_creds *<var class="pdparam">c</var>, </td></tr><tr><td> </td><td>const char **<var class="pdparam">comm</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_bus_creds_get_tid_comm</b>(</code></td><td>sd_bus_creds *<var class="pdparam">c</var>, </td></tr><tr><td> </td><td>const char **<var class="pdparam">comm</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_bus_creds_get_exe</b>(</code></td><td>sd_bus_creds *<var class="pdparam">c</var>, </td></tr><tr><td> </td><td>const char **<var class="pdparam">exe</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_bus_creds_get_cmdline</b>(</code></td><td>sd_bus_creds *<var class="pdparam">c</var>, </td></tr><tr><td> </td><td>char ***<var class="pdparam">cmdline</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_bus_creds_get_cgroup</b>(</code></td><td>sd_bus_creds *<var class="pdparam">c</var>, </td></tr><tr><td> </td><td>const char **<var class="pdparam">cgroup</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_bus_creds_get_unit</b>(</code></td><td>sd_bus_creds *<var class="pdparam">c</var>, </td></tr><tr><td> </td><td>const char **<var class="pdparam">unit</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_bus_creds_get_user_unit</b>(</code></td><td>sd_bus_creds *<var class="pdparam">c</var>, </td></tr><tr><td> </td><td>const char **<var class="pdparam">unit</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_bus_creds_get_slice</b>(</code></td><td>sd_bus_creds *<var class="pdparam">c</var>, </td></tr><tr><td> </td><td>const char **<var class="pdparam">slice</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_bus_creds_get_session</b>(</code></td><td>sd_bus_creds *<var class="pdparam">c</var>, </td></tr><tr><td> </td><td>const char **<var class="pdparam">slice</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_bus_creds_get_owner_uid</b>(</code></td><td>sd_bus_creds *<var class="pdparam">c</var>, </td></tr><tr><td> </td><td>uid_t *<var class="pdparam">uid</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_bus_creds_has_effective_cap</b>(</code></td><td>sd_bus_creds *<var class="pdparam">c</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">capability</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_bus_creds_has_permitted_cap</b>(</code></td><td>sd_bus_creds *<var class="pdparam">c</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">capability</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_bus_creds_has_inheritable_cap</b>(</code></td><td>sd_bus_creds *<var class="pdparam">c</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">capability</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_bus_creds_has_bounding_cap</b>(</code></td><td>sd_bus_creds *<var class="pdparam">c</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">capability</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_bus_creds_get_selinux_context</b>(</code></td><td>sd_bus_creds *<var class="pdparam">c</var>, </td></tr><tr><td> </td><td>const char **<var class="pdparam">context</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_bus_creds_get_audit_session_id</b>(</code></td><td>sd_bus_creds *<var class="pdparam">c</var>, </td></tr><tr><td> </td><td>uint32_t *<var class="pdparam">sessionid</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_bus_creds_get_audit_login_uid</b>(</code></td><td>sd_bus_creds *<var class="pdparam">c</var>, </td></tr><tr><td> </td><td>uid_t *<var class="pdparam">loginuid</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_bus_creds_get_unique_name</b>(</code></td><td>sd_bus_creds *<var class="pdparam">c</var>, </td></tr><tr><td> </td><td>const char **<var class="pdparam">name</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_bus_creds_get_well_known_names</b>(</code></td><td>sd_bus_creds *<var class="pdparam">c</var>, </td></tr><tr><td> </td><td>char ***<var class="pdparam">name</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1"><a name="idm214179373600"></a><h2 id="Description">Description<a class="headerlink" title="Permalink to this headline" href="#Description"></a></h2><p>These functions return information from an
23 <em class="parameter"><code>sd_bus_creds</code></em> object. It may be created with
24 <a href="sd_bus_creds_new_from_pid.html"><span class="citerefentry"><span class="refentrytitle">sd_bus_creds_new_from_pid</span>(3)</span></a>,
25 in which case it will describe the specified process, or it may be
26 created by
27 <a href="sd_bus_get_peer_creds.html"><span class="citerefentry"><span class="refentrytitle">sd_bus_get_peer_creds</span>(3)</span></a>,
28 in which case it will describe the process at the other endpoint
29 of a connection.
30 </p><p><code class="function">sd_bus_creds_get_pid</code> will retrieve the
31 PID (process identifier).</p><p><code class="function">sd_bus_creds_get_pid_starttime</code> will
32 retrieve the time since the start of the epoch in microseconds
33 since the process was started.</p><p><code class="function">sd_bus_creds_get_tid</code> will retrieve the
34 TID (thread identifier).</p><p><code class="function">sd_bus_creds_get_uid</code> will retrieve the
35 numeric UID (user identifier).</p><p><code class="function">sd_bus_creds_get_gid</code> will retrieve the
36 numeric GID (group identifier).</p><p><code class="function">sd_bus_creds_get_comm</code> will retrieve the
37 comm field (truncated name of the executable, as stored in
38 <code class="filename">/proc/<em class="replaceable"><code>pid</code></em>/comm</code>).
39 </p><p><code class="function">sd_bus_creds_get_tid_comm</code> will retrieve
40 the comm field of the thread (as stored in
41 <code class="filename">/proc/<em class="replaceable"><code>pid</code></em>/task/<em class="replaceable"><code>tid</code></em>/comm</code>).
42 </p><p><code class="function">sd_bus_creds_get_exe</code> will retrieve the
43 path to the program (as stored in the
44 <code class="filename">/proc/<em class="replaceable"><code>pid</code></em>/exe</code>
45 link, but with "<code class="literal"> (deleted)</code>" suffix removed).
46 </p><p><code class="function">sd_bus_creds_get_cmdline</code> will retrieve
47 an array of command-line arguments (as stored in
48 <code class="filename">/proc/<em class="replaceable"><code>pid</code></em>/cmdline</code>).
49 </p><p><code class="function">sd_bus_creds_get_cgroup</code> will retrieve
50 the cgroup path. See <a class="ulink" href="https://www.kernel.org/doc/Documentation/cgroups/cgroups.txt" target="_top">cgroups.txt</a>.
51 </p><p><code class="function">sd_bus_creds_get_unit</code> will retrieve the
52 systemd unit name (in the system instance of systemd) that the
53 process is part of. See
54 <a href="systemd.unit.html"><span class="citerefentry"><span class="refentrytitle">systemd.unit</span>(5)</span></a>.
55 </p><p><code class="function">sd_bus_creds_get_user_unit</code> will
56 retrieve the systemd unit name (in the user instance of systemd)
57 that the process is part of. See
58 <a href="systemd.unit.html"><span class="citerefentry"><span class="refentrytitle">systemd.unit</span>(5)</span></a>.
59 </p><p><code class="function">sd_bus_creds_get_slice</code> will retrieve
60 the systemd slice (a unit in the system instance of systemd) that
61 the process is part of. See
62 <a href="systemd.slice.html"><span class="citerefentry"><span class="refentrytitle">systemd.slice</span>(5)</span></a>.
63 </p><p><code class="function">sd_bus_creds_get_session</code> will retrieve
64 the logind session that the process is part of. See
65 <a href="systemd-logind.service.html"><span class="citerefentry"><span class="refentrytitle">systemd-logind.service</span>(8)</span></a>.
66 </p><p><code class="function">sd_bus_creds_get_owner_uid</code> will retrieve
67 the numeric UID (user identifier) of the user who owns the slice
68 that the process is part of. See
69 <a href="systemd.slice.html"><span class="citerefentry"><span class="refentrytitle">systemd.slice</span>(5)</span></a>
70 .
71 </p><p><code class="function">sd_bus_creds_has_effective_cap</code> will
72 check whether the capability specified by
73 <em class="parameter"><code>capability</code></em> was set in the effective
74 capabilities mask. A positive return value means that is was
75 set, zero means that it was not set, and a negative return
76 value signifies an error. See
77 <a href="capabilities.html"><span class="citerefentry"><span class="refentrytitle">capabilities</span>(7)</span></a>
78 and <code class="varname">Capabilities=</code> and
79 <code class="varname">CapabilityBoundingSet=</code> settings in
80 <a href="systemd.exec.html"><span class="citerefentry"><span class="refentrytitle">systemd.exec</span>(5)</span></a>.
81 </p><p><code class="function">sd_bus_creds_has_permitted_cap</code> is
82 similar to <code class="function">sd_bus_creds_has_effective_cap</code>,
83 but will check the permitted capabilities mask.</p><p><code class="function">sd_bus_creds_has_inheritable_cap</code> is
84 similar to <code class="function">sd_bus_creds_has_effective_cap</code>,
85 but will check the inheritable capabilities mask.</p><p><code class="function">sd_bus_creds_has_bounding_cap</code> is
86 similar to <code class="function">sd_bus_creds_has_effective_cap</code>,
87 but will check the bounding capabilities mask.</p><p><code class="function">sd_bus_creds_get_selinux_context</code> will
88 retrieve the SELinux security context (label) of the process.</p><p><code class="function">sd_bus_creds_get_audit_session_id</code> will
89 retrieve the audit session identifier of the process.</p><p><code class="function">sd_bus_creds_get_audit_login_uid</code> will
90 retrieve the audit user login identifier (the identifier of the
91 user who is "responsible" for the session).</p><p><code class="function">sd_bus_creds_get_unique_name</code> will
92 retrieve the D-Bus unique name. See <a class="ulink" href="http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names-bus" target="_top">The
93 D-Bus specification</a>.</p><p><code class="function">sd_bus_creds_get_well_known_names</code> will
94 retrieve the set of D-Bus well-known names. See <a class="ulink" href="http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names-bus" target="_top">The
95 D-Bus specification</a>.</p><p>All functions that take a <em class="parameter"><code>const
96 char**</code></em> parameter will store the answer there as an
97 address of a NUL-terminated string. It will be valid as long as
98 <em class="parameter"><code>c</code></em> remains valid, and should not be freed or
99 modified by the caller.</p><p>All functions that take a <em class="parameter"><code>char***</code></em>
100 parameter will store the answer there as an address of a an array
101 of strings. Each invidividual string is NUL-terminated, and the
102 array is NULL-terminated as a whole. It will be valid as long as
103 <em class="parameter"><code>c</code></em> remains valid, and should not be freed or
104 modified by the caller.</p></div><div class="refsect1"><a name="idm214179328320"></a><h2 id="Return Value">Return Value<a class="headerlink" title="Permalink to this headline" href="#Return%20Value"></a></h2><p>On success, these calls return 0 or a positive integer. On
105 failure, these calls return a negative errno-style error code.
106 </p></div><div class="refsect1"><a name="idm214179327024"></a><h2 id="Errors">Errors<a class="headerlink" title="Permalink to this headline" href="#Errors"></a></h2><p>Returned errors may indicate the following problems:</p><div class="variablelist"><dl class="variablelist"><dt id="-ENODATA"><span class="term"><code class="varname">-ENODATA</code></span><a class="headerlink" title="Permalink to this term" href="#-ENODATA"></a></dt><dd><p>Given field is not available in
107 <em class="parameter"><code>c</code></em>.</p></dd><dt id="-ENOENT"><span class="term"><code class="varname">-ENOENT</code></span><a class="headerlink" title="Permalink to this term" href="#-ENOENT"></a></dt><dd><p>Given field is not specified for the sender.
108 This will be returned by <code class="function">sd_bus_get_unit</code>,
109 <code class="function">sd_bus_get_user_unit</code>,
110 <code class="function">sd_bus_get_slice</code>,
111 <code class="function">sd_bus_get_session</code>, and
112 <code class="function">sd_bus_get_owner_uid</code> if the sender is not
113 part of a systemd system unit, systemd user unit, systemd
114 slice, logind session, or a systemd user session.</p></dd><dt id="-ENXIO"><span class="term"><code class="varname">-ENXIO</code></span><a class="headerlink" title="Permalink to this term" href="#-ENXIO"></a></dt><dd><p>An error occured in parsing cgroup paths.
115 <code class="filename">libsystemd</code> might be out of sync with
116 the running systemd version.</p></dd><dt id="-EINVAL"><span class="term"><code class="varname">-EINVAL</code></span><a class="headerlink" title="Permalink to this term" href="#-EINVAL"></a></dt><dd><p>Specified pointer parameter is <code class="constant">NULL</code>.
117 </p></dd><dt id="-ENOMEM"><span class="term"><code class="varname">-ENOMEM</code></span><a class="headerlink" title="Permalink to this term" href="#-ENOMEM"></a></dt><dd><p>Memory allocation failed.</p></dd></dl></div></div><div class="refsect1"><a name="idm214179313104"></a><h2 id="Notes">Notes<a class="headerlink" title="Permalink to this headline" href="#Notes"></a></h2><p><code class="function">sd_bus_open_user()</code> and other functions
118 described here are available as a shared library, which can be
119 compiled and linked to with the
120 <code class="constant">libsystemd</code> <a href="pkg-config.html"><span class="citerefentry"><span class="refentrytitle">pkg-config</span>(1)</span></a>
121 file.</p></div><div class="refsect1"><a name="idm214179310160"></a><h2 id="See Also">See Also<a class="headerlink" title="Permalink to this headline" href="#See%20Also"></a></h2><p>
122 <a href="systemd.html"><span class="citerefentry"><span class="refentrytitle">systemd</span>(1)</span></a>,
123 <a href="sd-bus.html"><span class="citerefentry"><span class="refentrytitle">sd-bus</span>(3)</span></a>,
124 <a href="credentials.html"><span class="citerefentry"><span class="refentrytitle">credentials</span>(7)</span></a>,
125 <a href="fork.html"><span class="citerefentry"><span class="refentrytitle">fork</span>(2)</span></a>,
126 <a href="execve.html"><span class="citerefentry"><span class="refentrytitle">execve</span>(2)</span></a>,
127 <a href="free.html"><span class="citerefentry"><span class="refentrytitle">free</span>(3)</span></a>,
128 <a href="proc.html"><span class="citerefentry"><span class="refentrytitle">proc</span>(5)</span></a>,
129 <a href="systemd.journald-fields.html"><span class="citerefentry"><span class="refentrytitle">systemd.journald-fields</span>(7)</span></a>
130 </p></div></div></body></html>