privsep patch, Please test (take 2)

Tim Rice tim at multitalents.net
Fri May 31 02:58:18 EST 2002


It looks like mmap() with MAP_SHARED just doesn't work on Linux 2.2
so i'm releasing a new patch.
See http://mail.nl.linux.org/linux-mm/1999-01/msg00034.html

On Wed, 29 May 2002, Tim Rice wrote: (and then revised)

Please try the attached patch. It adds support for platforms that
have mmap() but do not support MAP_ANONYMOUS.
Ie. UnixWare 2.x, Solaris < 8

You'll need autoconf 2.52 installed
Run autoreconf after applying the patch.

If you don't have autoconf 2.52 installed,
grab the new configure from
	http://www.multitalents.net/openssh/configure-privsep-2.gz
or
	ftp://ftp.multitalents.net/pub/openssh/configure-privsep-2.gz
and add the following line to config.h.in
#undef HAVE_BROKEN_MMAP

It works on UnixWare 2.1.3, and Solaris 7.
(In addition to the platforms that worked before)

It doesn't work with SCO yet. A problem with sendmsg() in mm_receive_fd()

I'd like to hear from other platforms that this helps.


-- 
Tim Rice				Multitalents	(707) 887-1469
tim at multitalents.net


-------------- next part --------------
--- openssh/acconfig.h.old	Sun May 12 20:25:01 2002
+++ openssh/acconfig.h	Thu May 30 09:07:03 2002
@@ -355,6 +355,9 @@
 /* Path that unprivileged child will chroot() to in privep mode */
 #undef PRIVSEP_PATH
 
+/* Define if you have the `mmap' function with broken MAP_ANONYMOUS */
+#undef HAVE_BROKEN_MMAP
+
 @BOTTOM@
 
 /* ******************* Shouldn't need to edit below this line ************** */
--- openssh/configure.ac.old	Mon May 27 17:37:33 2002
+++ openssh/configure.ac	Thu May 30 09:05:33 2002
@@ -576,6 +576,30 @@
 	strlcat strlcpy strmode strsep sysconf tcgetpgrp truncate utimes \
 	vhangup vsnprintf waitpid __b64_ntop _getpty)
 
+AC_MSG_CHECKING([for broken mmap])
+AC_TRY_RUN(
+	[
+#include <stdio.h>
+#include <sys/mman.h>
+#if !defined(MAP_ANON) && defined(MAP_ANONYMOUS)
+#define MAP_ANON MAP_ANONYMOUS
+#endif
+main() { void *address;
+#ifdef MAP_ANON
+address = mmap(NULL, 10, PROT_WRITE|PROT_READ, MAP_ANON|MAP_SHARED, -1, 0);
+if (address == MAP_FAILED)
+	exit(1);
+#endif
+exit(0);
+}
+	],
+	[ AC_MSG_RESULT(no) ], 
+	[
+		AC_MSG_RESULT(yes)
+		AC_DEFINE(HAVE_BROKEN_MMAP)
+	]
+)
+
 dnl IRIX and Solaris 2.5.1 have dirname() in libgen
 AC_CHECK_FUNCS(dirname, [AC_CHECK_HEADERS(libgen.h)] ,[
 	AC_CHECK_LIB(gen, dirname,[
--- openssh/monitor_mm.c.old	Fri Apr 12 17:49:51 2002
+++ openssh/monitor_mm.c	Thu May 30 09:19:10 2002
@@ -84,9 +84,14 @@
 	 */
 	mm->mmalloc = mmalloc;
 
-#if  defined(HAVE_MMAP) && defined(MAP_ANON)
+#if defined(HAVE_MMAP) && !defined(HAVE_BROKEN_MMAP)
+#ifdef MAP_ANON
 	address = mmap(NULL, size, PROT_WRITE|PROT_READ, MAP_ANON|MAP_SHARED,
 	    -1, 0);
+#else
+	address = mmap(NULL, size, PROT_WRITE|PROT_READ, MAP_SHARED,
+	    open("/dev/zero", O_RDWR), 0);
+#endif
 	if (address == MAP_FAILED)
 		fatal("mmap(%lu)", (u_long)size);
 #else
--- openssh/session.c.old	Sun May 12 20:25:02 2002
+++ openssh/session.c	Wed May 29 07:39:22 2002
@@ -1089,10 +1089,11 @@
 			exit(1);
 		}
 		/* Initialize the group list. */
-		if (initgroups(pw->pw_name, pw->pw_gid) < 0) {
-			perror("initgroups");
-			exit(1);
-		}
+		if (strcmp(pw->pw_name, SSH_PRIVSEP_USER))
+			if (initgroups(pw->pw_name, pw->pw_gid) < 0) {
+				perror("initgroups");
+				exit(1);
+			}
 		endgrent();
 # ifdef USE_PAM
 		/*


More information about the openssh-unix-dev mailing list