Debian Codegraph @

upstream/debian-unstable/man3/sd_bus_query_sender_creds.3

raw
1 '\" t
2 .TH "SD_BUS_QUERY_SENDER_CREDS" "3" "" "systemd 261~rc3" "sd_bus_query_sender_creds"
3 .\" -----------------------------------------------------------------
4 .\" * Define some portability stuff
5 .\" -----------------------------------------------------------------
6 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 .\" http://bugs.debian.org/507673
8 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
9 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10 .ie \n(.g .ds Aq \(aq
11 .el .ds Aq '
12 .\" -----------------------------------------------------------------
13 .\" * set default formatting
14 .\" -----------------------------------------------------------------
15 .\" disable hyphenation
16 .nh
17 .\" disable justification (adjust text to left margin only)
18 .ad l
19 .\" -----------------------------------------------------------------
20 .\" * MAIN CONTENT STARTS HERE *
21 .\" -----------------------------------------------------------------
22 .SH "NAME"
23 sd_bus_query_sender_creds, sd_bus_query_sender_privilege \- Query bus message sender credentials/privileges
24 .SH "SYNOPSIS"
25 .sp
26 .ft B
27 .nf
28 #include <systemd/sd\-bus\&.h>
29 .fi
30 .ft
31 .HP \w'int\ sd_bus_query_sender_creds('u
32 .BI "int sd_bus_query_sender_creds(sd_bus_message\ *" "m" ", uint64_t\ " "mask" ", sd_bus_creds\ **" "creds" ");"
33 .HP \w'sd_bus_error*\ sd_bus_query_sender_privilege('u
34 .BI "sd_bus_error* sd_bus_query_sender_privilege(sd_bus_message\ *" "m" ", int\ " "capability" ");"
35 .SH "DESCRIPTION"
36 .PP
37 \fBsd_bus_query_sender_creds()\fR
38 returns the credentials of the message
39 \fIm\fR\&. The
40 \fImask\fR
41 parameter is a combo of
42 \fBSD_BUS_CREDS_*\fR
43 flags that indicate which credential info the caller is interested in\&. See
44 \fBsd_bus_creds_new_from_pid\fR(3)
45 for a list of possible flags\&. First, this message checks if the requested credentials are attached to the message itself\&. If not, but the message contains the pid of the sender and the caller specified the
46 \fBSD_BUS_CREDS_AUGMENT\fR
47 flag, this function tries to figure out the missing credentials via other means (starting from the pid)\&. If the PID is not available but the message has a sender, this function calls
48 \fBsd_bus_get_name_creds\fR(3)
49 to get the requested credentials\&. If the message has no sender (when a direct connection is used), this function calls
50 \fBsd_bus_get_owner_creds\fR(3)
51 to get the requested credentials\&. On success, the requested credentials are stored in
52 \fIcreds\fR\&. Ownership of the credentials object in
53 \fIcreds\fR
54 is transferred to the caller and should be freed by calling
55 \fBsd_bus_creds_unref\fR(3)\&.
56 .PP
57 \fBsd_bus_query_sender_privilege()\fR
58 checks if the message
59 \fIm\fR
60 has the requested privileges\&. If
61 \fIcapability\fR
62 is a non\-negative integer, this function checks if the message has the capability with the same value\&. See
63 \fBcapabilities\fR(7)
64 for a list of capabilities\&. If
65 \fIcapability\fR
66 is a negative integer, this function returns whether the sender of the message runs as the same user as the receiver of the message, or if the sender of the message runs as root and the receiver of the message does not run as root\&. On success and if the message has the requested privileges, this function returns a positive integer\&. If the message does not have the requested privileges, this function returns zero\&.
67 .SH "RETURN VALUE"
68 .PP
69 On success, these functions return a non\-negative integer\&. On failure, they return a negative errno\-style error code\&.
70 .SS "Errors"
71 .PP
72 Returned errors may indicate the following problems:
73 .PP
74 \fB\-EINVAL\fR
75 .RS 4
76 The message
77 \fIm\fR
78 or an output parameter is
79 \fBNULL\fR\&.
80 .sp
81 Added in version 246\&.
82 .RE
83 .PP
84 \fB\-ENOTCONN\fR
85 .RS 4
86 The bus of
87 \fIm\fR
88 is not connected\&.
89 .sp
90 Added in version 246\&.
91 .RE
92 .PP
93 \fB\-ECHILD\fR
94 .RS 4
95 The bus of
96 \fIm\fR
97 was created in a different process, library or module instance\&.
98 .sp
99 Added in version 246\&.
100 .RE
101 .PP
102 \fB\-EPERM\fR
103 .RS 4
104 The message
105 \fIm\fR
106 is not sealed\&.
107 .sp
108 Added in version 246\&.
109 .RE
110 .SH "NOTES"
111 .PP
112 Functions described here are available as a shared library, which can be compiled against and linked to with the
113 \fBlibsystemd\fR\ \&\fBpkg-config\fR(1)
114 file\&.
115 .PP
116 The code described here uses
117 \fBgetenv\fR(3), which is declared to be not multi\-thread\-safe\&. This means that the code calling the functions described here must not call
118 \fBsetenv\fR(3)
119 from a parallel thread\&. It is recommended to only do calls to
120 \fBsetenv()\fR
121 from an early phase of the program when no other threads have been started\&.
122 .SH "HISTORY"
123 .PP
124 \fBsd_bus_query_sender_creds()\fR
125 and
126 \fBsd_bus_query_sender_privilege()\fR
127 were added in version 246\&.
128 .SH "SEE ALSO"
129 .PP
130 \fBsystemd\fR(1), \fBsd-bus\fR(3), \fBsd_bus_creds_new_from_pid\fR(3), \fBsd_bus_get_name_creds\fR(3), \fBsd_bus_get_owner_creds\fR(3), \fBsd_bus_creds_unref\fR(3), \fBcapabilities\fR(7)