[Previous]
[Contents]
[Next]

qnx_setids()

change the real and effective user and group IDs of a process

Synopsis:

#include <sys/types.h>
#include <sys/proc_msg.h>
#include <unistd.h>
int qnx_setids( pid_t pid,
                int id,
                unsigned subtype );

Description:

The qnx_setids() function allows you to change the real and effective user or group ID of the process, identified by pid, to id. If pid is zero, the current process is used. The subtype parameter determines what's changed as follows:

_PROC_SUB_SETUID
Set the user id, as defined by the setuid() function.
_PROC_SUB_SETGID
Set the group id, as defined by the setgid() function.
_PROC_SUB_SETEUID
Set the user id, as defined by the seteuid() function.
_PROC_SUB_SETEGID
Set the group id, as defined by the setegid() function.

The referenced POSIX functions call this function with pid set to zero.

Returns:

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

Errors:

EINVAL
The value of id or subtype is invalid.
EPERM
The process doesn't have appropriate privileges.
ESRCH
The pid is invalid.

Examples:

/*
 * change my effective group id
 */
#include <stdio.h>
#include <sys/types.h>
#include <sys/proc_msg.h>
#include <unistd.h>

void main()
  {
    if( qnx_setids( 0, 4, _PROC_SUB_SETEUID ) != -1 )
      fprintf( stderr, "Unable to change.\n" );
  }

Classification:

POSIX

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

See also:

errno, qnx_getids(), qnx_psinfo(), setuid(), setgid(), seteuid(), setegid()


[Previous]
[Contents]
[Next]