ladybird/Base/usr/share/man/man2/setuid.md
Liav A 5a649d0fd5 Kernel: Return EINVAL when specifying -1 for setuid and similar syscalls
For setreuid and setresuid syscalls, -1 means to set the current
uid/euid/gid/egid value, to be more convenient for programming.
However, for other syscalls where we pass only one argument, there's no
justification to specify -1.

This behavior is identical to how Linux handles the value -1, and is
influenced by the fact that the manual pages for the group of one
argument syscalls that handle ID operations is ambiguous about this
topic.
2021-12-20 11:32:16 +01:00

37 lines
915 B
Markdown

## Name
setuid, setgid - set user / group ID
## Synopsis
```**c++
#include <unistd.h>
int setuid(uid_t);
int setgid(gid_t);
```
## Description
Sets all of real, effective, and saved user or group ID to the given ID.
For non-superusers, the given ID has to be equal to the current real or effective ID for the call to succeed.
## Return value
If the call was set successful, returns 0.
Otherwise, returns -1 and sets `errno` to describe the error.
## Errors
* `EPERM`: The new ID is not equal to the real ID or effective ID, and the user is not superuser.
* `EINVAL`: The new ID is set to invalid value (-1).
## See also
* [`setuid_overview`(7)](../man7/setuid_overview.md)
* [`geteuid`(2) / `getegid`(2)](geteuid.md)
* [`getuid`(2) / `getgid`(2)](getuid.md)
* [`getresuid`(2) / `getresgid`(2)](getresuid.md)
* [`seteuid`(2) / `setegid`(2)](seteuid.md)
* [`setresuid`(2) / `setresgid`(2)](setresuid.md)