1.\" $OpenBSD: setresuid.2,v 1.10 2024/08/02 22:14:54 guenther Exp $ 2.\" 3.\" Copyright (c) 2000 4.\" Sheldon Hearn. All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 15.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20.\" DAMAGES 21.\" 22.\" $FreeBSD: src/lib/libc/sys/setresuid.2,v 1.12 2001/10/01 16:09:02 ru Exp $ 23.\" 24.Dd $Mdocdate: August 2 2024 $ 25.Dt SETRESUID 2 26.Os 27.Sh NAME 28.Nm getresgid , 29.Nm getresuid , 30.Nm setresgid , 31.Nm setresuid 32.Nd get or set real, effective and saved user or group ID 33.Sh SYNOPSIS 34.In unistd.h 35.Ft int 36.Fn getresgid "gid_t *rgid" "gid_t *egid" "gid_t *sgid" 37.Ft int 38.Fn getresuid "uid_t *ruid" "uid_t *euid" "uid_t *suid" 39.Ft int 40.Fn setresgid "gid_t rgid" "gid_t egid" "gid_t sgid" 41.Ft int 42.Fn setresuid "uid_t ruid" "uid_t euid" "uid_t suid" 43.Sh DESCRIPTION 44The 45.Fn setresuid 46function sets the real, 47effective and saved user IDs of the current process. 48The analogous 49.Fn setresgid 50sets the real, effective and saved group IDs. 51.Pp 52Privileged processes may set these IDs to arbitrary values. 53Unprivileged processes are restricted 54in that each of the new IDs must match one of the current IDs. 55.Pp 56Passing \-1 as an argument causes the corresponding value 57to remain unchanged. 58.Pp 59The 60.Fn getresgid 61and 62.Fn getresuid 63calls retrieve the real, effective, and saved group and user IDs of 64the current process, respectively. 65.Sh RETURN VALUES 66.Rv -std 67.Sh ERRORS 68.Bl -tag -width Er 69.It Bq Er EPERM 70The calling process was not privileged and tried to change one or 71more IDs to a value which was not the current real ID, the current 72effective ID nor the current saved ID. 73.It Bq Er EFAULT 74An address passed to 75.Fn getresgid 76or 77.Fn getresuid 78was invalid. 79.El 80.Sh SEE ALSO 81.Xr getegid 2 , 82.Xr geteuid 2 , 83.Xr getgid 2 , 84.Xr getuid 2 , 85.Xr issetugid 2 , 86.Xr setgid 2 , 87.Xr setregid 2 , 88.Xr setreuid 2 , 89.Xr setuid 2 90.Sh STANDARDS 91The 92.Fn getresgid , 93.Fn getresuid , 94.Fn setresgid , 95and 96.Fn setresuid 97functions conform to the X/Open System Interfaces option of 98.St -p1003.1-2024 . 99.Sh HISTORY 100These functions first appeared in HP-UX. 101