git: 9front

Download patch

ref: 6e181e926f54c300091a8c1c5d2610d6c030e52c
parent: 6d42f323eb2dcb1a93433963aa7d6ddee3e048db
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Tue Mar 11 03:03:15 EDT 2014

exportfs: avoid closing netfd in filter()

netfd is initially zero (stdin), when filter() closes fd0,
fd0 is free to be reused. this causes problems with openmount()
that assumes sfd being >2.

instead, we dup the our pipe end over netfd, and close the pipe.

--- a/sys/src/cmd/exportfs/exportfs.c
+++ b/sys/src/cmd/exportfs/exportfs.c
@@ -927,10 +927,11 @@
 		exec(file, argv);
 		fatal("filter: exec; %r");
 	default:
-		close(fd);
+		dup(p[1], fd);
 		close(p[0]);
+		close(p[1]);
 	}
-	return p[1];	
+	return fd;
 }
 
 static void
--