summaryrefslogtreecommitdiff
path: root/term
diff options
context:
space:
mode:
authorThomas Bushnell <thomas@gnu.org>1999-02-19 07:45:57 +0000
committerThomas Bushnell <thomas@gnu.org>1999-02-19 07:45:57 +0000
commitd822f1e0c93ee19dd34462ed3fab51b2b4f22bc4 (patch)
tree751a583f10cc861bce4a7eac1b62bfa3001aec7f /term
parentb4d4e7e9b8ca92adddbb2c19bb1c3d1beda23441 (diff)
1999-02-06 Mark Kettenis <kettenis@gnu.org>
* main.c (main): Initialize status from underlying node. * users.c (check_access_hook): New function. Correctly implement access permission checking. (trivfs_check_access_hook): Initialize with check_access_hook. (trivfs_S_file_check_access): Removed.
Diffstat (limited to 'term')
-rw-r--r--term/ChangeLog8
-rw-r--r--term/main.c22
-rw-r--r--term/users.c40
3 files changed, 53 insertions, 17 deletions
diff --git a/term/ChangeLog b/term/ChangeLog
index 2cee50ea..e26f5f95 100644
--- a/term/ChangeLog
+++ b/term/ChangeLog
@@ -1,3 +1,11 @@
+1999-02-06 Mark Kettenis <kettenis@gnu.org>
+
+ * main.c (main): Initialize status from underlying node.
+ * users.c (check_access_hook): New function. Correctly implement
+ access permission checking.
+ (trivfs_check_access_hook): Initialize with check_access_hook.
+ (trivfs_S_file_check_access): Removed.
+
Thu Feb 18 00:57:30 1999 Thomas Bushnell, BSG <tb@mit.edu>
* devio.c (devio_assert_dtr): Bother to set open_pending.
diff --git a/term/main.c b/term/main.c
index d14c7c48..db23ef5b 100644
--- a/term/main.c
+++ b/term/main.c
@@ -54,7 +54,8 @@ main (int argc, char **argv)
struct port_class *peerclass, *peercntlclass;
struct trivfs_control **ourcntl, **peercntl;
mach_port_t bootstrap;
- enum {T_DEVICE, T_PTYMASTER, T_PTYSLAVE} type;
+ enum {T_DEVICE, T_PTYMASTER, T_PTYSLAVE} type;
+ struct stat st;
term_bucket = ports_create_bucket ();
@@ -168,8 +169,22 @@ main (int argc, char **argv)
termflags = NO_CARRIER | NO_OWNER;
mutex_init (&global_lock);
- term_owner = term_group = 0;
- term_mode = (bottom == &ptyio_bottom ? 0666 : 0600) | S_IFCHR | S_IROOT;
+ /* Initialize status from underlying node. */
+ errno = io_stat ((*ourcntl)->underlying, &st);
+ if (errno)
+ {
+ /* We cannot stat the underlying node. Fallback to the defaults. */
+ term_owner = term_group = 0;
+ term_mode = (bottom == &ptyio_bottom ? DEFFILEMODE : S_IRUSR | S_IWUSR);
+ errno = 0;
+ }
+ else
+ {
+ term_owner = st.st_uid;
+ term_group = st.st_gid;
+ term_mode = (st.st_mode & ACCESSPERMS);
+ }
+ term_mode |= S_IFCHR | S_IROOT;
inputq = create_queue (256, QUEUE_LOWAT, QUEUE_HIWAT);
@@ -190,4 +205,3 @@ main (int argc, char **argv)
return 0;
}
-
diff --git a/term/users.c b/term/users.c
index 8794bfb6..31780aed 100644
--- a/term/users.c
+++ b/term/users.c
@@ -105,6 +105,33 @@ init_users ()
static error_t
+check_access_hook (struct trivfs_control *cntl,
+ struct iouser *user,
+ mach_port_t realnode,
+ int *allowed)
+{
+ struct stat st;
+
+ mutex_lock (&global_lock);
+
+ st.st_uid = term_owner;
+ st.st_gid = term_group;
+ st.st_mode = term_mode;
+
+ *allowed = 0;
+ if (fshelp_access (&st, S_IREAD, user) == 0)
+ *allowed |= O_READ;
+ if (fshelp_access (&st, S_IWRITE, user) == 0)
+ *allowed |= O_WRITE;
+
+ mutex_unlock (&global_lock);
+ return 0;
+}
+error_t (*trivfs_check_access_hook) (struct trivfs_control *, struct iouser *,
+ mach_port_t, int *)
+ = check_access_hook;
+
+static error_t
open_hook (struct trivfs_control *cntl,
struct iouser *user,
int flags)
@@ -508,19 +535,6 @@ out:
return err;
}
-error_t
-trivfs_S_file_check_access (struct trivfs_protid *cred,
- mach_port_t reply, mach_msg_type_name_t reply_type,
- int *allowed)
-{
- if (!cred)
- return EOPNOTSUPP;
-
- /* XXX Do the right thing eventually. */
- *allowed = O_READ | O_WRITE;
- return 0;
-}
-
/* Called for user writes to the terminal as described
in <hurd/io.defs>. */