Back to index

glibc  2.9
Functions
seteuid.c File Reference
#include <errno.h>
#include <unistd.h>
#include <setxid.h>
#include <kernel-features.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int seteuid (uid_t uid)

Function Documentation

int seteuid ( uid_t  uid)

Definition at line 30 of file seteuid.c.

{
  int result;

  if (uid == (uid_t) ~0)
    {
      __set_errno (EINVAL);
      return -1;
    }

#if __ASSUME_32BITUIDS > 0
  result = INLINE_SETXID_SYSCALL (setresuid32, 3, -1, uid, -1);
#else
  /* First try the syscall.  */
# ifdef __NR_setresuid
  result = __setresuid (-1, uid, -1);
#  if __ASSUME_SETRESUID_SYSCALL > 0
  if (0)
#  else
  if (result == -1 && errno == ENOSYS)
#  endif
    /* No system call available.  Use emulation.  This may not work
       since `setreuid' also sets the saved user ID when UID is not
       equal to the real user ID, making it impossible to switch back.  */
# endif
    result = __setreuid (-1, uid);
#endif

  return result;
}