sd_bus_creds_new_from_pid.3 6.35 KB
Newer Older
1
'\" t
Michael Biebl's avatar
Michael Biebl committed
2
.TH "SD_BUS_CREDS_NEW_FROM_PID" "3" "" "systemd 215" "sd_bus_creds_new_from_pid"
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
sd_bus_creds_new_from_pid, sd_bus_creds_get_mask, sd_bus_creds_ref, sd_bus_creds_unref \- Retrieve credentials object for the specified PID
.SH "SYNOPSIS"
.sp
.ft B
.nf
#include <systemd/sd\-bus\&.h>
.fi
.ft
.HP \w'int\ sd_bus_creds_new_from_pid('u
.BI "int sd_bus_creds_new_from_pid(pid_t\ " "pid" ", uint64_t\ " "creds_mask" ", sd_bus_creds\ **" "ret" ");"
.HP \w'uint64_t\ sd_bus_creds_get_mask('u
.BI "uint64_t sd_bus_creds_get_mask(const\ sd_bus_creds\ *" "c" ");"
.HP \w'sd_bus_creds\ *sd_bus_creds_ref('u
.BI "sd_bus_creds *sd_bus_creds_ref(sd_bus_creds\ *" "c" ");"
.HP \w'sd_bus_creds\ *sd_bus_creds_unref('u
.BI "sd_bus_creds *sd_bus_creds_unref(sd_bus_creds\ *" "c" ");"
.PP
\fBSD_BUS_CREDS_PID\fR,
\fBSD_BUS_CREDS_PID_STARTTIME\fR,
\fBSD_BUS_CREDS_TID\fR,
\fBSD_BUS_CREDS_UID\fR,
\fBSD_BUS_CREDS_GID\fR,
\fBSD_BUS_CREDS_COMM\fR,
\fBSD_BUS_CREDS_TID_COMM\fR,
\fBSD_BUS_CREDS_EXE\fR,
\fBSD_BUS_CREDS_CMDLINE\fR,
\fBSD_BUS_CREDS_CGROUP\fR,
\fBSD_BUS_CREDS_UNIT\fR,
\fBSD_BUS_CREDS_USER_UNIT\fR,
\fBSD_BUS_CREDS_SLICE\fR,
\fBSD_BUS_CREDS_SESSION\fR,
\fBSD_BUS_CREDS_OWNER_UID\fR,
\fBSD_BUS_CREDS_EFFECTIVE_CAPS\fR,
\fBSD_BUS_CREDS_PERMITTED_CAPS\fR,
\fBSD_BUS_CREDS_INHERITABLE_CAPS\fR,
\fBSD_BUS_CREDS_BOUNDING_CAPS\fR,
\fBSD_BUS_CREDS_SELINUX_CONTEXT\fR,
\fBSD_BUS_CREDS_AUDIT_SESSION_ID\fR,
\fBSD_BUS_CREDS_AUDIT_LOGIN_UID\fR,
\fBSD_BUS_CREDS_UNIQUE_NAME\fR,
\fBSD_BUS_CREDS_WELL_KNOWN_NAMES\fR,
\fB_SD_BUS_CREDS_ALL\fR
.SH "DESCRIPTION"
.PP
\fBsd_bus_creds_new_from_pid()\fR
creates a new credentials object and fills it with information about the process
\fIpid\fR\&. This pointer to this object will be stored in
\fIret\fR
pointer\&.
.PP
The information that will be stored is determined by
\fIcreds_mask\fR\&. It may contain a subset of ORed constants
\fBSD_BUS_CREDS_PID\fR,
\fBSD_BUS_CREDS_PID_STARTTIME\fR,
\fBSD_BUS_CREDS_TID\fR,
\fBSD_BUS_CREDS_UID\fR,
\fBSD_BUS_CREDS_GID\fR,
\fBSD_BUS_CREDS_COMM\fR,
\fBSD_BUS_CREDS_TID_COMM\fR,
\fBSD_BUS_CREDS_EXE\fR,
\fBSD_BUS_CREDS_CMDLINE\fR,
\fBSD_BUS_CREDS_CGROUP\fR,
\fBSD_BUS_CREDS_UNIT\fR,
\fBSD_BUS_CREDS_USER_UNIT\fR,
\fBSD_BUS_CREDS_SLICE\fR,
\fBSD_BUS_CREDS_SESSION\fR,
\fBSD_BUS_CREDS_OWNER_UID\fR,
\fBSD_BUS_CREDS_EFFECTIVE_CAPS\fR,
\fBSD_BUS_CREDS_PERMITTED_CAPS\fR,
\fBSD_BUS_CREDS_INHERITABLE_CAPS\fR,
\fBSD_BUS_CREDS_BOUNDING_CAPS\fR,
\fBSD_BUS_CREDS_SELINUX_CONTEXT\fR,
\fBSD_BUS_CREDS_AUDIT_SESSION_ID\fR,
\fBSD_BUS_CREDS_AUDIT_LOGIN_UID\fR,
\fBSD_BUS_CREDS_UNIQUE_NAME\fR,
\fBSD_BUS_CREDS_WELL_KNOWN_NAMES\fR, or
\fB_SD_BUS_CREDS_ALL\fR
to indicate all known fields\&.
.PP
Fields can be retrieved from the credentials object using
\fBsd_bus_creds_get_pid\fR(3)
and other functions which correspond directly to the constants listed above\&.
.PP
A mask of fields which were actually sucessfully set (acquired from
/proc, etc\&.) can be retrieved with
\fBsd_bus_creds_get_mask()\fR\&. If the credentials object was created with
\fBsd_bus_creds_new_from_pid()\fR, this will be a subset of fields requested in
\fIcreds_mask\fR\&.
.PP
\fBsd_bus_creds_ref\fR
creates a new reference to the credentials object
\fIc\fR\&. This object will not be destroyed until
\fBsd_bus_creds_unref\fR
has been called as many times plus once more\&. Once the reference count has dropped to zero,
\fIc\fR
cannot be used anymore, so futher calls to
\fBsd_bus_creds_ref(c)\fR
or
\fBsd_bus_creds_unref(c)\fR
are illegal\&.
.PP
\fBsd_bus_creds_unref\fR
destroys a reference to
\fIc\fR\&.
.SH "RETURN VALUE"
.PP
On success,
\fBsd_bus_creds_new_from_pid()\fR
returns 0 or a positive integer\&. On failure, it returns a negative errno\-style error code\&.
.PP
\fBsd_bus_creds_get_mask()\fR
returns the mask of successfully acquired fields\&.
.PP
\fBsd_bus_creds_ref\fR
always returns the argument\&.
.PP
\fBsd_bus_creds_unref\fR
always returns
\fBNULL\fR\&.
.SH "REFERENCE OWNERSHIP"
.PP
Function
\fBsd_bus_creds_new_from_pid()\fR
creates a new object and the caller owns the sole reference\&. When not needed anymore, this reference should be destroyed with
\fBsd_bus_creds_unref\fR(3)\&.
.SH "ERRORS"
.PP
Returned errors may indicate the following problems:
.PP
\fI\-ESRCH\fR
.RS 4
Specified
\fIpid\fR
could not be found\&.
.RE
.PP
\fI\-EINVAL\fR
.RS 4
Specified parameter is invalid (\fBNULL\fR
in case of output parameters)\&.
.RE
.PP
\fI\-ENOMEM\fR
.RS 4
Memory allocation failed\&.
.RE
.SH "NOTES"
.PP
\fBsd_bus_creds_new_from_pid()\fR
is available as a shared library, which can be compiled and linked to with the
\fBlibsystemd\fR\ \&\fBpkg-config\fR(1)
file\&.
.SH "SEE ALSO"
.PP
\fBsystemd\fR(1),
\fBsd-bus\fR(3),
\fBsd_bus_creds_ref\fR(3),
\fBsd_bus_creds_unref\fR(3),
\fBsd_bus_creds_get_pid\fR(3),
\fBsd_bus_creds_get_pid_starttime\fR(3),
\fBsd_bus_creds_get_tid\fR(3),
\fBsd_bus_creds_get_uid\fR(3),
\fBsd_bus_creds_get_gid\fR(3),
\fBsd_bus_creds_get_comm\fR(3),
\fBsd_bus_creds_get_tid_comm\fR(3),
\fBsd_bus_creds_get_exe\fR(3),
\fBsd_bus_creds_get_cmdline\fR(3),
\fBsd_bus_creds_get_cgroup\fR(3),
\fBsd_bus_creds_get_unit\fR(3),
\fBsd_bus_creds_get_user_unit\fR(3),
\fBsd_bus_creds_get_slice\fR(3),
\fBsd_bus_creds_get_session\fR(3),
\fBsd_bus_creds_get_owner_uid\fR(3),
\fBsd_bus_creds_has_effective_cap\fR(3),
\fBsd_bus_creds_has_permitted_cap\fR(3),
\fBsd_bus_creds_has_inheritable_cap\fR(3),
\fBsd_bus_creds_has_bounding_cap\fR(3),
\fBsd_bus_creds_get_selinux_context\fR(3),
\fBsd_bus_creds_get_audit_session_id\fR(3),
\fBsd_bus_creds_get_audit_login_uid\fR(3),
\fBsd_bus_creds_get_unique_name\fR(3),
\fBsd_bus_creds_get_well_known_names\fR(3)