vishalmishra434 / rpms / openssh

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