diff options
author | Thomas Bushnell <thomas@gnu.org> | 1999-02-19 07:45:57 +0000 |
---|---|---|
committer | Thomas Bushnell <thomas@gnu.org> | 1999-02-19 07:45:57 +0000 |
commit | d822f1e0c93ee19dd34462ed3fab51b2b4f22bc4 (patch) | |
tree | 751a583f10cc861bce4a7eac1b62bfa3001aec7f /term/main.c | |
parent | b4d4e7e9b8ca92adddbb2c19bb1c3d1beda23441 (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/main.c')
-rw-r--r-- | term/main.c | 22 |
1 files changed, 18 insertions, 4 deletions
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; } - |