3.3p1 patch for Solaris 2.6

itojun at iijlab.net itojun at iijlab.net
Wed Jun 26 01:06:55 EST 2002


>> 	here's a patch to 3.3p1 for Solaris 2.6 - it does not handle
>> 	mmap() with fd = -1.  does it look okay?
>That looks good.  Any reason why you do not check the open result,
>too.  I mean I know mmap is going to fail with an invalid fd, but
>still.

	i just wasn't careful enough.  here's a new one.

itojun


--- work.i386/openssh-3.3p1/servconf.c-	Tue Jun 25 23:43:22 2002
+++ work.i386/openssh-3.3p1/servconf.c	Tue Jun 25 23:43:33 2002
@@ -257,7 +257,7 @@
 	if (use_privsep == -1)
 		use_privsep = 1;
 
-#if !defined(HAVE_MMAP) || !defined(MAP_ANON)
+#if !defined(HAVE_MMAP)
 	if (use_privsep && options->compression == 1) {
 		error("This platform does not support both privilege "
 		    "separation and compression");
--- work.i386/openssh-3.3p1/monitor_mm.c-	Tue Jun 25 23:42:02 2002
+++ work.i386/openssh-3.3p1/monitor_mm.c	Wed Jun 26 00:05:42 2002
@@ -71,6 +71,9 @@
 {
 	void *address;
 	struct mm_master *mm;
+#if defined(HAVE_MMAP) && !defined(MAP_ANON)
+	int fd;
+#endif
 
 	if (mmalloc == NULL)
 		mm = xmalloc(sizeof(struct mm_master));
@@ -87,6 +90,15 @@
 #if  defined(HAVE_MMAP) && defined(MAP_ANON)
 	address = mmap(NULL, size, PROT_WRITE|PROT_READ, MAP_ANON|MAP_SHARED,
 	    -1, 0);
+	if (address == MAP_FAILED)
+		fatal("mmap(%lu): %s", (u_long)size, strerror(errno));
+#elif defined(HAVE_MMAP) && !defined(MAP_ANON)
+	fd = open("/dev/zero", O_RDWR);
+	if (fd < 0)
+		fatal("open(/dev/zero): %s", strerror(errno));
+	address = mmap(NULL, size, PROT_WRITE|PROT_READ, MAP_ANON|MAP_SHARED,
+	    fd, 0);
+	close(fd);
 	if (address == MAP_FAILED)
 		fatal("mmap(%lu): %s", (u_long)size, strerror(errno));
 #else



More information about the openssh-unix-dev mailing list