xref: /illumos-gate/usr/src/man/man3proc/proc_get_cred.3proc (revision dcbf3bd6a1f1360fc1afcee9e22c6dcff7844bf2)
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 May 11, 2016
15.Dt PROG_GET_CRED 3PROC
16.Os
17.Sh NAME
18.Nm proc_get_cred
19.Nd get process credentials
20.Sh SYNOPSIS
21.Lb libproc
22.In libproc.h
23.Ft int
24.Fo proc_get_cred
25.Fa "pid_t proc"
26.Fa "prcred_t *credp"
27.Fa "int ngroups"
28.Fc
29.Sh DESCRIPTION
30The
31.Fn proc_get_cred
32function is a convenient way to read the /proc cred file for the process
33.Fa proc .
34.Pp
35Up to
36.Fa ngroups
37supplemental groups will be read and written into
38.Fa credp
39in addition to the normal information. If
40.Fa ngroups
41is more than one, than it is up to the caller to have allocated enough
42space for
43.Fa credp .
44Callers could allocate it, using an expression similar to:
45.Pp
46.Dl credp = malloc(sizeof (prcred_t) + (ngroups - 1) * sizeof (gid_t));
47.Pp
48The definition of the
49.Sy prcred_t
50structure may be found in
51.Xr proc 4 .
52.Sh RETURN VALUES
53Upon successful completion, the
54.Fn proc_get_cred
55function returns
56.Sy 0 .
57Otherwise,
58.Sy -1
59is returned to indicate an error occurred.
60.Sh INTERFACE STABILITY
61.Sy Uncommitted
62.Sh MT-LEVEL
63.Sy MT-Safe
64.Sh SEE ALSO
65.Xr libproc 3LIB ,
66.Xr proc 4
67