Back to index

glibc  2.9
Functions
geteuids.c File Reference
#include <hurd.h>
#include <hurd/id.h>
#include <string.h>

Go to the source code of this file.

Functions

int geteuids (int n, uid_t *uidset)

Function Documentation

int geteuids ( int  n,
uid_t uidset 
)

Definition at line 24 of file geteuids.c.

{
  error_t err;
  int nuids;
  void *crit;

  crit = _hurd_critical_section_lock ();
  __mutex_lock (&_hurd_id.lock);

  if (err = _hurd_check_ids ())
    {
      __mutex_unlock (&_hurd_id.lock);
      _hurd_critical_section_unlock (crit);
      return __hurd_fail (err);
    }

  nuids = _hurd_id.gen.nuids;

  if (n != 0)
    {
      /* Copy the uids onto stack storage and then release the idlock.  */
      uid_t uids[nuids];
      memcpy (uids, _hurd_id.gen.uids, sizeof (uids));
      __mutex_unlock (&_hurd_id.lock);
      _hurd_critical_section_unlock (crit);

      /* Now that the lock is released, we can safely copy the
        uid set into the user's array, which might fault.  */
      if (nuids > n)
       nuids = n;
      memcpy (uidset, uids, nuids * sizeof (uid_t));
    }
  else
    {
      __mutex_unlock (&_hurd_id.lock);
      _hurd_critical_section_unlock (crit);
    }

  return nuids;
}

Here is the call graph for this function: