summaryrefslogtreecommitdiff
path: root/libfshelp
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2001-07-03 01:10:17 +0000
committerRoland McGrath <roland@gnu.org>2001-07-03 01:10:17 +0000
commitcfdf7c3ded1e3165ae643a740a4a0425cecdadcb (patch)
tree9e86c8233b18bd0cf268c48bf9b163494483fa2b /libfshelp
parentb5f0edcc31bbdb8969404b409311c29240281c24 (diff)
2001-06-21 Neal H Walfield <neal@cs.uml.edu>
* fshelp.h (fshelp_iscontroller): Declare new function. * perms-iscontroller.c: New file. * Makefile (SRCS): Add it.
Diffstat (limited to 'libfshelp')
-rw-r--r--libfshelp/Makefile3
-rw-r--r--libfshelp/fshelp.h9
-rw-r--r--libfshelp/perms-iscontroller.c38
3 files changed, 48 insertions, 2 deletions
diff --git a/libfshelp/Makefile b/libfshelp/Makefile
index 6dc47da6..11c14985 100644
--- a/libfshelp/Makefile
+++ b/libfshelp/Makefile
@@ -27,7 +27,8 @@ SRCS = lock-acquire.c lock-init.c \
exec-reauth.c \
set-options.c \
get-identity.c \
- perms-isowner.c perms-access.c perms-checkdirmod.c \
+ perms-isowner.c perms-iscontroller.c perms-access.c \
+ perms-checkdirmod.c \
touch.c
LCLHDRS = fshelp.h locks.h trans.h
installhdrs = fshelp.h
diff --git a/libfshelp/fshelp.h b/libfshelp/fshelp.h
index 81e1fadb..88f63b69 100644
--- a/libfshelp/fshelp.h
+++ b/libfshelp/fshelp.h
@@ -1,5 +1,5 @@
/* FS helper library definitions
- Copyright (C) 1994,95,96,97,98,99,2000 Free Software Foundation, Inc.
+ Copyright (C) 1994,95,96,97,98,99,2000,01 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -238,6 +238,13 @@ error_t fshelp_set_options (struct argp *argp, int flags,
appropriate error code. */
error_t fshelp_isowner (struct stat *st, struct iouser *user);
+/* Check to see whether USER should be considered a controller of the
+ filesystem. Which is to say, check to see if we should give USER the
+ control port. ST is the stat of the root node. USER is the user
+ asking for a send right to the control port. */
+error_t
+fshelp_iscontroller (struct stat *st, struct iouser *user);
+
/* Check to see whether the user USER can operate on a file identified
by ST. OP is one of S_IREAD, S_IWRITE, and S_IEXEC. If the access
is permitted, return zero; otherwise return an appropriate error
diff --git a/libfshelp/perms-iscontroller.c b/libfshelp/perms-iscontroller.c
new file mode 100644
index 00000000..456da2a2
--- /dev/null
+++ b/libfshelp/perms-iscontroller.c
@@ -0,0 +1,38 @@
+/* see whether a user should be considered a controller of the filesystem
+ Copyright (C) 2001 Free Software Foundation, Inc.
+ Written by Neal H Walfield <neal@cs.uml.edu>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ The GNU Hurd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
+
+#include <unistd.h>
+#include "fshelp.h"
+
+/* Check to see whether USER should be considered a controller of the
+ filesystem. Which is to say, check to see if we should give USER the
+ control port. ST is the stat of the root node. USER is the user
+ asking for a send right to the control port. */
+error_t
+fshelp_iscontroller (struct stat *st, struct iouser *user)
+{
+ /* Permitted if USER has the superuser uid, the owner uid or if the
+ USER has authority over the process's effective id. */
+ if (idvec_contains (user->uids, st->st_uid)
+ || idvec_contains (user->uids, st->st_uid)
+ || idvec_contains (user->uids, geteuid ()))
+ return 0;
+ return EPERM;
+}