]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/sd_bus_creds_get_pid.xml
sysusers: add support for a --image= switch
[thirdparty/systemd.git] / man / sd_bus_creds_get_pid.xml
CommitLineData
514094f9 1<?xml version='1.0'?>
3a54a157
ZJS
2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
0307f791 4<!-- SPDX-License-Identifier: LGPL-2.1+ -->
cd6d5e1c 5
7d6b2723 6<refentry id="sd_bus_creds_get_pid" xmlns:xi="http://www.w3.org/2001/XInclude">
cd6d5e1c
ZJS
7
8 <refentryinfo>
9 <title>sd_bus_creds_get_pid</title>
10 <productname>systemd</productname>
cd6d5e1c
ZJS
11 </refentryinfo>
12
13 <refmeta>
14 <refentrytitle>sd_bus_creds_get_pid</refentrytitle>
15 <manvolnum>3</manvolnum>
16 </refmeta>
17
18 <refnamediv>
19 <refname>sd_bus_creds_get_pid</refname>
52d7c4dc 20 <refname>sd_bus_creds_get_ppid</refname>
cd6d5e1c
ZJS
21 <refname>sd_bus_creds_get_tid</refname>
22 <refname>sd_bus_creds_get_uid</refname>
52d7c4dc
LP
23 <refname>sd_bus_creds_get_euid</refname>
24 <refname>sd_bus_creds_get_suid</refname>
25 <refname>sd_bus_creds_get_fsuid</refname>
cd6d5e1c 26 <refname>sd_bus_creds_get_gid</refname>
52d7c4dc
LP
27 <refname>sd_bus_creds_get_egid</refname>
28 <refname>sd_bus_creds_get_sgid</refname>
29 <refname>sd_bus_creds_get_fsgid</refname>
30 <refname>sd_bus_creds_get_supplementary_gids</refname>
cd6d5e1c
ZJS
31 <refname>sd_bus_creds_get_comm</refname>
32 <refname>sd_bus_creds_get_tid_comm</refname>
33 <refname>sd_bus_creds_get_exe</refname>
34 <refname>sd_bus_creds_get_cmdline</refname>
35 <refname>sd_bus_creds_get_cgroup</refname>
36 <refname>sd_bus_creds_get_unit</refname>
cd6d5e1c 37 <refname>sd_bus_creds_get_slice</refname>
f6f7a984
LP
38 <refname>sd_bus_creds_get_user_unit</refname>
39 <refname>sd_bus_creds_get_user_slice</refname>
cd6d5e1c
ZJS
40 <refname>sd_bus_creds_get_session</refname>
41 <refname>sd_bus_creds_get_owner_uid</refname>
42 <refname>sd_bus_creds_has_effective_cap</refname>
43 <refname>sd_bus_creds_has_permitted_cap</refname>
44 <refname>sd_bus_creds_has_inheritable_cap</refname>
45 <refname>sd_bus_creds_has_bounding_cap</refname>
46 <refname>sd_bus_creds_get_selinux_context</refname>
47 <refname>sd_bus_creds_get_audit_session_id</refname>
48 <refname>sd_bus_creds_get_audit_login_uid</refname>
52d7c4dc 49 <refname>sd_bus_creds_get_tty</refname>
cd6d5e1c
ZJS
50 <refname>sd_bus_creds_get_unique_name</refname>
51 <refname>sd_bus_creds_get_well_known_names</refname>
52d7c4dc 52 <refname>sd_bus_creds_get_description</refname>
cd6d5e1c
ZJS
53
54 <refpurpose>Retrieve fields from a credentials object</refpurpose>
55 </refnamediv>
56
57 <refsynopsisdiv>
58 <funcsynopsis>
59 <funcsynopsisinfo>#include &lt;systemd/sd-bus.h&gt;</funcsynopsisinfo>
60
61 <funcprototype>
62 <funcdef>int <function>sd_bus_creds_get_pid</function></funcdef>
8dc385e7 63 <paramdef>sd_bus_creds *<parameter>c</parameter></paramdef>
cd6d5e1c
ZJS
64 <paramdef>pid_t *<parameter>pid</parameter></paramdef>
65 </funcprototype>
66
52d7c4dc
LP
67 <funcprototype>
68 <funcdef>int <function>sd_bus_creds_get_ppid</function></funcdef>
69 <paramdef>sd_bus_creds *<parameter>c</parameter></paramdef>
70 <paramdef>pid_t *<parameter>ppid</parameter></paramdef>
71 </funcprototype>
72
cd6d5e1c
ZJS
73 <funcprototype>
74 <funcdef>int <function>sd_bus_creds_get_tid</function></funcdef>
8dc385e7 75 <paramdef>sd_bus_creds *<parameter>c</parameter></paramdef>
cd6d5e1c
ZJS
76 <paramdef>pid_t *<parameter>tid</parameter></paramdef>
77 </funcprototype>
78
79 <funcprototype>
52d7c4dc
LP
80 <funcdef>int <function>sd_bus_creds_get_uid</function></funcdef>
81 <paramdef>sd_bus_creds *<parameter>c</parameter></paramdef>
82 <paramdef>uid_t *<parameter>uid</parameter></paramdef>
83 </funcprototype>
84
85 <funcprototype>
86 <funcdef>int <function>sd_bus_creds_get_euid</function></funcdef>
87 <paramdef>sd_bus_creds *<parameter>c</parameter></paramdef>
88 <paramdef>uid_t *<parameter>uid</parameter></paramdef>
89 </funcprototype>
90
91 <funcprototype>
92 <funcdef>int <function>sd_bus_creds_get_suid</function></funcdef>
93 <paramdef>sd_bus_creds *<parameter>c</parameter></paramdef>
94 <paramdef>uid_t *<parameter>uid</parameter></paramdef>
95 </funcprototype>
96
97 <funcprototype>
98 <funcdef>int <function>sd_bus_creds_get_fsuid</function></funcdef>
8dc385e7 99 <paramdef>sd_bus_creds *<parameter>c</parameter></paramdef>
cd6d5e1c
ZJS
100 <paramdef>uid_t *<parameter>uid</parameter></paramdef>
101 </funcprototype>
102
103 <funcprototype>
104 <funcdef>int <function>sd_bus_creds_get_gid</function></funcdef>
8dc385e7 105 <paramdef>sd_bus_creds *<parameter>c</parameter></paramdef>
cd6d5e1c
ZJS
106 <paramdef>gid_t *<parameter>gid</parameter></paramdef>
107 </funcprototype>
108
52d7c4dc
LP
109 <funcprototype>
110 <funcdef>int <function>sd_bus_creds_get_egid</function></funcdef>
111 <paramdef>sd_bus_creds *<parameter>c</parameter></paramdef>
112 <paramdef>gid_t *<parameter>gid</parameter></paramdef>
113 </funcprototype>
114
115 <funcprototype>
116 <funcdef>int <function>sd_bus_creds_get_sgid</function></funcdef>
117 <paramdef>sd_bus_creds *<parameter>c</parameter></paramdef>
118 <paramdef>gid_t *<parameter>gid</parameter></paramdef>
119 </funcprototype>
120
121 <funcprototype>
122 <funcdef>int <function>sd_bus_creds_get_fsgid</function></funcdef>
123 <paramdef>sd_bus_creds *<parameter>c</parameter></paramdef>
124 <paramdef>gid_t *<parameter>gid</parameter></paramdef>
125 </funcprototype>
126
127 <funcprototype>
128 <funcdef>int <function>sd_bus_creds_get_supplementary_gids</function></funcdef>
129 <paramdef>sd_bus_creds *<parameter>c</parameter></paramdef>
130 <paramdef>const gid_t **<parameter>gids</parameter></paramdef>
131 </funcprototype>
132
cd6d5e1c
ZJS
133 <funcprototype>
134 <funcdef>int <function>sd_bus_creds_get_comm</function></funcdef>
8dc385e7 135 <paramdef>sd_bus_creds *<parameter>c</parameter></paramdef>
cd6d5e1c
ZJS
136 <paramdef>const char **<parameter>comm</parameter></paramdef>
137 </funcprototype>
138
139 <funcprototype>
140 <funcdef>int <function>sd_bus_creds_get_tid_comm</function></funcdef>
8dc385e7 141 <paramdef>sd_bus_creds *<parameter>c</parameter></paramdef>
cd6d5e1c
ZJS
142 <paramdef>const char **<parameter>comm</parameter></paramdef>
143 </funcprototype>
144
145 <funcprototype>
146 <funcdef>int <function>sd_bus_creds_get_exe</function></funcdef>
8dc385e7 147 <paramdef>sd_bus_creds *<parameter>c</parameter></paramdef>
cd6d5e1c
ZJS
148 <paramdef>const char **<parameter>exe</parameter></paramdef>
149 </funcprototype>
150
151 <funcprototype>
152 <funcdef>int <function>sd_bus_creds_get_cmdline</function></funcdef>
8dc385e7 153 <paramdef>sd_bus_creds *<parameter>c</parameter></paramdef>
cd6d5e1c
ZJS
154 <paramdef>char ***<parameter>cmdline</parameter></paramdef>
155 </funcprototype>
156
157 <funcprototype>
158 <funcdef>int <function>sd_bus_creds_get_cgroup</function></funcdef>
8dc385e7 159 <paramdef>sd_bus_creds *<parameter>c</parameter></paramdef>
cd6d5e1c
ZJS
160 <paramdef>const char **<parameter>cgroup</parameter></paramdef>
161 </funcprototype>
162
163 <funcprototype>
164 <funcdef>int <function>sd_bus_creds_get_unit</function></funcdef>
8dc385e7 165 <paramdef>sd_bus_creds *<parameter>c</parameter></paramdef>
cd6d5e1c
ZJS
166 <paramdef>const char **<parameter>unit</parameter></paramdef>
167 </funcprototype>
168
f6f7a984
LP
169 <funcprototype>
170 <funcdef>int <function>sd_bus_creds_get_slice</function></funcdef>
171 <paramdef>sd_bus_creds *<parameter>c</parameter></paramdef>
172 <paramdef>const char **<parameter>slice</parameter></paramdef>
173 </funcprototype>
174
cd6d5e1c
ZJS
175 <funcprototype>
176 <funcdef>int <function>sd_bus_creds_get_user_unit</function></funcdef>
8dc385e7 177 <paramdef>sd_bus_creds *<parameter>c</parameter></paramdef>
cd6d5e1c
ZJS
178 <paramdef>const char **<parameter>unit</parameter></paramdef>
179 </funcprototype>
180
181 <funcprototype>
f6f7a984 182 <funcdef>int <function>sd_bus_creds_get_user_slice</function></funcdef>
8dc385e7 183 <paramdef>sd_bus_creds *<parameter>c</parameter></paramdef>
cd6d5e1c
ZJS
184 <paramdef>const char **<parameter>slice</parameter></paramdef>
185 </funcprototype>
186
187 <funcprototype>
188 <funcdef>int <function>sd_bus_creds_get_session</function></funcdef>
8dc385e7 189 <paramdef>sd_bus_creds *<parameter>c</parameter></paramdef>
cd6d5e1c
ZJS
190 <paramdef>const char **<parameter>slice</parameter></paramdef>
191 </funcprototype>
192
193 <funcprototype>
194 <funcdef>int <function>sd_bus_creds_get_owner_uid</function></funcdef>
8dc385e7 195 <paramdef>sd_bus_creds *<parameter>c</parameter></paramdef>
cd6d5e1c
ZJS
196 <paramdef>uid_t *<parameter>uid</parameter></paramdef>
197 </funcprototype>
198
199 <funcprototype>
200 <funcdef>int <function>sd_bus_creds_has_effective_cap</function></funcdef>
8dc385e7 201 <paramdef>sd_bus_creds *<parameter>c</parameter></paramdef>
cd6d5e1c
ZJS
202 <paramdef>int <parameter>capability</parameter></paramdef>
203 </funcprototype>
204
205 <funcprototype>
206 <funcdef>int <function>sd_bus_creds_has_permitted_cap</function></funcdef>
8dc385e7 207 <paramdef>sd_bus_creds *<parameter>c</parameter></paramdef>
cd6d5e1c
ZJS
208 <paramdef>int <parameter>capability</parameter></paramdef>
209 </funcprototype>
210
211 <funcprototype>
212 <funcdef>int <function>sd_bus_creds_has_inheritable_cap</function></funcdef>
8dc385e7 213 <paramdef>sd_bus_creds *<parameter>c</parameter></paramdef>
cd6d5e1c
ZJS
214 <paramdef>int <parameter>capability</parameter></paramdef>
215 </funcprototype>
216
217 <funcprototype>
218 <funcdef>int <function>sd_bus_creds_has_bounding_cap</function></funcdef>
8dc385e7 219 <paramdef>sd_bus_creds *<parameter>c</parameter></paramdef>
cd6d5e1c
ZJS
220 <paramdef>int <parameter>capability</parameter></paramdef>
221 </funcprototype>
222
223 <funcprototype>
224 <funcdef>int <function>sd_bus_creds_get_selinux_context</function></funcdef>
8dc385e7 225 <paramdef>sd_bus_creds *<parameter>c</parameter></paramdef>
cd6d5e1c
ZJS
226 <paramdef>const char **<parameter>context</parameter></paramdef>
227 </funcprototype>
228
229 <funcprototype>
230 <funcdef>int <function>sd_bus_creds_get_audit_session_id</function></funcdef>
8dc385e7 231 <paramdef>sd_bus_creds *<parameter>c</parameter></paramdef>
cd6d5e1c
ZJS
232 <paramdef>uint32_t *<parameter>sessionid</parameter></paramdef>
233 </funcprototype>
234
235 <funcprototype>
236 <funcdef>int <function>sd_bus_creds_get_audit_login_uid</function></funcdef>
8dc385e7 237 <paramdef>sd_bus_creds *<parameter>c</parameter></paramdef>
cd6d5e1c
ZJS
238 <paramdef>uid_t *<parameter>loginuid</parameter></paramdef>
239 </funcprototype>
240
52d7c4dc
LP
241 <funcprototype>
242 <funcdef>int <function>sd_bus_creds_get_tty</function></funcdef>
243 <paramdef>sd_bus_creds *<parameter>c</parameter></paramdef>
244 <paramdef>const char **<parameter>tty</parameter></paramdef>
245 </funcprototype>
246
cd6d5e1c
ZJS
247 <funcprototype>
248 <funcdef>int <function>sd_bus_creds_get_unique_name</function></funcdef>
8dc385e7 249 <paramdef>sd_bus_creds *<parameter>c</parameter></paramdef>
cd6d5e1c
ZJS
250 <paramdef>const char **<parameter>name</parameter></paramdef>
251 </funcprototype>
252
253 <funcprototype>
254 <funcdef>int <function>sd_bus_creds_get_well_known_names</function></funcdef>
8dc385e7 255 <paramdef>sd_bus_creds *<parameter>c</parameter></paramdef>
cd6d5e1c
ZJS
256 <paramdef>char ***<parameter>name</parameter></paramdef>
257 </funcprototype>
258
5c20a8bc 259 <funcprototype>
52d7c4dc 260 <funcdef>int <function>sd_bus_creds_get_description</function></funcdef>
5c20a8bc
LP
261 <paramdef>sd_bus_creds *<parameter>c</parameter></paramdef>
262 <paramdef>const char **<parameter>name</parameter></paramdef>
263 </funcprototype>
264
cd6d5e1c
ZJS
265 </funcsynopsis>
266 </refsynopsisdiv>
267
268 <refsect1>
269 <title>Description</title>
270
f6f7a984
LP
271 <para>These functions return credential information from an
272 <parameter>sd_bus_creds</parameter> object. Credential objects may
273 be created with
cd6d5e1c 274 <citerefentry><refentrytitle>sd_bus_creds_new_from_pid</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
52d7c4dc
LP
275 in which case they describe the credentials of the process
276 identified by the specified PID, with
277 <citerefentry><refentrytitle>sd_bus_get_name_creds</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
278 in which case they describe the credentials of a bus peer
b655a028 279 identified by the specified bus name, with
056f95d0 280 <citerefentry><refentrytitle>sd_bus_get_owner_creds</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
52d7c4dc 281 in which case they describe the credentials of the creator of a
b655a028
UTL
282 bus, or with
283 <citerefentry><refentrytitle>sd_bus_message_get_creds</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
f6f7a984
LP
284 in which case they describe the credentials of the sender of the
285 message.</para>
286
287 <para>Not all credential fields are part of every
288 <literal>sd_bus_creds</literal> object. Use
289 <citerefentry><refentrytitle>sd_bus_creds_get_mask</refentrytitle><manvolnum>3</manvolnum></citerefentry>
290 to determine the mask of fields available.</para>
cd6d5e1c 291
52d7c4dc 292 <para><function>sd_bus_creds_get_pid()</function> will retrieve
a8eaaee7 293 the PID (process identifier). Similarly,
52d7c4dc
LP
294 <function>sd_bus_creds_get_ppid()</function> will retrieve the
295 parent PID. Note that PID 1 has no parent process, in which case
296 -ENXIO is returned.</para>
cd6d5e1c 297
b7ea3f3e 298 <para><function>sd_bus_creds_get_tid()</function> will retrieve the
cd6d5e1c
ZJS
299 TID (thread identifier).</para>
300
52d7c4dc 301 <para><function>sd_bus_creds_get_uid()</function> will retrieve
a8eaaee7 302 the numeric UID (user identifier). Similarly,
52d7c4dc
LP
303 <function>sd_bus_creds_get_euid()</function> returns the effective
304 UID, <function>sd_bus_creds_get_suid()</function> the saved UID
305 and <function>sd_bus_creds_get_fsuid()</function> the file system
306 UID.</para>
cd6d5e1c 307
b7ea3f3e 308 <para><function>sd_bus_creds_get_gid()</function> will retrieve the
a8eaaee7 309 numeric GID (group identifier). Similarly,
52d7c4dc
LP
310 <function>sd_bus_creds_get_egid()</function> returns the effective
311 GID, <function>sd_bus_creds_get_sgid()</function> the saved GID
312 and <function>sd_bus_creds_get_fsgid()</function> the file system
313 GID.</para>
314
315 <para><function>sd_bus_creds_get_supplementary_gids()</function>
316 will retrieve the supplementary GIDs list.</para>
cd6d5e1c 317
b7ea3f3e 318 <para><function>sd_bus_creds_get_comm()</function> will retrieve the
dc968941 319 comm field (truncated name of the executable, as stored in
cd6d5e1c
ZJS
320 <filename>/proc/<replaceable>pid</replaceable>/comm</filename>).
321 </para>
322
b7ea3f3e 323 <para><function>sd_bus_creds_get_tid_comm()</function> will retrieve
cd6d5e1c
ZJS
324 the comm field of the thread (as stored in
325 <filename>/proc/<replaceable>pid</replaceable>/task/<replaceable>tid</replaceable>/comm</filename>).
326 </para>
327
e5134f00
LP
328 <para><function>sd_bus_creds_get_exe()</function> will retrieve the path to the program executable (as
329 stored in the <filename>/proc/<replaceable>pid</replaceable>/exe</filename> link, but with the <literal>
330 (deleted)</literal> suffix removed). Note that kernel threads do not have an executable path, in which
331 case -ENXIO is returned. Note that this property should not be used for more than explanatory
332 information, in particular it should not be used for security-relevant decisions. That's because the
333 executable might have been replaced or removed by the time the value can be processed. Moreover, the
334 kernel exports this information in an ambiguous way (i.e. a deleted executable cannot be safely
f4e1a425 335 distinguished from one whose name suffix is <literal> (deleted)</literal>).</para>
cd6d5e1c 336
52d7c4dc
LP
337 <para><function>sd_bus_creds_get_cmdline()</function> will
338 retrieve an array of command line arguments (as stored in
339 <filename>/proc/<replaceable>pid</replaceable>/cmdline</filename>). Note
340 that kernel threads do not have a command line, in which case
341 -ENXIO is returned.</para>
cd6d5e1c 342
b7ea3f3e 343 <para><function>sd_bus_creds_get_cgroup()</function> will retrieve
c7458f93 344 the control group path. See <ulink
3c887f97 345 url="https://www.kernel.org/doc/Documentation/cgroup-v1/cgroups.txt">cgroups.txt</ulink>.
cd6d5e1c
ZJS
346 </para>
347
52d7c4dc
LP
348 <para><function>sd_bus_creds_get_unit()</function> will retrieve
349 the systemd unit name (in the system instance of systemd) that the
a8eaaee7 350 process is a part of. See
52d7c4dc 351 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>. For
b938cb90 352 processes that are not part of a unit, returns -ENXIO.
cd6d5e1c
ZJS
353 </para>
354
b7ea3f3e 355 <para><function>sd_bus_creds_get_user_unit()</function> will
cd6d5e1c 356 retrieve the systemd unit name (in the user instance of systemd)
a8eaaee7 357 that the process is a part of. See
52d7c4dc 358 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>. For
b938cb90 359 processes that are not part of a user unit, returns -ENXIO.
cd6d5e1c
ZJS
360 </para>
361
b7ea3f3e 362 <para><function>sd_bus_creds_get_slice()</function> will retrieve
cd6d5e1c 363 the systemd slice (a unit in the system instance of systemd) that
a8eaaee7
JE
364 the process is a part of. See
365 <citerefentry><refentrytitle>systemd.slice</refentrytitle><manvolnum>5</manvolnum></citerefentry>. Similarly,
f6f7a984
LP
366 <function>sd_bus_creds_get_user_slice()</function> retrieves the
367 systemd slice of the process, in the user instance of systemd.
cd6d5e1c
ZJS
368 </para>
369
52d7c4dc 370 <para><function>sd_bus_creds_get_session()</function> will
f6f7a984 371 retrieve the identifier of the login session that the process is
1c97e2eb
AJ
372 a part of. Please note the login session may be limited to a stub
373 process or two. User processes may instead be started from their
374 systemd user manager, e.g. GUI applications started using DBus
375 activation, as well as service processes which are shared between
376 multiple logins of the same user. For processes that are not part
377 of a session, returns -ENXIO.</para>
cd6d5e1c 378
52d7c4dc
LP
379 <para><function>sd_bus_creds_get_owner_uid()</function> will
380 retrieve the numeric UID (user identifier) of the user who owns
1c97e2eb 381 the user unit or login session that the process is a part of. See
f6f7a984 382 <citerefentry><refentrytitle>systemd-logind.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
1c97e2eb
AJ
383 For processes that are not part of a user unit or session, returns
384 -ENXIO.
cd6d5e1c
ZJS
385 </para>
386
479050b3
LP
387 <para><function>sd_bus_creds_has_effective_cap()</function> will check whether the capability specified by
388 <parameter>capability</parameter> was set in the effective capabilities mask. A positive return value means that it
389 was set, zero means that it was not set, and a negative return value indicates an error. See <citerefentry
390 project='man-pages'><refentrytitle>capabilities</refentrytitle><manvolnum>7</manvolnum></citerefentry> and the
391 <varname>AmbientCapabilities=</varname> and <varname>CapabilityBoundingSet=</varname> settings in
cd6d5e1c
ZJS
392 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
393 </para>
394
b7ea3f3e
LP
395 <para><function>sd_bus_creds_has_permitted_cap()</function> is
396 similar to <function>sd_bus_creds_has_effective_cap()</function>,
cd6d5e1c
ZJS
397 but will check the permitted capabilities mask.</para>
398
b7ea3f3e
LP
399 <para><function>sd_bus_creds_has_inheritable_cap()</function> is
400 similar to <function>sd_bus_creds_has_effective_cap()</function>,
cd6d5e1c
ZJS
401 but will check the inheritable capabilities mask.</para>
402
b7ea3f3e
LP
403 <para><function>sd_bus_creds_has_bounding_cap()</function> is
404 similar to <function>sd_bus_creds_has_effective_cap()</function>,
cd6d5e1c
ZJS
405 but will check the bounding capabilities mask.</para>
406
b7ea3f3e 407 <para><function>sd_bus_creds_get_selinux_context()</function> will
82adf6af 408 retrieve the SELinux security context (label) of the process.</para>
cd6d5e1c 409
52d7c4dc
LP
410 <para><function>sd_bus_creds_get_audit_session_id()</function>
411 will retrieve the audit session identifier of the process. Returns
412 -ENXIO for processes that are not part of an audit session.</para>
cd6d5e1c 413
b7ea3f3e 414 <para><function>sd_bus_creds_get_audit_login_uid()</function> will
cd6d5e1c 415 retrieve the audit user login identifier (the identifier of the
52d7c4dc
LP
416 user who is "responsible" for the session). Returns -ENXIO for
417 processes that are not part of an audit session.</para>
418
419 <para><function>sd_bus_creds_get_tty()</function> will retrieve
f6f7a984
LP
420 the controlling TTY, without the prefixing "/dev/". Returns -ENXIO
421 for processes that have no controlling TTY.</para>
cd6d5e1c 422
b7ea3f3e 423 <para><function>sd_bus_creds_get_unique_name()</function> will
cd6d5e1c
ZJS
424 retrieve the D-Bus unique name. See <ulink
425 url="http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names-bus">The
426 D-Bus specification</ulink>.</para>
427
b7ea3f3e 428 <para><function>sd_bus_creds_get_well_known_names()</function> will
cd6d5e1c
ZJS
429 retrieve the set of D-Bus well-known names. See <ulink
430 url="http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names-bus">The
431 D-Bus specification</ulink>.</para>
432
52d7c4dc 433 <para><function>sd_bus_creds_get_description()</function> will
5c20a8bc
LP
434 retrieve a descriptive name of the bus connection of the
435 peer. This name is useful to discern multiple bus connections by
436 the same peer, and may be altered by the peer with the
52d7c4dc 437 <citerefentry><refentrytitle>sd_bus_set_description</refentrytitle><manvolnum>3</manvolnum></citerefentry>
5c20a8bc
LP
438 call.</para>
439
cd6d5e1c
ZJS
440 <para>All functions that take a <parameter>const
441 char**</parameter> parameter will store the answer there as an
442 address of a NUL-terminated string. It will be valid as long as
443 <parameter>c</parameter> remains valid, and should not be freed or
444 modified by the caller.</para>
445
446 <para>All functions that take a <parameter>char***</parameter>
7f3fdb7f 447 parameter will store the answer there as an address of an array
ff9b60f3 448 of strings. Each individual string is NUL-terminated, and the
cd6d5e1c
ZJS
449 array is NULL-terminated as a whole. It will be valid as long as
450 <parameter>c</parameter> remains valid, and should not be freed or
451 modified by the caller.</para>
452 </refsect1>
453
454 <refsect1>
455 <title>Return Value</title>
456
457 <para>On success, these calls return 0 or a positive integer. On
458 failure, these calls return a negative errno-style error code.
459 </para>
cd6d5e1c 460
b1de39de
ZJS
461 <refsect2>
462 <title>Errors</title>
463
464 <para>Returned errors may indicate the following problems:</para>
465
466 <variablelist>
467 <varlistentry>
468 <term><constant>-ENODATA</constant></term>
469
470 <listitem><para>The given field is not available in the credentials object
471 <parameter>c</parameter>.</para>
472 </listitem>
473 </varlistentry>
474
475 <varlistentry>
476 <term><constant>-ENXIO</constant></term>
477
478 <listitem><para>The given field is not specified for the described process or peer. This will be
479 returned by <function>sd_bus_creds_get_unit()</function>,
480 <function>sd_bus_creds_get_slice()</function>, <function>sd_bus_creds_get_user_unit()</function>,
481 <function>sd_bus_creds_get_user_slice()</function>, and
482 <function>sd_bus_creds_get_session()</function> if the process is not part of a systemd system
483 unit, systemd user unit, systemd slice, or logind session. It will be returned by
484 <function>sd_bus_creds_get_owner_uid()</function> if the process is not part of a systemd user unit
485 or logind session. It will also be returned by <function>sd_bus_creds_get_exe()</function> and
486 <function>sd_bus_creds_get_cmdline()</function> for kernel threads (since these are not started
487 from an executable binary, nor have a command line), and by
488 <function>sd_bus_creds_get_audit_session_id()</function> and
489 <function>sd_bus_creds_get_audit_login_uid()</function> when the process is not part of an audit
490 session, and <function>sd_bus_creds_get_tty()</function> if the process has no controlling
491 TTY.</para></listitem>
492 </varlistentry>
493
494 <varlistentry>
495 <term><constant>-EINVAL</constant></term>
496
497 <listitem><para>Specified pointer parameter is <constant>NULL</constant>.</para></listitem>
498 </varlistentry>
499
500 <varlistentry>
501 <term><constant>-ENOMEM</constant></term>
502
503 <listitem><para>Memory allocation failed.</para></listitem>
504 </varlistentry>
505 </variablelist>
506 </refsect2>
cd6d5e1c
ZJS
507 </refsect1>
508
7d6b2723 509 <xi:include href="libsystemd-pkgconfig.xml" />
cd6d5e1c
ZJS
510
511 <refsect1>
512 <title>See Also</title>
513
514 <para>
515 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
516 <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
f6f7a984
LP
517 <citerefentry><refentrytitle>sd_bus_creds_new_from_pid</refentrytitle><manvolnum>2</manvolnum></citerefentry>,
518 <citerefentry project='man-pages'><refentrytitle>fork</refentrytitle><manvolnum>2</manvolnum></citerefentry>,
519 <citerefentry project='man-pages'><refentrytitle>execve</refentrytitle><manvolnum>2</manvolnum></citerefentry>,
5aded369
ZJS
520 <citerefentry project='man-pages'><refentrytitle>credentials</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
521 <citerefentry project='man-pages'><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
522 <citerefentry project='man-pages'><refentrytitle>proc</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
e530ed5e 523 <citerefentry><refentrytitle>systemd.journal-fields</refentrytitle><manvolnum>7</manvolnum></citerefentry>
cd6d5e1c
ZJS
524 </para>
525 </refsect1>
526
527</refentry>