Subject: Re: openssh3.3p1 on solaris2.6
To: IWAMOTO Toshihiro <iwamoto@sat.t.u-tokyo.ac.jp>
From: Jun-ichiro itojun Hagino <itojun@iijlab.net>
List: tech-pkg
Date: 06/25/2002 23:44:34
>I'm using Zoularis on Solaris2.6. I noticed the following diff is
>necessary to use compression and priviledge separation, because
>it doesn't have MAP_ANON.
>Does this diff look OK? I'd like to commit it shortly.
how about this? it does not check the return value of open(2),
which is IMHO bad.
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 Tue Jun 25 23:43:11 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,13 @@
#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);
+ 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