summaryrefslogtreecommitdiff
path: root/lib/libc/sys/setresuid.2
blob: 074463be507d1303e1c453257345e3d50ab86314 (plain)
1
2
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
.\" $OpenBSD: setresuid.2,v 1.7 2013/08/14 06:32:29 jmc Exp $
.\"
.\" Copyright (c) 2000
.\"      Sheldon Hearn.  All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES
.\"
.\" $FreeBSD: src/lib/libc/sys/setresuid.2,v 1.12 2001/10/01 16:09:02 ru Exp $
.\"
.Dd $Mdocdate: August 14 2013 $
.Dt SETRESUID 2
.Os
.Sh NAME
.Nm getresgid ,
.Nm getresuid ,
.Nm setresgid ,
.Nm setresuid
.Nd get or set real, effective and saved user or group ID
.Sh SYNOPSIS
.Fd #include <sys/types.h>
.Fd #include <unistd.h>
.Ft int
.Fn getresgid "gid_t *rgid" "gid_t *egid" "gid_t *sgid"
.Ft int
.Fn getresuid "uid_t *ruid" "uid_t *euid" "uid_t *suid"
.Ft int
.Fn setresgid "gid_t rgid" "gid_t egid" "gid_t sgid"
.Ft int
.Fn setresuid "uid_t ruid" "uid_t euid" "uid_t suid"
.Sh DESCRIPTION
The
.Fn setresuid
function sets the real,
effective and saved user IDs of the current process.
The analogous
.Fn setresgid
sets the real, effective and saved group IDs.
.Pp
Privileged processes may set these IDs to arbitrary values.
Unprivileged processes are restricted
in that each of the new IDs must match one of the current IDs.
.Pp
Passing \-1 as an argument causes the corresponding value
to remain unchanged.
.Pp
The
.Fn getresgid
and
.Fn getresuid
calls retrieve the real, effective, and saved group and user IDs of
the current process, respectively.
.Sh RETURN VALUES
Upon successful completion, a value of 0 is returned.
Otherwise, a value of \-1 is returned and
.Va errno
is set to indicate the error.
.Sh ERRORS
.Bl -tag -width Er
.It Bq Er EPERM
The calling process was not privileged and tried to change one or
more IDs to a value which was not the current real ID, the current
effective ID nor the current saved ID.
.It Bq Er EFAULT
An address passed to
.Fn getresgid
or
.Fn getresuid
was invalid.
.El
.Sh SEE ALSO
.Xr getegid 2 ,
.Xr geteuid 2 ,
.Xr getgid 2 ,
.Xr getuid 2 ,
.Xr issetugid 2 ,
.Xr setgid 2 ,
.Xr setregid 2 ,
.Xr setreuid 2 ,
.Xr setuid 2
.Sh STANDARDS
These functions are not part of the
.St -p1003.1
specification.
While they are not completely portable, they are the least ambiguous way to
manage user and group IDs.
.Sh HISTORY
These functions first appeared in HP-UX.