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 PR_GETPEERUCRED 3PROC 16.Os 17.Sh NAME 18.Nm pr_getpeerucred 19.Nd inject getpeerucred library call into victim process 20.Sh LIBRARY 21.Lb libproc 22.Sh SYNOPSIS 23.In libproc.h 24.Ft int 25.Fo pr_getpeerucred 26.Fa "struct ps_prochandle *P" 27.Fa "int fd" 28.Fa "ucred_t **ucp" 29.Fc 30.Sh DESCRIPTION 31The 32.Fn pr_getpeerucred 33function injects the 34.Xr getpeerucred 3C 35library call into the target process 36.Fa P 37by means of the agent LWP. 38If the process handle 39.Fa P 40is 41.Dv NULL 42then this is equivalent to calling 43.Xr getpeerucred 3C 44on the currently running process. 45.Pp 46The arguments 47.Fa fd 48and 49.Fa *ucp 50have the same meaning as in 51.Xr getpeerucred 3C . 52See 53.Xr getpeerucred 3C 54for the full description and purpose of the 55.Sy getpeerucred 56library call and its arguments. 57.Pp 58The 59.Fn pr_getpeerucred 60function only works on active processes. 61Process handles that correspond to core files, zombie processes, or ELF objects 62do not support library call injection. 63.Sh RETURN VALUES 64Upon successful completion, the 65.Fn pr_getpeerucred 66function's return value is that described in 67.Xr getpeerucred 3C . 68Otherwise, 69.Sy -1 70is returned and 71.Sy errno 72is set to 73.Er ENOSYS 74to indicate that the library call could not be injected. 75.Sh ERRORS 76For a full list of possible errors see the 77.Sy ERRORS 78section in 79.Xr getpeerucred 3C . 80.Pp 81The 82.Fn pr_getpeerucred 83function will fail if: 84.Bl -tag -width Er 85.It Er ENOSYS 86An error occurred while trying to invoke the agent LWP and inject a 87library call in the process handle 88.Fa P 89or the process handle 90.Fa P 91does not support library call injection. 92.El 93.Sh INTERFACE STABILITY 94.Sy Uncommitted 95.Sh MT-LEVEL 96See 97.Sy LOCKING 98in 99.Xr libproc 3LIB . 100.Sh SEE ALSO 101.Xr getpeerucred 3C , 102.Xr libproc 3LIB , 103.Xr proc 5 104