vishalmishra434 / rpms / openssh

Forked from rpms/openssh a month ago
Clone
Petr Lautrbach 0c438f
diff -up openssh-5.9p1/session.c.privsep-selinux openssh-5.9p1/session.c
Petr Lautrbach 0c438f
--- openssh-5.9p1/session.c.privsep-selinux	2012-08-01 15:36:33.397565915 +0200
Petr Lautrbach 0c438f
+++ openssh-5.9p1/session.c	2012-08-02 18:18:15.038094629 +0200
Petr Lautrbach 0c438f
@@ -1536,6 +1536,13 @@ do_setusercontext(struct passwd *pw)
Petr Lautrbach 0c438f
 		/* Permanently switch to the desired uid. */
Petr Lautrbach 0c438f
 		permanently_set_uid(pw);
Petr Lautrbach cd5891
 #endif
Petr Lautrbach 0c438f
+
Petr Lautrbach 0c438f
+#ifdef WITH_SELINUX
Petr Lautrbach 0c438f
+		if (options.chroot_directory == NULL ||
Petr Lautrbach 0c438f
+		    strcasecmp(options.chroot_directory, "none") == 0) {
Petr Lautrbach 0c438f
+			ssh_selinux_copy_context();
Petr Lautrbach 0c438f
+		}
Petr Lautrbach 0c438f
+#endif
Petr Lautrbach cd5891
 	}
Petr Lautrbach cd5891
 
Petr Lautrbach 0c438f
 	if (getuid() != pw->pw_uid || geteuid() != pw->pw_uid)
Petr Lautrbach 0c438f
diff -up openssh-5.9p1/sshd.c.privsep-selinux openssh-5.9p1/sshd.c
Petr Lautrbach 0c438f
--- openssh-5.9p1/sshd.c.privsep-selinux	2012-08-01 16:09:22.949423356 +0200
Petr Lautrbach 0c438f
+++ openssh-5.9p1/sshd.c	2012-08-02 18:07:22.912225684 +0200
Petr Lautrbach 0c438f
@@ -790,6 +790,14 @@ privsep_postauth(Authctxt *authctxt)
Petr Lautrbach 0c438f
 	do_setusercontext(authctxt->pw);
Petr Lautrbach 0c438f
 
Petr Lautrbach 0c438f
  skip:
Petr Lautrbach cd5891
+#ifdef WITH_SELINUX
Petr Lautrbach 0c438f
+	/* switch SELinux content for root too */
Petr Lautrbach 0c438f
+	if (authctxt->pw->pw_uid == 0 && (options.chroot_directory == NULL ||
Petr Lautrbach 0c438f
+	    strcasecmp(options.chroot_directory, "none") == 0)) {
Petr Lautrbach cd5891
+		ssh_selinux_copy_context();
Petr Lautrbach cd5891
+	}
Petr Lautrbach cd5891
+#endif
Petr Lautrbach cd5891
+
Petr Lautrbach 0c438f
 	/* It is safe now to apply the key state */
Petr Lautrbach 0c438f
 	monitor_apply_keystate(pmonitor);
Petr Lautrbach 0c438f