From e68e88d2de7449b53c98ad7fc3e1ff169313bef3 Mon Sep 17 00:00:00 2001 From: Alex Wilson Date: Wed, 5 Aug 2015 12:25:15 -0700 Subject: [PATCH 21/34] Try to create privsep chroot dir if it doesn't exist yet diff -wpruN --no-dereference '--exclude=*.orig' a~/sshd-session.c a/sshd-session.c --- a~/sshd-session.c 1970-01-01 00:00:00 +++ a/sshd-session.c 1970-01-01 00:00:00 @@ -303,6 +303,20 @@ privsep_preauth_child(void) /* Demote the child */ if (privsep_chroot) { + struct stat st; + int rc; + + if ((stat(_PATH_PRIVSEP_CHROOT_DIR, &st) == -1) || + (S_ISDIR(st.st_mode) == 0)) { + rc = mkdir(_PATH_PRIVSEP_CHROOT_DIR, 0755); + if (rc != 0) { + fatal("Failed to create privilege separation " + "directory %s: %s", + _PATH_PRIVSEP_CHROOT_DIR, + strerror(errno)); + } + } + /* Change our root directory */ if (chroot(_PATH_PRIVSEP_CHROOT_DIR) == -1) fatal("chroot(\"%s\"): %s", _PATH_PRIVSEP_CHROOT_DIR,