privsep patch, Please test

Tim Rice tim at multitalents.net
Thu May 30 04:14:13 EST 2002



Please try the attached patch. It adds support for platforms that
have mmap() but do not support MAP_ANONYMOUS.
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.gz
or
	ftp://ftp.multitalents.net/pub/openssh/configure-privsep.gz
and add the following line to config.h.in
#undef HAVE_WORKING_MAP_ANONYMOUS

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

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

-- 
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	Wed May 29 08:15:21 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 working MAP_ANONYMOUS */
+#undef HAVE_WORKING_MAP_ANONYMOUS
+
 @BOTTOM@
 
 /* ******************* Shouldn't need to edit below this line ************** */
--- openssh/configure.ac.old	Mon May 27 17:37:33 2002
+++ openssh/configure.ac	Wed May 29 08:17:13 2002
@@ -576,6 +576,28 @@
 	strlcat strlcpy strmode strsep sysconf tcgetpgrp truncate utimes \
 	vhangup vsnprintf waitpid __b64_ntop _getpty)
 
+AC_MSG_CHECKING([for mmap with working MAP_ANONYMOUS])
+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;
+address = mmap(NULL, 10, PROT_WRITE|PROT_READ, MAP_ANON|MAP_SHARED, -1, 0);
+if (address == MAP_FAILED)
+	exit(1);
+exit(0);
+}
+	],
+	[
+		AC_MSG_RESULT(yes)
+		AC_DEFINE(HAVE_WORKING_MAP_ANONYMOUS)
+	], 
+	[ AC_MSG_RESULT(no) ]
+)
+
 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	Wed May 29 08:22:54 2002
@@ -84,9 +84,14 @@
 	 */
 	mm->mmalloc = mmalloc;
 
-#if  defined(HAVE_MMAP) && defined(MAP_ANON)
+#ifdef HAVE_MMAP
+#ifdef HAVE_WORKING_MAP_ANONYMOUS
 	address = mmap(NULL, size, PROT_WRITE|PROT_READ, MAP_ANON|MAP_SHARED,
 	    -1, 0);
+#else
+	address = mmap(NULL, size, PROT_WRITE|PROT_READ, MAP_PRIVATE,
+	    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