From 67cabf362fea62548630bfa44ad1d9538a78aa29 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Mon, 15 Aug 1994 20:40:57 +0000 Subject: Formerly host.c.~6~ --- proc/host.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 2 deletions(-) (limited to 'proc') diff --git a/proc/host.c b/proc/host.c index fd54390a..72da687f 100644 --- a/proc/host.c +++ b/proc/host.c @@ -20,6 +20,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Written by Michael I. Bushnell. */ #include +#include #include #include #include @@ -28,6 +29,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include +#include #define HURD_VERSION_DEFINE #include @@ -52,8 +54,6 @@ struct server_version } *server_versions; int nserver_versions, server_versions_nalloc; - - struct execdata_notify { mach_port_t notify_port; @@ -141,6 +141,38 @@ S_proc_getprivports (struct proc *p, return 0; } +/* Initialize the standard exec ports and ints. */ +void +init_stdarrays () +{ + auth_t nullauth; + mach_port_t pt; + int pid = getpid (); + + std_port_array = malloc (sizeof (mach_port_t) * INIT_PORT_MAX); + std_int_array = malloc (sizeof (int) * INIT_INT_MAX); + + bzero (std_port_array, sizeof (mach_port_t) * INIT_PORT_MAX); + bzero (std_int_array, sizeof (int) * INIT_INT_MAX); + + __USEPORT (AUTH, auth_makeauth (port, 0, MACH_MSG_TYPE_COPY_SEND, 0, + 0, 0, 0, 0, 0, 0, 0, 0, &nullauth)); + + pt = getcwdir (); + io_reauthenticate (pt, pid); + auth_user_authenticate (nullauth, pt, pid, &std_port_array[INIT_PORT_CWDIR]); + mach_port_deallocate (mach_task_self (), pt); + + pt = getcrdir (); + io_reauthenticate (pt, pid); + auth_user_authenticate (nullauth, pt, pid, &std_port_array[INIT_PORT_CRDIR]); + mach_port_deallocate (mach_task_self (), pt); + + std_port_array[INIT_PORT_AUTH] = nullauth; + + std_int_array[INIT_UMASK] = CMASK; +} + /* Implement proc_setexecdata as described in . */ kern_return_t S_proc_setexecdata (struct proc *p, @@ -190,6 +222,9 @@ S_proc_getexecdata (struct proc *p, { /* XXX memory leak here */ + if (!std_port_array) + init_stdarrays (); + if (*nports < n_std_ports) *ports = malloc (n_std_ports * sizeof (mach_port_t)); bcopy (std_port_array, *ports, n_std_ports * sizeof (mach_port_t)); @@ -223,11 +258,34 @@ S_proc_execdata_notify (struct proc *p, if (foo) mach_port_deallocate (mach_task_self (), foo); + if (!std_port_array) + init_stdarrays (); + exec_setexecdata (n->notify_port, std_port_array, MACH_MSG_TYPE_COPY_SEND, n_std_ports, std_int_array, n_std_ints); return 0; } +/* Check all the execdata notify ports and see if one of them is + PORT; if it is, then free it. */ +void +check_dead_execdata_notify (mach_port_t port) +{ + struct execdata_notify *en, **prevp; + + for (en = execdata_notifys, prevp = &execdata_notifys; en; en = *prevp) + { + if (en->notify_port == port) + { + mach_port_deallocate (mach_task_self (), port); + *prevp = en->next; + free (en); + } + else + prevp = &en->next; + } +} + /* Version information handling. A server registers its name, and version with -- cgit v1.2.3