diff options
Diffstat (limited to 'libnetfs/file-getcontrol.c')
-rw-r--r-- | libnetfs/file-getcontrol.c | 43 |
1 files changed, 16 insertions, 27 deletions
diff --git a/libnetfs/file-getcontrol.c b/libnetfs/file-getcontrol.c index ccbd7541..50401f86 100644 --- a/libnetfs/file-getcontrol.c +++ b/libnetfs/file-getcontrol.c @@ -1,6 +1,6 @@ /* Return the filesystem corresponding to a file - Copyright (C) 1995, 1996 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 2001 Free Software Foundation, Inc. Written by Michael I. Bushnell, p/BSG. This file is part of the GNU Hurd. @@ -21,6 +21,7 @@ #include "netfs.h" #include "fsys_S.h" +#include <hurd/fshelp.h> error_t netfs_S_file_getcontrol (struct protid *user, @@ -29,34 +30,22 @@ netfs_S_file_getcontrol (struct protid *user, { error_t err; struct port_info *pi; - uid_t *uids, *gids; - int nuids, ngids; - int i; if (!user) return EOPNOTSUPP; - mutex_lock (&user->po->np->lock); - netfs_interpret_credential (user->credential, &uids, &nuids, &gids, &ngids); - mutex_unlock (&user->po->np->lock); - free (gids); - - for (i = 0; i < nuids; i++) - if (uids[i] == 0) - { - /* They've got root; give it to them. */ - free (uids); - err = ports_create_port (netfs_control_class, netfs_port_bucket, - sizeof (struct port_info), &pi); - if (err) - return err; - *control = ports_get_right (pi); - *controltype = MACH_MSG_TYPE_MAKE_SEND; - ports_port_deref (pi); - return 0; - } - - /* Not got root. */ - free (uids); - return EPERM; + err = fshelp_iscontroller (&netfs_root_node->nn_stat, user->user); + if (err) + return err; + + /* They've have the appropriate credentials; give it to them. */ + err = ports_create_port (netfs_control_class, netfs_port_bucket, + sizeof (struct port_info), &pi); + if (err) + return err; + + *control = ports_get_right (pi); + *controltype = MACH_MSG_TYPE_MAKE_SEND; + ports_port_deref (pi); + return 0; } |