HPlogo MPE/iX Developer's Kit Reference Manual Volume I: HP 3000 MPE/iX Computer Systems > Chapter 4  POSIX/iX Library Function Descriptions

setuid

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

Sets user IDs.

Syntax

   #include <sys/types.h>

   init setuid(uid_t uid);

Parameters

uid

The ID of a user.

Return Values

Upon successful completion, a value of zero is returned. If unsuccessful, a value of -1 is returned and errno is set to indicate the error.

Description

If {_POSIX_SAVED_IDS} is defined:

If the process has appropriate privileges, the setuid() function sets the real user ID, effective user ID, and the saved set-user-ID to uid.

If the process does not have appropriate privileges, but uid is equal to the real user ID or the saved set-user-ID , the setuid() function sets the effective user ID to uid; the real user ID and saved set-user-ID remain unchanged by this functioncall.

Otherwise:

If the process has appropriate privileges, the setuid() function sets the real user ID and effective user ID to uid.

If the process does not have appropriate privileges, but uid is equal to the real user ID, the setuid() function sets the effective user ID to uid; the real user ID remains unchanged by this function call.

If the process does not have appropriate privileges, but gid is equal to the real group ID, the setgid() functionsets the effective group ID to gid; the real group ID remains unchanged by this function call.

Implementation Considerations

None.

Errors

If any of the following conditions occur, the setuid() function shall return -1 and set errno to the corresponding value:

EINVALCAUSE The signal sig is not a valid signal number, or pid is -1.
 ACTION Refer to Table 3-6 “POSIX/iX Signals” for descriptions of valid signal numbers, or set pid to a valid value.
EPERMCAUSE The caller does not have permission to send the signal to any receiving process.
 ACTION Refer to the kill() function description for signal permission rules.

If any of the following conditions occur, the setgid() function shall return -1 and set errno to the corresponding value:

EINVALCAUSEThe signal sig is not a valid signal number, or pid is -1.
 ACTIONRefer to Table 3-6 “POSIX/iX Signals” for descriptions of valid signal numbers, or set pid to a valid value.
EPERMCAUSEThe caller does not have permission to send the signal to any receiving process.
 ACTIONRefer to the kill() function description for signal permission rules.

See Also

exec(), getuid(), POSIX.1 (Section 3.3.2).

Feedback to webmaster