Back to index

glibc  2.9
setgroups.c File Reference
#include <errno.h>
#include <sys/types.h>
#include <grp.h>
#include <hurd.h>
#include <hurd/id.h>

Go to the source code of this file.


int setgroups (size_t n, const gid_t *groups)

Function Documentation

int setgroups ( size_t  n,
const gid_t groups 

Definition at line 27 of file setgroups.c.

  error_t err;
  auth_t newauth;
  size_t i;
  gid_t new[n];

  /* Fault before taking locks.  */
  for (i = 0; i < n; ++i)
    new[i] = groups[i];

  __mutex_lock (&_hurd_id.lock);
  err = _hurd_check_ids ();
  if (! err)
      /* Get a new auth port using those IDs.  */
      err = __USEPORT (AUTH,
                     __auth_makeauth (port, NULL, MACH_MSG_TYPE_COPY_SEND, 0,
                                   _hurd_id.gen.uids, _hurd_id.gen.nuids,
                                   _hurd_id.aux.uids, _hurd_id.aux.nuids,
                                   new, n,
                                   _hurd_id.aux.gids, _hurd_id.aux.ngids,
  __mutex_unlock (&_hurd_id.lock);

  if (err)
    return __hurd_fail (err);

  /* Install the new auth port and reauthenticate everything.  */
  err = __setauth (newauth);
  __mach_port_deallocate (__mach_task_self (), newauth);
  return err;

Here is the call graph for this function: