]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/sd_bus_creds_get_pid.xml
travis: use UBSan checks from OSS-Fuzz
[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
52d7c4dc
LP
328 <para><function>sd_bus_creds_get_exe()</function> will retrieve
329 the path to the program executable (as stored in the
cd6d5e1c 330 <filename>/proc/<replaceable>pid</replaceable>/exe</filename>
a8eaaee7 331 link, but with the <literal> (deleted)</literal> suffix removed). Note
52d7c4dc
LP
332 that kernel threads do not have an executable path, in which case
333 -ENXIO is returned.</para>
cd6d5e1c 334
52d7c4dc
LP
335 <para><function>sd_bus_creds_get_cmdline()</function> will
336 retrieve an array of command line arguments (as stored in
337 <filename>/proc/<replaceable>pid</replaceable>/cmdline</filename>). Note
338 that kernel threads do not have a command line, in which case
339 -ENXIO is returned.</para>
cd6d5e1c 340
b7ea3f3e 341 <para><function>sd_bus_creds_get_cgroup()</function> will retrieve
c7458f93 342 the control group path. See <ulink
3c887f97 343 url="https://www.kernel.org/doc/Documentation/cgroup-v1/cgroups.txt">cgroups.txt</ulink>.
cd6d5e1c
ZJS
344 </para>
345
52d7c4dc
LP
346 <para><function>sd_bus_creds_get_unit()</function> will retrieve
347 the systemd unit name (in the system instance of systemd) that the
a8eaaee7 348 process is a part of. See
52d7c4dc 349 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>. For
b938cb90 350 processes that are not part of a unit, returns -ENXIO.
cd6d5e1c
ZJS
351 </para>
352
b7ea3f3e 353 <para><function>sd_bus_creds_get_user_unit()</function> will
cd6d5e1c 354 retrieve the systemd unit name (in the user instance of systemd)
a8eaaee7 355 that the process is a part of. See
52d7c4dc 356 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>. For
b938cb90 357 processes that are not part of a user unit, returns -ENXIO.
cd6d5e1c
ZJS
358 </para>
359
b7ea3f3e 360 <para><function>sd_bus_creds_get_slice()</function> will retrieve
cd6d5e1c 361 the systemd slice (a unit in the system instance of systemd) that
a8eaaee7
JE
362 the process is a part of. See
363 <citerefentry><refentrytitle>systemd.slice</refentrytitle><manvolnum>5</manvolnum></citerefentry>. Similarly,
f6f7a984
LP
364 <function>sd_bus_creds_get_user_slice()</function> retrieves the
365 systemd slice of the process, in the user instance of systemd.
cd6d5e1c
ZJS
366 </para>
367
52d7c4dc 368 <para><function>sd_bus_creds_get_session()</function> will
f6f7a984 369 retrieve the identifier of the login session that the process is
1c97e2eb
AJ
370 a part of. Please note the login session may be limited to a stub
371 process or two. User processes may instead be started from their
372 systemd user manager, e.g. GUI applications started using DBus
373 activation, as well as service processes which are shared between
374 multiple logins of the same user. For processes that are not part
375 of a session, returns -ENXIO.</para>
cd6d5e1c 376
52d7c4dc
LP
377 <para><function>sd_bus_creds_get_owner_uid()</function> will
378 retrieve the numeric UID (user identifier) of the user who owns
1c97e2eb 379 the user unit or login session that the process is a part of. See
f6f7a984 380 <citerefentry><refentrytitle>systemd-logind.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
1c97e2eb
AJ
381 For processes that are not part of a user unit or session, returns
382 -ENXIO.
cd6d5e1c
ZJS
383 </para>
384
479050b3
LP
385 <para><function>sd_bus_creds_has_effective_cap()</function> will check whether the capability specified by
386 <parameter>capability</parameter> was set in the effective capabilities mask. A positive return value means that it
387 was set, zero means that it was not set, and a negative return value indicates an error. See <citerefentry
388 project='man-pages'><refentrytitle>capabilities</refentrytitle><manvolnum>7</manvolnum></citerefentry> and the
389 <varname>AmbientCapabilities=</varname> and <varname>CapabilityBoundingSet=</varname> settings in
cd6d5e1c
ZJS
390 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
391 </para>
392
b7ea3f3e
LP
393 <para><function>sd_bus_creds_has_permitted_cap()</function> is
394 similar to <function>sd_bus_creds_has_effective_cap()</function>,
cd6d5e1c
ZJS
395 but will check the permitted capabilities mask.</para>
396
b7ea3f3e
LP
397 <para><function>sd_bus_creds_has_inheritable_cap()</function> is
398 similar to <function>sd_bus_creds_has_effective_cap()</function>,
cd6d5e1c
ZJS
399 but will check the inheritable capabilities mask.</para>
400
b7ea3f3e
LP
401 <para><function>sd_bus_creds_has_bounding_cap()</function> is
402 similar to <function>sd_bus_creds_has_effective_cap()</function>,
cd6d5e1c
ZJS
403 but will check the bounding capabilities mask.</para>
404
b7ea3f3e 405 <para><function>sd_bus_creds_get_selinux_context()</function> will
82adf6af 406 retrieve the SELinux security context (label) of the process.</para>
cd6d5e1c 407
52d7c4dc
LP
408 <para><function>sd_bus_creds_get_audit_session_id()</function>
409 will retrieve the audit session identifier of the process. Returns
410 -ENXIO for processes that are not part of an audit session.</para>
cd6d5e1c 411
b7ea3f3e 412 <para><function>sd_bus_creds_get_audit_login_uid()</function> will
cd6d5e1c 413 retrieve the audit user login identifier (the identifier of the
52d7c4dc
LP
414 user who is "responsible" for the session). Returns -ENXIO for
415 processes that are not part of an audit session.</para>
416
417 <para><function>sd_bus_creds_get_tty()</function> will retrieve
f6f7a984
LP
418 the controlling TTY, without the prefixing "/dev/". Returns -ENXIO
419 for processes that have no controlling TTY.</para>
cd6d5e1c 420
b7ea3f3e 421 <para><function>sd_bus_creds_get_unique_name()</function> will
cd6d5e1c
ZJS
422 retrieve the D-Bus unique name. See <ulink
423 url="http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names-bus">The
424 D-Bus specification</ulink>.</para>
425
b7ea3f3e 426 <para><function>sd_bus_creds_get_well_known_names()</function> will
cd6d5e1c
ZJS
427 retrieve the set of D-Bus well-known names. See <ulink
428 url="http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names-bus">The
429 D-Bus specification</ulink>.</para>
430
52d7c4dc 431 <para><function>sd_bus_creds_get_description()</function> will
5c20a8bc
LP
432 retrieve a descriptive name of the bus connection of the
433 peer. This name is useful to discern multiple bus connections by
434 the same peer, and may be altered by the peer with the
52d7c4dc 435 <citerefentry><refentrytitle>sd_bus_set_description</refentrytitle><manvolnum>3</manvolnum></citerefentry>
5c20a8bc
LP
436 call.</para>
437
cd6d5e1c
ZJS
438 <para>All functions that take a <parameter>const
439 char**</parameter> parameter will store the answer there as an
440 address of a NUL-terminated string. It will be valid as long as
441 <parameter>c</parameter> remains valid, and should not be freed or
442 modified by the caller.</para>
443
444 <para>All functions that take a <parameter>char***</parameter>
7f3fdb7f 445 parameter will store the answer there as an address of an array
ff9b60f3 446 of strings. Each individual string is NUL-terminated, and the
cd6d5e1c
ZJS
447 array is NULL-terminated as a whole. It will be valid as long as
448 <parameter>c</parameter> remains valid, and should not be freed or
449 modified by the caller.</para>
450 </refsect1>
451
452 <refsect1>
453 <title>Return Value</title>
454
455 <para>On success, these calls return 0 or a positive integer. On
456 failure, these calls return a negative errno-style error code.
457 </para>
cd6d5e1c 458
b1de39de
ZJS
459 <refsect2>
460 <title>Errors</title>
461
462 <para>Returned errors may indicate the following problems:</para>
463
464 <variablelist>
465 <varlistentry>
466 <term><constant>-ENODATA</constant></term>
467
468 <listitem><para>The given field is not available in the credentials object
469 <parameter>c</parameter>.</para>
470 </listitem>
471 </varlistentry>
472
473 <varlistentry>
474 <term><constant>-ENXIO</constant></term>
475
476 <listitem><para>The given field is not specified for the described process or peer. This will be
477 returned by <function>sd_bus_creds_get_unit()</function>,
478 <function>sd_bus_creds_get_slice()</function>, <function>sd_bus_creds_get_user_unit()</function>,
479 <function>sd_bus_creds_get_user_slice()</function>, and
480 <function>sd_bus_creds_get_session()</function> if the process is not part of a systemd system
481 unit, systemd user unit, systemd slice, or logind session. It will be returned by
482 <function>sd_bus_creds_get_owner_uid()</function> if the process is not part of a systemd user unit
483 or logind session. It will also be returned by <function>sd_bus_creds_get_exe()</function> and
484 <function>sd_bus_creds_get_cmdline()</function> for kernel threads (since these are not started
485 from an executable binary, nor have a command line), and by
486 <function>sd_bus_creds_get_audit_session_id()</function> and
487 <function>sd_bus_creds_get_audit_login_uid()</function> when the process is not part of an audit
488 session, and <function>sd_bus_creds_get_tty()</function> if the process has no controlling
489 TTY.</para></listitem>
490 </varlistentry>
491
492 <varlistentry>
493 <term><constant>-EINVAL</constant></term>
494
495 <listitem><para>Specified pointer parameter is <constant>NULL</constant>.</para></listitem>
496 </varlistentry>
497
498 <varlistentry>
499 <term><constant>-ENOMEM</constant></term>
500
501 <listitem><para>Memory allocation failed.</para></listitem>
502 </varlistentry>
503 </variablelist>
504 </refsect2>
cd6d5e1c
ZJS
505 </refsect1>
506
7d6b2723 507 <xi:include href="libsystemd-pkgconfig.xml" />
cd6d5e1c
ZJS
508
509 <refsect1>
510 <title>See Also</title>
511
512 <para>
513 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
514 <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
f6f7a984
LP
515 <citerefentry><refentrytitle>sd_bus_creds_new_from_pid</refentrytitle><manvolnum>2</manvolnum></citerefentry>,
516 <citerefentry project='man-pages'><refentrytitle>fork</refentrytitle><manvolnum>2</manvolnum></citerefentry>,
517 <citerefentry project='man-pages'><refentrytitle>execve</refentrytitle><manvolnum>2</manvolnum></citerefentry>,
5aded369
ZJS
518 <citerefentry project='man-pages'><refentrytitle>credentials</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
519 <citerefentry project='man-pages'><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
520 <citerefentry project='man-pages'><refentrytitle>proc</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
e530ed5e 521 <citerefentry><refentrytitle>systemd.journal-fields</refentrytitle><manvolnum>7</manvolnum></citerefentry>
cd6d5e1c
ZJS
522 </para>
523 </refsect1>
524
525</refentry>