setresuid(2)

setresuid2

Get or set real, effective and saved user or group id

Usage

#include <sys/types.h>

#include <unistd.h>

int

getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid);

int

getresuid(uid_t *ruid, uid_t *euid, uid_t *suid);

int

setresgid(gid_t rgid, gid_t egid, gid_t sgid);

int

setresuid(uid_t ruid, uid_t euid, uid_t suid);

Library

Standard C Library (libc, -lc)

Overview

The setresuid() system call sets the real, effective and saved user IDs of the current process. The analogous setresgid() sets the real, effective and saved group IDs.

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.

Passing -1 as an argument causes the corresponding value to remain unchanged.

The getresgid() and getresuid() calls retrieve the real, effective, and saved group and user IDs of the current process, respectively.

Return values

The getresgid() function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error.

Errors

[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.

[EFAULT]

An address passed to getresgid() or getresuid() was invalid.

Releases

70 releases since FreeBSD 4.0-RELEASE; the text changed 38 times.

  1. 4.0
  2. 4.1–4.2
  3. 4.3
  4. 4.4
  5. 4.5–4.11
  6. 5.0
  7. 5.1–6.3
  8. 6.4
  9. 7.0
  10. 7.1
  11. 7.2
  12. 7.3
  13. 7.4
  14. 8.0
  15. 8.1
  16. 8.2
  17. 8.3
  18. 8.4
  19. 9.0
  20. 9.1
  21. 9.2
  22. 9.3
  23. 10.0
  24. 10.1
  25. 10.2
  26. 10.3
  27. 10.4
  28. 11.0
  29. 11.1
  30. 11.2
  31. 11.3
  32. 11.4
  33. 12.0
  34. 12.1
  35. 12.2
  36. 12.3
  37. 12.4
  38. 13.0–13.2
  39. 13.3–16.0

History

These functions first appeared in HP-UX.

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.