From: Ben Gras Date: Mon, 21 Sep 2009 15:25:15 +0000 (+0000) Subject: RS_LOOKUP feature for libc functions that want to access servers. X-Git-Tag: v3.1.5~113 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zpipe.c?a=commitdiff_plain;h=32fa22fc2df83d9e2f0b7ec74ae35a844002bd14;p=minix.git RS_LOOKUP feature for libc functions that want to access servers. let ipc talk to all USER processes and vice versa. pm sig wrapper notify has to be called from two files. actually install include files. --- diff --git a/etc/drivers.conf b/etc/drivers.conf index 382099585..2e7b6639b 100644 --- a/etc/drivers.conf +++ b/etc/drivers.conf @@ -395,6 +395,7 @@ driver ipc TTY DS VM + USER ; vm REMAP diff --git a/include/Makefile b/include/Makefile index 7ee12e638..5f71fc981 100644 --- a/include/Makefile +++ b/include/Makefile @@ -8,11 +8,11 @@ all:: clean:: install:: - #-rm -rf $(INC) - #mkdir -p $(INC) - #cpdir . $(INC) - #@chown -R bin $(INC) - #@rm -f $(INC)/Makefile + -rm -rf $(INC) + mkdir -p $(INC) + cpdir . $(INC) + @chown -R bin $(INC) + @rm -f $(INC)/Makefile gcc: install SHELL=/bin/sh; if [ -f $(MKHEADERS343) ] ; then sh -e $(MKHEADERS343) ; fi diff --git a/include/minix/com.h b/include/minix/com.h index 202a79968..ef8dc8f04 100755 --- a/include/minix/com.h +++ b/include/minix/com.h @@ -636,7 +636,7 @@ * arguments are passed in * a struct rs_start */ -#define RS_LOOKUP (DS_RQ_BASE + 8) /* lookup server name */ +#define RS_LOOKUP (RS_RQ_BASE + 8) /* lookup server name */ # define RS_CMD_ADDR m1_p1 /* command string */ # define RS_CMD_LEN m1_i1 /* length of command */ diff --git a/servers/pm/proto.h b/servers/pm/proto.h index 3c091ea88..b70f4837d 100644 --- a/servers/pm/proto.h +++ b/servers/pm/proto.h @@ -90,6 +90,8 @@ _PROTOTYPE( int do_sigprocmask, (void) ); _PROTOTYPE( int do_sigreturn, (void) ); _PROTOTYPE( int do_sigsuspend, (void) ); _PROTOTYPE( void check_pending, (struct mproc *rmp) ); +_PROTOTYPE( int, vm_notify_sig_wrapper(endpoint_t ep) ); + /* time.c */ _PROTOTYPE( int do_stime, (void) ); diff --git a/servers/pm/signal.c b/servers/pm/signal.c index c9244d246..678945bbb 100644 --- a/servers/pm/signal.c +++ b/servers/pm/signal.c @@ -306,7 +306,7 @@ PUBLIC int do_pause() return(SUSPEND); } -PRIVATE vm_notify_sig_wrapper(endpoint_t ep) +PUBLIC vm_notify_sig_wrapper(endpoint_t ep) { /* get IPC's endpoint, * the reason that we directly get the endpoint diff --git a/servers/rs/main.c b/servers/rs/main.c index 7808c380d..638065504 100644 --- a/servers/rs/main.c +++ b/servers/rs/main.c @@ -91,9 +91,9 @@ PUBLIC int main(void) continue; } - /* Only root can make calls to rs */ + /* Only root can make calls to rs. unless it's RS_LOOKUP. */ euid= getpeuid(m.m_source); - if (euid != 0) + if (euid != 0 && call_nr != RS_LOOKUP) { printf("RS: got unauthorized request %d from endpoint %d\n", call_nr, m.m_source); @@ -111,6 +111,7 @@ PUBLIC int main(void) case RS_RESTART: result = do_restart(&m); break; case RS_SHUTDOWN: result = do_shutdown(&m); break; case GETSYSINFO: result = do_getsysinfo(&m); break; + case RS_LOOKUP: result = do_lookup(&m); break; default: printf("Warning, RS got unexpected request %d from %d\n", m.m_type, m.m_source); diff --git a/servers/rs/manager.c b/servers/rs/manager.c index b08caeb55..cd1ae0e37 100644 --- a/servers/rs/manager.c +++ b/servers/rs/manager.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -1420,3 +1421,42 @@ int endpoint; return; } } + +/*===========================================================================* + * do_lookup * + *===========================================================================*/ +PUBLIC int do_lookup(m_ptr) +message *m_ptr; +{ + static char namebuf[100]; + int len, r; + struct rproc *rrp; + + len = m_ptr->RS_NAME_LEN; + + if(len < 2 || len >= sizeof(namebuf)) { + printf("RS: len too weird (%d)\n", len); + return EINVAL; + } + + if((r=sys_vircopy(m_ptr->m_source, D, (vir_bytes) m_ptr->RS_NAME, + SELF, D, (vir_bytes) namebuf, len)) != OK) { + printf("RS: name copy failed\n"); + return r; + + } + + namebuf[len] = '\0'; + + for (rrp=BEG_RPROC_ADDR; rrpr_flags & RS_IN_USE)) + continue; + if (!strcmp(rrp->r_label, namebuf)) { + m_ptr->RS_ENDPOINT = rrp->r_proc_nr_e; + return OK; + } + } + + return ESRCH; +} + diff --git a/servers/rs/proto.h b/servers/rs/proto.h index 1e0ccf5e4..583df7b02 100644 --- a/servers/rs/proto.h +++ b/servers/rs/proto.h @@ -14,6 +14,7 @@ _PROTOTYPE( int do_down, (message *m)); _PROTOTYPE( int do_refresh, (message *m)); _PROTOTYPE( int do_rescue, (message *m)); _PROTOTYPE( int do_restart, (message *m)); +_PROTOTYPE( int do_lookup, (message *m)); _PROTOTYPE( int do_shutdown, (message *m)); _PROTOTYPE( void do_period, (message *m)); _PROTOTYPE( void do_exit, (message *m));