text
stringlengths 0
234
|
---|
the saved set-user-id will be set to the new effective user id. |
.pp |
completely analogously, |
.br setregid () |
sets real and effective group id's of the calling process, |
and all of the above holds with "group" instead of "user". |
.sh return value |
on success, zero is returned. |
on error, \-1 is returned, and |
.i errno |
is set to indicate the error. |
.pp |
.ir note : |
there are cases where |
.br setreuid () |
can fail even when the caller is uid 0; |
it is a grave security error to omit checking for a failure return from |
.br setreuid (). |
.sh errors |
.tp |
.b eagain |
the call would change the caller's real uid (i.e., |
.i ruid |
does not match the caller's real uid), |
but there was a temporary failure allocating the |
necessary kernel data structures. |
.tp |
.b eagain |
.i ruid |
does not match the caller's real uid and this call would |
bring the number of processes belonging to the real user id |
.i ruid |
over the caller's |
.b rlimit_nproc |
resource limit. |
since linux 3.1, this error case no longer occurs |
(but robust applications should check for this error); |
see the description of |
.b eagain |
in |
.br execve (2). |
.tp |
.b einval |
one or more of the target user or group ids |
is not valid in this user namespace. |
.tp |
.b eperm |
the calling process is not privileged |
(on linux, does not have the necessary capability in its user namespace: |
.b cap_setuid |
in the case of |
.br setreuid (), |
or |
.b cap_setgid |
in the case of |
.br setregid ()) |
and a change other than (i) |
swapping the effective user (group) id with the real user (group) id, |
or (ii) setting one to the value of the other or (iii) setting the |
effective user (group) id to the value of the |
saved set-user-id (saved set-group-id) was specified. |
.sh conforming to |
posix.1-2001, posix.1-2008, 4.3bsd |
.rb ( setreuid () |
and |
.br setregid () |
first appeared in 4.2bsd). |
.sh notes |
setting the effective user (group) id to the |
saved set-user-id (saved set-group-id) is |
possible since linux 1.1.37 (1.1.38). |
.pp |
posix.1 does not specify all of the uid changes that linux permits |
for an unprivileged process. |
for |
.br setreuid (), |
the effective user id can be made the same as the |
real user id or the saved set-user-id, |
and it is unspecified whether unprivileged processes may set the |
real user id to the real user id, the effective user id, or the |
saved set-user-id. |
for |
.br setregid (), |
the real group id can be changed to the value of the saved set-group-id, |
and the effective group id can be changed to the value of |
the real group id or the saved set-group-id. |
the precise details of what id changes are permitted vary |
across implementations. |
.pp |
posix.1 makes no specification about the effect of these calls |
on the saved set-user-id and saved set-group-id. |
.pp |
the original linux |
.br setreuid () |
and |
.br setregid () |
system calls supported only 16-bit user and group ids. |
subsequently, linux 2.4 added |
.br setreuid32 () |
and |