Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ setuid(2) — CX/UX 6.20

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

getuid(2)

setuid(3C)

setreuid(2)

exec(2)

intro(2)

setuid(2)  —  AT&T SYSTEM V

NAME

setuid, setgid − set user and group IDs

SYNOPSIS

#include <sys/types.h>
 
uid_t setuid (uid)
uid_t uid;

gid_t setgid (gid)
gid_t gid;

DESCRIPTION

The function setuid is used to set the real user ID and effective user ID of the calling process. 

If the effective user ID of the calling process is super-user, the real user ID, the effective user ID and the saved set-user-ID from exec(2) are set to uid. 

If the effective user ID of the calling process is not super-user, then setuid behaves as follows.  If uid is equal to the real user ID of the current process or if uid is equal to the saved set-user-ID from exec(2), the effective user ID is set to uid. 

The function setgid is used to set the real group ID and effective group ID of the calling process. 

If the effective user ID of the calling process is super-user, the real group ID, the effective group ID and the saved set-group-ID from exec(2) are set to gid. 

If the effective user ID of the calling process is not super-user, then setgid behaves as follows.  If gid is equal to the real group ID of the current process or if gid is equal to the saved set-group-ID from exec(2), the effective group ID is set to gid. 

RETURN VALUE

Upon successful completion, a value of 0 is returned.  Otherwise, a value of −1 is returned and errno is set to indicate the error. 

ERRORS

The function setuid will fail and set errno to:

[EPERM] if the real user ID of the calling process is not equal to uid, and the saved set-user-ID from exec(2) is not equal to uid, and its effective user ID is not super-user. 

[EINVAL] if the uid is out of range. 

The function setgid will fail and set errno to:

[EPERM] if the real group ID of the calling process is not equal to gid, and the saved set-group-ID from exec(2) is not equal to gid, and its effective user ID is not super-user. 

[EINVAL] The gid is out of range. 

SEE ALSO

getuid(2), setuid(3C), setreuid(2), exec(2), intro(2). 

CX/UX Programmer’s Reference Manual

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026