summaryrefslogtreecommitdiff
path: root/libfshelp
diff options
context:
space:
mode:
authorThomas Bushnell <thomas@gnu.org>1999-07-01 21:04:27 +0000
committerThomas Bushnell <thomas@gnu.org>1999-07-01 21:04:27 +0000
commit1f6601e1a657d7008f6c15fca71d2dc092f7cb78 (patch)
treefb40807ecbba849f1c1eb62f74c08b7d93d0cad3 /libfshelp
parent087058d53edc32dc9f0fc886c940e264a911a299 (diff)
1999-07-01 Thomas Bushnell, BSG <tb@mit.edu>
* translated.c: New file; guts from fshelp.h. * perms-isowner.c: Likewise. * perms-access.c: Likewise. * prems-checkdirmod.c: Likewise. * touch.c: Likewise. * fshelp.h (fshelp_translated, fshelp_isowner, fshelp_access, fshelp_checkdirmod, fshelp_touch): Replace inline definitions with ordinary declarations. (FSHELP_EI): Removed macro. * fshelp.c: Deleted file. * Makefile (SRCS): Added translated.c, perms-isowner.c, perms-access.c, perms-checkdirmod.c, touch.c. Removed fshelp.c.
Diffstat (limited to 'libfshelp')
-rw-r--r--libfshelp/ChangeLog15
-rw-r--r--libfshelp/Makefile7
-rw-r--r--libfshelp/fshelp.c2
-rw-r--r--libfshelp/fshelp.h90
-rw-r--r--libfshelp/perms-access.c43
-rw-r--r--libfshelp/perms-checkdirmod.c44
-rw-r--r--libfshelp/perms-isowner.c39
-rw-r--r--libfshelp/touch.c48
-rw-r--r--libfshelp/translated.c28
9 files changed, 229 insertions, 87 deletions
diff --git a/libfshelp/ChangeLog b/libfshelp/ChangeLog
index ec1b5cfe..a8905c7c 100644
--- a/libfshelp/ChangeLog
+++ b/libfshelp/ChangeLog
@@ -1,3 +1,18 @@
+1999-07-01 Thomas Bushnell, BSG <tb@mit.edu>
+
+ * translated.c: New file; guts from fshelp.h.
+ * perms-isowner.c: Likewise.
+ * perms-access.c: Likewise.
+ * prems-checkdirmod.c: Likewise.
+ * touch.c: Likewise.
+ * fshelp.h (fshelp_translated, fshelp_isowner, fshelp_access,
+ fshelp_checkdirmod, fshelp_touch): Replace inline definitions with
+ ordinary declarations.
+ (FSHELP_EI): Removed macro.
+ * fshelp.c: Deleted file.
+ * Makefile (SRCS): Added translated.c, perms-isowner.c,
+ perms-access.c, perms-checkdirmod.c, touch.c. Removed fshelp.c.
+
Wed Apr 28 03:06:19 1999 Thomas Bushnell, BSG <tb@mit.edu>
* fetch-root.c (fshelp_fetch_root): Don't deallocate the
diff --git a/libfshelp/Makefile b/libfshelp/Makefile
index 96e9b621..6dc47da6 100644
--- a/libfshelp/Makefile
+++ b/libfshelp/Makefile
@@ -1,5 +1,5 @@
#
-# Copyright (C) 1994, 95, 96, 98 Free Software Foundation, Inc.
+# Copyright (C) 1994, 95, 96, 98, 1999 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
@@ -22,12 +22,13 @@ libname = libfshelp
SRCS = lock-acquire.c lock-init.c \
start-translator-long.c start-translator.c \
fetch-root.c transbox-init.c set-active.c fetch-control.c \
- drop-transbox.c \
+ drop-transbox.c translated.c \
delegate.c \
exec-reauth.c \
set-options.c \
get-identity.c \
- fshelp.c
+ perms-isowner.c perms-access.c perms-checkdirmod.c \
+ touch.c
LCLHDRS = fshelp.h locks.h trans.h
installhdrs = fshelp.h
diff --git a/libfshelp/fshelp.c b/libfshelp/fshelp.c
deleted file mode 100644
index 49477bd3..00000000
--- a/libfshelp/fshelp.c
+++ /dev/null
@@ -1,2 +0,0 @@
-#define FSHELP_EI
-#include "fshelp.h"
diff --git a/libfshelp/fshelp.h b/libfshelp/fshelp.h
index 9218b1e6..9fe8fcfc 100644
--- a/libfshelp/fshelp.h
+++ b/libfshelp/fshelp.h
@@ -1,5 +1,5 @@
/* FS helper library definitions
- Copyright (C) 1994, 95, 96, 97, 98 Free Software Foundation, Inc.
+ Copyright (C) 1994, 95, 96, 97, 98, 1999 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
@@ -31,10 +31,6 @@
#include <sys/stat.h>
#include <maptime.h>
-#ifndef FSHELP_EI
-#define FSHELP_EI extern inline
-#endif
-
/* Passive translator linkage */
/* These routines are self-contained and start passive translators,
@@ -141,11 +137,7 @@ fshelp_transbox_init (struct transbox *transbox,
void *cookie);
/* Return true iff there is an active translator on this box */
-FSHELP_EI int
-fshelp_translated (struct transbox *box)
-{
- return (box->active != MACH_PORT_NULL);
-}
+int fshelp_translated (struct transbox *box);
/* Atomically replace the existing active translator port for this box
with NEWACTIVE. If EXCL is non-zero then don't frob an existing
@@ -240,64 +232,21 @@ error_t fshelp_set_options (struct argp *argp, int flags,
/* Check to see whether USER should be considered the owner of the
file identified by ST. If so, return zero; otherwise return an
appropriate error code. */
-FSHELP_EI error_t
-fshelp_isowner (struct stat *st, struct iouser *user)
-{
- /* Permitted if the user has the owner UID, the superuser UID, or if
- the user is in the group of the file and has the group ID as
- their user ID. */
- if (idvec_contains (user->uids, st->st_uid)
- || idvec_contains (user->uids, 0)
- || (idvec_contains (user->gids, st->st_gid)
- && idvec_contains (user->uids, st->st_gid)))
- return 0;
- else
- return EPERM;
-}
-
+error_t fshelp_isowner (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
code. */
-FSHELP_EI error_t
-fshelp_access (struct stat *st, int op, struct iouser *user)
-{
- int gotit;
- if (idvec_contains (user->uids, 0))
- gotit = 1;
- else if (user->uids->num == 0 && (st->st_mode & S_IUSEUNK))
- gotit = st->st_mode & (op << S_IUNKSHIFT);
- else if (!fshelp_isowner (st, user))
- gotit = st->st_mode & op;
- else if (idvec_contains (user->gids, st->st_gid))
- gotit = st->st_mode & (op >> 3);
- else
- gotit = st->st_mode & (op >> 6);
- return gotit ? 0 : EACCES;
-}
+error_t fshelp_access (struct stat *st, int op, struct iouser *user);
/* Check to see whether USER is allowed to modify DIR with respect to
existing file ST. (If there is no existing file, pass 0 for ST.)
If the access is permissable return 0; otherwise return an
appropriate error code. */
-FSHELP_EI error_t
-fshelp_checkdirmod (struct stat *dir, struct stat *st, struct iouser *user)
-{
- error_t err;
-
- /* The user must be able to write the directory. */
- err = fshelp_access (dir, S_IWRITE, user);
- if (err)
- return err;
-
- /* If the directory is sticky, the user must own either it or the file. */
- if ((dir->st_mode & S_ISVTX) && st
- && fshelp_isowner (dir, user) && fshelp_isowner (st, user))
- return EACCES;
+error_t fshelp_checkdirmod (struct stat *dir, struct stat *st,
+ struct iouser *user);
- return 0;
-}
/* Timestamps to change. */
#define TOUCH_ATIME 0x1
@@ -306,29 +255,6 @@ fshelp_checkdirmod (struct stat *dir, struct stat *st, struct iouser *user)
/* Change the stat times of NODE as indicated by WHAT (from the set TOUCH_*)
to the current time. */
-FSHELP_EI void
-fshelp_touch (struct stat *st, unsigned what,
- volatile struct mapped_time_value *maptime)
-{
- struct timeval tv;
-
- maptime_read (maptime, &tv);
-
- if (what & TOUCH_ATIME)
- {
- st->st_atime = tv.tv_sec;
- st->st_atime_usec = tv.tv_usec;
- }
- if (what & TOUCH_CTIME)
- {
- st->st_ctime = tv.tv_sec;
- st->st_ctime_usec = tv.tv_usec;
- }
- if (what & TOUCH_MTIME)
- {
- st->st_mtime = tv.tv_sec;
- st->st_mtime_usec = tv.tv_usec;
- }
-}
-
+void fshelp_touch (struct stat *st, unsigned what,
+ volatile struct mapped_time_value *maptime);
#endif
diff --git a/libfshelp/perms-access.c b/libfshelp/perms-access.c
new file mode 100644
index 00000000..91ad9da8
--- /dev/null
+++ b/libfshelp/perms-access.c
@@ -0,0 +1,43 @@
+/*
+ Copyright (C) 1999 Free Software Foundation, Inc.
+ Written by Thomas Bushnell, BSG.
+
+ 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 "fshelp.h"
+
+/* 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
+ code. */
+error_t
+fshelp_access (struct stat *st, int op, struct iouser *user)
+{
+ int gotit;
+ if (idvec_contains (user->uids, 0))
+ gotit = 1;
+ else if (user->uids->num == 0 && (st->st_mode & S_IUSEUNK))
+ gotit = st->st_mode & (op << S_IUNKSHIFT);
+ else if (!fshelp_isowner (st, user))
+ gotit = st->st_mode & op;
+ else if (idvec_contains (user->gids, st->st_gid))
+ gotit = st->st_mode & (op >> 3);
+ else
+ gotit = st->st_mode & (op >> 6);
+ return gotit ? 0 : EACCES;
+}
diff --git a/libfshelp/perms-checkdirmod.c b/libfshelp/perms-checkdirmod.c
new file mode 100644
index 00000000..db4b2e43
--- /dev/null
+++ b/libfshelp/perms-checkdirmod.c
@@ -0,0 +1,44 @@
+/*
+ Copyright (C) 1999 Free Software Foundation, Inc.
+ Written by Thomas Bushnell, BSG.
+
+ 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 "fshelp.h"
+
+/* Check to see whether USER is allowed to modify DIR with respect to
+ existing file ST. (If there is no existing file, pass 0 for ST.)
+ If the access is permissable return 0; otherwise return an
+ appropriate error code. */
+error_t
+fshelp_checkdirmod (struct stat *dir, struct stat *st, struct iouser *user)
+{
+ error_t err;
+
+ /* The user must be able to write the directory. */
+ err = fshelp_access (dir, S_IWRITE, user);
+ if (err)
+ return err;
+
+ /* If the directory is sticky, the user must own either it or the file. */
+ if ((dir->st_mode & S_ISVTX) && st
+ && fshelp_isowner (dir, user) && fshelp_isowner (st, user))
+ return EACCES;
+
+ return 0;
+}
diff --git a/libfshelp/perms-isowner.c b/libfshelp/perms-isowner.c
new file mode 100644
index 00000000..d1975993
--- /dev/null
+++ b/libfshelp/perms-isowner.c
@@ -0,0 +1,39 @@
+/*
+ Copyright (C) 1999 Free Software Foundation, Inc.
+ Written by Thomas Bushnell, BSG.
+
+ 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 "fshelp.h"
+
+/* Check to see whether USER should be considered the owner of the
+ file identified by ST. If so, return zero; otherwise return an
+ appropriate error code. */
+error_t
+fshelp_isowner (struct stat *st, struct iouser *user)
+{
+ /* Permitted if the user has the owner UID, the superuser UID, or if
+ the user is in the group of the file and has the group ID as
+ their user ID. */
+ if (idvec_contains (user->uids, st->st_uid)
+ || idvec_contains (user->uids, 0)
+ || (idvec_contains (user->gids, st->st_gid)
+ && idvec_contains (user->uids, st->st_gid)))
+ return 0;
+ else
+ return EPERM;
+}
diff --git a/libfshelp/touch.c b/libfshelp/touch.c
new file mode 100644
index 00000000..c254bfbf
--- /dev/null
+++ b/libfshelp/touch.c
@@ -0,0 +1,48 @@
+/*
+ Copyright (C) 1999 Free Software Foundation, Inc.
+ Written by Thomas Bushnell, BSG.
+
+ 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 "fshelp.h"
+
+/* Change the stat times of NODE as indicated by WHAT (from the set TOUCH_*)
+ to the current time. */
+void
+fshelp_touch (struct stat *st, unsigned what,
+ volatile struct mapped_time_value *maptime)
+{
+ struct timeval tv;
+
+ maptime_read (maptime, &tv);
+
+ if (what & TOUCH_ATIME)
+ {
+ st->st_atime = tv.tv_sec;
+ st->st_atime_usec = tv.tv_usec;
+ }
+ if (what & TOUCH_CTIME)
+ {
+ st->st_ctime = tv.tv_sec;
+ st->st_ctime_usec = tv.tv_usec;
+ }
+ if (what & TOUCH_MTIME)
+ {
+ st->st_mtime = tv.tv_sec;
+ st->st_mtime_usec = tv.tv_usec;
+ }
+}
diff --git a/libfshelp/translated.c b/libfshelp/translated.c
new file mode 100644
index 00000000..2dc724b6
--- /dev/null
+++ b/libfshelp/translated.c
@@ -0,0 +1,28 @@
+/*
+ Copyright (C) 1999 Free Software Foundation, Inc.
+ Written by Thomas Bushnell, BSG.
+
+ 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 "fshelp.h"
+
+/* Return true iff there is an active translator on this box */
+int
+fshelp_translated (struct transbox *box)
+{
+ return (box->active != MACH_PORT_NULL);
+}