fatal("open ack write");
ini = initial;
- if (readn(netfd, initial, sizeof(initial)) < sizeof(initial))
+ n = readn(netfd, initial, sizeof(initial));
+ if (n == 0)
+ fatal(nil); /* port scan or spurious open/close on exported /srv file (unmount) */
+ if (n < sizeof(initial))
fatal("can't read initial string: %r");
if (memcmp(ini, "impo", 4) == 0) {
for(m = Proclist; m; m = m->next)
postnote(PNPROC, m->pid, "kill");
- DEBUG(DFD, "%s\n", buf);
- if (s)
+ if (s) {
+ DEBUG(DFD, "%s\n", buf);
sysfatal("%s", buf); /* caution: buf could contain '%' */
- else
+ } else
exits(nil);
}
if(pipe(p) < 0)
return -1;
- switch(rfork(RFPROC|RFMEM|RFNOWAIT|RFNAMEG|RFFDG)){
+ switch(rfork(RFPROC|RFMEM|RFNOWAIT|RFNAMEG|RFFDG|RFREND)){
case -1:
+ close(p[0]);
+ close(p[1]);
return -1;
default:
break;
}
+ dup(p[0], 0);
+ dup(p[0], 1);
+ close(p[0]);
close(p[1]);
arg[0] = "exportfs";
arg[2] = mbuf;
arg[3] = nil;
- close(0);
- close(1);
- dup(p[0], 0);
- dup(p[0], 1);
exec("/bin/exportfs", arg);
_exits("whoops: exec failed");
return -1;