git: 9front

Download patch

ref: 01229e5b52c4532702b891d3bee7e9296e2ad1c2
parent: 11904cc75c606a30b0eddb7dd404389490e78c8d
author: Jacob Moody <moody@posixcafe.org>
date: Sun Dec 18 15:37:30 EST 2022

aux/listen: tweak per service namespaces

move in to the namespace earlier before the
announce. Only attempt and complain to syslog
when the file already exists, but if building
the new namespace fails we should bail.

--- a/sys/src/cmd/aux/listen.c
+++ b/sys/src/cmd/aux/listen.c
@@ -149,7 +149,7 @@
 void
 listendir(char *srvdir, int trusted)
 {
-	int ctl, pid, start, i;
+	int ctl, pid, start;
 	char dir[40], err[128], ds[128];
 	char prog[Maxpath], serv[Maxserv], ns[Maxpath];
 	long childs;
@@ -206,6 +206,12 @@
 				syslog(1, listenlog, "couldn't fork for %s", ds);
 				break;
 			case 0:
+				/* optional per service namespace files */
+				if(!trusted && access(ns, AEXIST)==0)
+					if(newns("none", ns) < 0){
+						syslog(1, listenlog, "can't build namespace %s: %r\n", ns);
+						exits("newns");
+					}
 				childs = 0;
 				for(;;){
 					ctl = announce(ds, dir);
@@ -222,9 +228,6 @@
 							exits("ctl");
 					}
 					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);
 				}
--