[Previous]
[Contents]
[Next]

seteuid()

set the effective user ID

Synopsis:

#include <unistd.h>
int seteuid( uid_t uid );

Description:

The seteuid() function allows the calling process to set the effective user ID. The real and saved user IDs aren't changed.

Returns:

0
Success
-1
An error occurred. errno is set to indicate the error.

Errors:

EINVAL
The value of uid is invalid.
EPERM
The process doesn't have appropriate privileges, and uid doesn't match the real user ID.

Examples:

/*
 * This process sets its effective userid to 0 (root).
 */
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>

void main()
  {
    uid_t oeuid;

    oeuid = geteuid();
    if( seteuid( 0 ) == -1 ) {
       perror( "seteuid" );
       exit( 1 );
    }
    printf( "Effective userid now 0, was %d\n",
        oeuid );
  }

Classification:

UNIX

Safety:
Interrupt handler No
Signal handler Yes, but modifies errno
Thread Yes

See also:

errno, setegid(), setuid(), setgid()


[Previous]
[Contents]
[Next]