aux/listen: Allow per service namespace files
This commit is contained in:
parent
9fe925eaa5
commit
674fcda107
3 changed files with 45 additions and 7 deletions
24
rc/bin/service/!tcp80.namespace
Normal file
24
rc/bin/service/!tcp80.namespace
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
mount -aC #s/boot /root $rootspec
|
||||||
|
|
||||||
|
# kernel devices
|
||||||
|
bind #c /dev
|
||||||
|
bind #d /fd
|
||||||
|
bind -c #e /env
|
||||||
|
bind #p /proc
|
||||||
|
bind -a #l /net
|
||||||
|
bind -a #I /net
|
||||||
|
|
||||||
|
bind /root/$cputype/bin /bin
|
||||||
|
bind /root/rc /rc
|
||||||
|
bind -a /rc/bin /bin
|
||||||
|
|
||||||
|
chdev Mcde|pslI/
|
||||||
|
|
||||||
|
# grab just our webroot
|
||||||
|
bind /root/usr/web /srv
|
||||||
|
|
||||||
|
# or bind in the actual root
|
||||||
|
# bind -a /root /
|
||||||
|
|
||||||
|
unmount /root
|
||||||
|
chdev -r Ms
|
|
@ -96,6 +96,14 @@ For example,
|
||||||
an inbound call on the TCP network for port 565 executes service
|
an inbound call on the TCP network for port 565 executes service
|
||||||
.BR tcp565 .
|
.BR tcp565 .
|
||||||
.PP
|
.PP
|
||||||
|
Services may have individual
|
||||||
|
.IR namespace (6)
|
||||||
|
files specified within
|
||||||
|
.IR srvdir .
|
||||||
|
If provided, the namespace is used as the parent for each connection
|
||||||
|
to the corresponding service. Namespace files are found by appending a .namespace
|
||||||
|
suffix to the service name.
|
||||||
|
.PP
|
||||||
At least the following services are available in
|
At least the following services are available in
|
||||||
.BR /bin/service .
|
.BR /bin/service .
|
||||||
.TF \ tcp0000
|
.TF \ tcp0000
|
||||||
|
|
|
@ -136,6 +136,7 @@ listendir(char *srvdir, int trusted)
|
||||||
{
|
{
|
||||||
int ctl, pid, start;
|
int ctl, pid, start;
|
||||||
char dir[40], err[128], ds[128];
|
char dir[40], err[128], ds[128];
|
||||||
|
char prog[Maxpath], serv[Maxserv], ns[Maxpath];
|
||||||
long childs;
|
long childs;
|
||||||
Announce *a;
|
Announce *a;
|
||||||
Waitmsg *wm;
|
Waitmsg *wm;
|
||||||
|
@ -178,6 +179,10 @@ listendir(char *srvdir, int trusted)
|
||||||
sleep((pid*10)%200);
|
sleep((pid*10)%200);
|
||||||
|
|
||||||
snprint(ds, sizeof ds, "%s!%s!%s", protodir, addr, a->a);
|
snprint(ds, sizeof ds, "%s!%s!%s", protodir, addr, a->a);
|
||||||
|
snprint(serv, sizeof serv, "%s%s", proto, a->a);
|
||||||
|
snprint(prog, sizeof prog, "%s/%s", srvdir, serv);
|
||||||
|
snprint(ns, sizeof ns, "%s.namespace", prog);
|
||||||
|
|
||||||
whined = a->whined;
|
whined = a->whined;
|
||||||
|
|
||||||
/* a process per service */
|
/* a process per service */
|
||||||
|
@ -201,7 +206,11 @@ listendir(char *srvdir, int trusted)
|
||||||
else
|
else
|
||||||
exits("ctl");
|
exits("ctl");
|
||||||
}
|
}
|
||||||
dolisten(dir, ctl, srvdir, a->a, &childs);
|
procsetname("%s %s", dir, ds);
|
||||||
|
if(!trusted)
|
||||||
|
if(newns("none", ns) < 0)
|
||||||
|
syslog(0, listenlog, "can't build namespace %s: %r\n", ns);
|
||||||
|
dolisten(dir, ctl, serv, prog, &childs);
|
||||||
close(ctl);
|
close(ctl);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -299,6 +308,8 @@ scandir(char *dname)
|
||||||
continue;
|
continue;
|
||||||
if(strncmp(nm, proto, nlen) != 0)
|
if(strncmp(nm, proto, nlen) != 0)
|
||||||
continue;
|
continue;
|
||||||
|
if(strstr(nm + nlen, ".namespace") != nil)
|
||||||
|
continue;
|
||||||
addannounce(nm + nlen);
|
addannounce(nm + nlen);
|
||||||
}
|
}
|
||||||
free(db);
|
free(db);
|
||||||
|
@ -329,15 +340,10 @@ becomenone(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
dolisten(char *dir, int ctl, char *srvdir, char *port, long *pchilds)
|
dolisten(char *dir, int ctl, char *serv, char *prog, long *pchilds)
|
||||||
{
|
{
|
||||||
char ndir[40], wbuf[64];
|
char ndir[40], wbuf[64];
|
||||||
char prog[Maxpath], serv[Maxserv];
|
|
||||||
int nctl, data, wfd, nowait;
|
int nctl, data, wfd, nowait;
|
||||||
|
|
||||||
procsetname("%s %s!%s!%s", dir, proto, addr, port);
|
|
||||||
snprint(serv, sizeof serv, "%s%s", proto, port);
|
|
||||||
snprint(prog, sizeof prog, "%s/%s", srvdir, serv);
|
|
||||||
|
|
||||||
wfd = -1;
|
wfd = -1;
|
||||||
nowait = RFNOWAIT;
|
nowait = RFNOWAIT;
|
||||||
|
|
Loading…
Reference in a new issue