(_hurd_msgport_receive): Unlock self sigstate lock after getting it.
[kopensolaris-gnu/glibc.git] / hurd / hurdauth.c
index e14075e..b4e2cb8 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
 This file is part of the GNU C Library.
 
 The GNU C Library is free software; you can redistribute it and/or
@@ -17,32 +17,49 @@ not, write to the Free Software Foundation, Inc., 675 Mass Ave,
 Cambridge, MA 02139, USA.  */
 
 #include <hurd.h>
+#include <hurd/msg_server.h>
+#include <hurd/id.h>
 
-error_t
-__add_auth (mach_port_t me,
-           auth_t addauth)
+int
+_hurd_refport_secure_p (mach_port_t ref)
+{
+  if (ref == __mach_task_self ())
+    return 1;
+  if (__USEPORT (AUTH, ref == port))
+    return 1;
+  return 0;
+}
+
+kern_return_t
+_S_add_auth (mach_port_t me,
+            auth_t addauth)
 {
   error_t err;
   auth_t newauth;
 
-  if (err = __USEPORT (AUTH, __auth_combine (port, addauth, &newauth)))
+  if (err = __USEPORT (AUTH,
+                      __auth_makeauth (port,
+                                       &addauth, 1, MACH_MSG_TYPE_MOVE_SEND,
+                                       NULL, 0,
+                                       NULL, 0,
+                                       NULL, 0,
+                                       NULL, 0,
+                                       &newauth)))
     return err;
 
-  /* XXX clobbers errno. Need per-thread errno. */
   err = __setauth (newauth);
   __mach_port_deallocate (__mach_task_self (), newauth);
   if (err)
     return errno;
 
-  __mach_port_deallocate (__mach_task_self (), addauth);
   return 0;
 }
 
-error_t
-__del_auth (mach_port_t me,
-           task_t task,
-           uid_t *uids, mach_msg_type_number_t nuids,
-           gid_t *gids, mach_msg_type_number_t ngids)
+kern_return_t
+_S_del_auth (mach_port_t me,
+            task_t task,
+            intarray_t uids, mach_msg_type_number_t nuids,
+            intarray_t gids, mach_msg_type_number_t ngids)
 {
   error_t err;
   auth_t newauth;
@@ -50,6 +67,7 @@ __del_auth (mach_port_t me,
   if (!_hurd_refport_secure_p (task))
     return EPERM;
 
+  HURD_CRITICAL_BEGIN;
   __mutex_lock (&_hurd_id.lock);
   err = _hurd_check_ids ();
 
@@ -89,6 +107,7 @@ __del_auth (mach_port_t me,
 
       err = __USEPORT (AUTH, __auth_makeauth
                       (port,
+                       NULL, 0, MACH_MSG_TYPE_COPY_SEND,
                        newu, nu,
                        _hurd_id.aux.uids, _hurd_id.aux.nuids,
                        newg, ng,
@@ -96,11 +115,12 @@ __del_auth (mach_port_t me,
                        &newauth));
     }
   __mutex_unlock (&_hurd_id.lock);
+  HURD_CRITICAL_END;
 
   if (err)
     return err;
 
-  err = __setauth (newauth);   /* XXX clobbers errno */
+  err = __setauth (newauth);
   __mach_port_deallocate (__mach_task_self (), newauth);
   if (err)
     return errno;