xref: /illumos-gate/usr/src/man/man3proc/proc_get_cred.3proc (revision e82490700e19f1b8a2cef6102f4726144d281988)
1.\"
2.\" This file and its contents are supplied under the terms of the
3.\" Common Development and Distribution License ("CDDL"), version 1.0.
4.\" You may only use this file in accordance with the terms of version
5.\" 1.0 of the CDDL.
6.\"
7.\" A full copy of the text of the CDDL should have accompanied this
8.\" source.  A copy of the CDDL is also available via the Internet at
9.\" http://www.illumos.org/license/CDDL.
10.\"
11.\"
12.\" Copyright 2015 Joyent, Inc.
13.\"
14.Dd November 27, 2023
15.Dt PROG_GET_CRED 3PROC
16.Os
17.Sh NAME
18.Nm proc_get_cred
19.Nd get process credentials
20.Sh LIBRARY
21.Lb libproc
22.Sh SYNOPSIS
23.In libproc.h
24.Ft int
25.Fo proc_get_cred
26.Fa "pid_t proc"
27.Fa "prcred_t *credp"
28.Fa "int ngroups"
29.Fc
30.Sh DESCRIPTION
31The
32.Fn proc_get_cred
33function is a convenient way to read the /proc cred file for the process
34.Fa proc .
35.Pp
36Up to
37.Fa ngroups
38supplemental groups will be read and written into
39.Fa credp
40in addition to the normal information.
41If
42.Fa ngroups
43is more than one, than it is up to the caller to have allocated enough
44space for
45.Fa credp .
46Callers could allocate it, using an expression similar to:
47.Pp
48.Dl credp = malloc(sizeof (prcred_t) + (ngroups - 1) * sizeof (gid_t));
49.Pp
50The definition of the
51.Sy prcred_t
52structure may be found in
53.Xr proc 5 .
54.Sh RETURN VALUES
55Upon successful completion, the
56.Fn proc_get_cred
57function returns
58.Sy 0 .
59Otherwise,
60.Sy -1
61is returned to indicate an error occurred.
62.Sh INTERFACE STABILITY
63.Sy Uncommitted
64.Sh MT-LEVEL
65.Sy MT-Safe
66.Sh SEE ALSO
67.Xr libproc 3LIB ,
68.Xr proc 5
69