Back to index

glibc  2.9
Functions
setegid.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 setegid (gid_t gid)

Function Documentation

int setegid ( gid_t  gid)

Definition at line 31 of file setegid.c.

{
  int result;

  if (gid == (gid_t) ~0)
    {
      __set_errno (EINVAL);
      return -1;
    }

#if __ASSUME_32BITUIDS > 0
  result = INLINE_SETXID_SYSCALL (setresgid32, 3, -1, gid, -1);
#else
  /* First try the syscall.  */
# ifdef __NR_setresgid
  result = __setresgid (-1, gid, -1);
#  if __ASSUME_SETRESGID_SYSCALL > 0
  if (0)
#  else
  if (result == -1 && errno == ENOSYS)
#  endif
    /* No system call available.  Use emulation.  This may not work
       since `setregid' also sets the saved user ID when GID is not
       equal to the real user ID, making it impossible to switch back.  */
# endif
    result = __setregid (-1, gid);
#endif

  return result;
}