/[hurd]/hurd/libnetfs/io-restrict-auth.c
ViewVC logotype

Diff of /hurd/libnetfs/io-restrict-auth.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by roland, Sat Jun 16 20:37:39 2001 UTC revision 1.5 by roland, Sun May 5 03:26:30 2002 UTC
# Line 1  Line 1 
1  /*  /*
2     Copyright (C) 1995,96,2001 Free Software Foundation, Inc.     Copyright (C) 1995,96,2001,02 Free Software Foundation, Inc.
3     Written by Michael I. Bushnell, p/BSG.     Written by Michael I. Bushnell, p/BSG.
4    
5     This file is part of the GNU Hurd.     This file is part of the GNU Hurd.
# Line 21  Line 21 
21  #include "netfs.h"  #include "netfs.h"
22  #include "io_S.h"  #include "io_S.h"
23    
 static inline int  
 listmember (int *list, int query, int n)  
 {  
   int i;  
   for (i = 0; i < n; i++)  
     if (list[i] == query)  
       return 1;  
   return 0;  
 }  
   
24  error_t  error_t
25  netfs_S_io_restrict_auth (struct protid *user,  netfs_S_io_restrict_auth (struct protid *user,
26                            mach_port_t *newport,                            mach_port_t *newport,
# Line 41  netfs_S_io_restrict_auth (struct protid Line 31  netfs_S_io_restrict_auth (struct protid
31                            mach_msg_type_number_t ngids)                            mach_msg_type_number_t ngids)
32  {  {
33    error_t err;    error_t err;
   struct idvec *uvec, *gvec;  
   int i;  
34    struct protid *newpi;    struct protid *newpi;
35    struct iouser *new_user;    struct iouser *new_user;
36      
37    if (!user)    if (!user)
38      return EOPNOTSUPP;      return EOPNOTSUPP;
39      
40    if (idvec_contains (user->user->uids, 0))    err = iohelp_restrict_iouser (&new_user, user->user,
41      {                                  uids, nuids, gids, ngids);
42        err = iohelp_create_complex_iouser (&new_user, uids, nuids, gids, ngids);    if (err)
43        if (err)      return err;
44          return err;  
     }  
   else  
     {  
       uvec = make_idvec ();  
       if (! uvec)  
         return ENOMEM;  
   
       gvec = make_idvec ();  
       if (! gvec)  
         {  
           idvec_free (uvec);  
           return ENOMEM;  
         }  
   
       for (i = 0; i < user->user->uids->num; i++)  
         if (listmember (uids, user->user->uids->ids[i], nuids))  
           {  
             err = idvec_add (uvec, user->user->uids->ids[i]);  
             if (err)  
               goto out;  
           }  
         
       for (i = 0; i < user->user->gids->num; i++)  
         if (listmember (gids, user->user->gids->ids[i], ngids))  
           {  
             err = idvec_add (gvec, user->user->gids->ids[i]);  
             if (err)  
               goto out;  
           }  
   
       err = iohelp_create_iouser (&new_user, uvec, gvec);  
   
       if (err)  
         {  
         out:  
           idvec_free (uvec);  
           idvec_free (gvec);  
           return err;  
         }  
     }  
     
45    mutex_lock (&user->po->np->lock);    mutex_lock (&user->po->np->lock);
46    newpi = netfs_make_protid (user->po, new_user);    newpi = netfs_make_protid (user->po, new_user);
47    if (newpi)    if (newpi)
# Line 109  netfs_S_io_restrict_auth (struct protid Line 56  netfs_S_io_restrict_auth (struct protid
56        iohelp_free_iouser (new_user);        iohelp_free_iouser (new_user);
57        err = ENOMEM;        err = ENOMEM;
58      }      }
59      
60    ports_port_deref (newpi);    ports_port_deref (newpi);
61    return err;    return err;
62  }  }
   

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26