setruid(3)

setruid3

Set user and group id

Usage

#include <unistd.h>

int

setruid(uid_t ruid);

int

setrgid(gid_t rgid);

Library

Standard C Library (libc, -lc)

Overview

The setruid() function (setrgid()) sets the real user ID (group ID) of the current process.

Return values

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

Compatibility

The use of these calls is not portable. Their use is discouraged; they will be removed in the future.

Errors

The functions fail if:

[EPERM]

The user is not the super user and the ID specified is not the real or effective ID.

Releases

163 releases since Mac OS X 10.0; the text changed 3 times.

  1. 10.0–10.1.5
  2. 10.2–10.2.8
  3. 10.3–10.6.8
  4. 10.7–26.5

History

The setruid() and setrgid() syscalls appeared in 4.2BSD and were dropped in 4.4BSD.

From Libc 1752.120.2 in macOS 26.5. Parsed by carta from the page's mdoc source.