6a4c8dd
diff -up openssh-5.1p1/sshd.c.log-chroot openssh-5.1p1/sshd.c
6a4c8dd
--- openssh-5.1p1/sshd.c.log-chroot	2008-07-23 15:18:52.000000000 +0200
6a4c8dd
+++ openssh-5.1p1/sshd.c	2008-07-23 15:18:52.000000000 +0200
6a4c8dd
@@ -591,6 +591,10 @@ privsep_preauth_child(void)
c9833c9
 	/* Demote the private keys to public keys. */
c9833c9
 	demote_sensitive_data();
e01ed66
 
c9833c9
+	/* Open the syslog permanently so the chrooted process still
c9833c9
+	   can write to syslog. */
c9833c9
+	open_log();
c9833c9
+	
c9833c9
 	/* Change our root directory */
c9833c9
 	if (chroot(_PATH_PRIVSEP_CHROOT_DIR) == -1)
c9833c9
 		fatal("chroot(\"%s\"): %s", _PATH_PRIVSEP_CHROOT_DIR,
6a4c8dd
diff -up openssh-5.1p1/log.c.log-chroot openssh-5.1p1/log.c
6a4c8dd
--- openssh-5.1p1/log.c.log-chroot	2008-06-10 15:01:51.000000000 +0200
6a4c8dd
+++ openssh-5.1p1/log.c	2008-07-23 15:18:52.000000000 +0200
c9833c9
@@ -56,6 +56,7 @@ static LogLevel log_level = SYSLOG_LEVEL
e01ed66
 static int log_on_stderr = 1;
e01ed66
 static int log_facility = LOG_AUTH;
e01ed66
 static char *argv0;
e01ed66
+static int log_fd_keep;
e01ed66
 
e01ed66
 extern char *__progname;
e01ed66
 
6a4c8dd
@@ -392,10 +393,21 @@ do_log(LogLevel level, const char *fmt, 
e01ed66
 		syslog_r(pri, &sdata, "%.500s", fmtbuf);
e01ed66
 		closelog_r(&sdata);
e01ed66
 #else
e01ed66
+	    if (!log_fd_keep) {
e01ed66
 		openlog(argv0 ? argv0 : __progname, LOG_PID, log_facility);
e01ed66
+	    }
e01ed66
 		syslog(pri, "%.500s", fmtbuf);
e01ed66
+	    if (!log_fd_keep) {
e01ed66
 		closelog();
e01ed66
+	    }
e01ed66
 #endif
e01ed66
 	}
c9833c9
 	errno = saved_errno;
e01ed66
 }
e01ed66
+
e01ed66
+void
e01ed66
+open_log(void)
e01ed66
+{
e01ed66
+	openlog(argv0 ? argv0 : __progname, LOG_PID|LOG_NDELAY, log_facility);
e01ed66
+	log_fd_keep = 1;
e01ed66
+}
6a4c8dd
diff -up openssh-5.1p1/log.h.log-chroot openssh-5.1p1/log.h
6a4c8dd
--- openssh-5.1p1/log.h.log-chroot	2008-06-13 02:22:54.000000000 +0200
6a4c8dd
+++ openssh-5.1p1/log.h	2008-07-23 15:20:11.000000000 +0200
6a4c8dd
@@ -66,4 +66,6 @@ void     debug3(const char *, ...) __att
e01ed66
 
c9833c9
 void	 do_log(LogLevel, const char *, va_list);
6a4c8dd
 void	 cleanup_exit(int) __attribute__((noreturn));
c9833c9
+
c9833c9
+void     open_log(void);
c9833c9
 #endif