diff --git a/openssh-6.1p1-privsep-selinux.patch b/openssh-6.1p1-privsep-selinux.patch index b3f96c4..65e50b3 100644 --- a/openssh-6.1p1-privsep-selinux.patch +++ b/openssh-6.1p1-privsep-selinux.patch @@ -1,28 +1,68 @@ +diff -up openssh-6.1p1/openbsd-compat/port-linux.c.privsep-selinux openssh-6.1p1/openbsd-compat/port-linux.c +--- openssh-6.1p1/openbsd-compat/port-linux.c.privsep-selinux 2012-10-12 13:35:03.715980297 +0200 ++++ openssh-6.1p1/openbsd-compat/port-linux.c 2012-10-12 13:35:03.719980279 +0200 +@@ -505,6 +505,23 @@ ssh_selinux_change_context(const char *n + xfree(newctx); + } + ++void ++ssh_selinux_copy_context(void) ++{ ++ char *ctx; ++ ++ if (!ssh_selinux_enabled()) ++ return; ++ ++ if (getexeccon((security_context_t *)&ctx) != 0) { ++ logit("%s: getcon failed with %s", __func__, strerror (errno)); ++ return; ++ } ++ if (setcon(ctx) != 0) ++ logit("%s: setcon failed with %s", __func__, strerror (errno)); ++ xfree(ctx); ++} ++ + #endif /* WITH_SELINUX */ + + #ifdef LINUX_OOM_ADJUST +diff -up openssh-6.1p1/openbsd-compat/port-linux.h.privsep-selinux openssh-6.1p1/openbsd-compat/port-linux.h +--- openssh-6.1p1/openbsd-compat/port-linux.h.privsep-selinux 2011-01-25 02:16:18.000000000 +0100 ++++ openssh-6.1p1/openbsd-compat/port-linux.h 2012-10-12 13:35:03.719980279 +0200 +@@ -24,6 +24,7 @@ int ssh_selinux_enabled(void); + void ssh_selinux_setup_pty(char *, const char *); + void ssh_selinux_setup_exec_context(char *); + void ssh_selinux_change_context(const char *); ++void ssh_selinux_copy_context(void); + void ssh_selinux_setfscreatecon(const char *); + #endif + diff -up openssh-6.1p1/session.c.privsep-selinux openssh-6.1p1/session.c ---- openssh-6.1p1/session.c.privsep-selinux 2012-09-15 13:45:26.079476022 +0200 -+++ openssh-6.1p1/session.c 2012-09-15 13:45:28.460522390 +0200 -@@ -1513,6 +1513,7 @@ do_setusercontext(struct passwd *pw) +--- openssh-6.1p1/session.c.privsep-selinux 2012-10-12 13:35:03.670980503 +0200 ++++ openssh-6.1p1/session.c 2012-10-12 14:03:01.011305806 +0200 +@@ -1513,6 +1513,10 @@ do_setusercontext(struct passwd *pw) platform_setusercontext_post_groups(pw); + - if (options.chroot_directory != NULL && - strcasecmp(options.chroot_directory, "none") != 0) { - tmp = tilde_expand_filename(options.chroot_directory, -@@ -1536,6 +1537,10 @@ do_setusercontext(struct passwd *pw) - /* Permanently switch to the desired uid. */ - permanently_set_uid(pw); - #endif -+ +#ifdef WITH_SELINUX + ssh_selinux_copy_context(); +#endif + if (options.chroot_directory != NULL && + strcasecmp(options.chroot_directory, "none") != 0) { + tmp = tilde_expand_filename(options.chroot_directory, +@@ -1787,9 +1791,6 @@ do_child(Session *s, const char *command + argv[i] = NULL; + optind = optreset = 1; + __progname = argv[0]; +-#ifdef WITH_SELINUX +- ssh_selinux_change_context("sftpd_t"); +-#endif + exit(sftp_server_main(i, argv, s->pw)); } - if (getuid() != pw->pw_uid || geteuid() != pw->pw_uid) diff -up openssh-6.1p1/sshd.c.privsep-selinux openssh-6.1p1/sshd.c ---- openssh-6.1p1/sshd.c.privsep-selinux 2012-09-15 13:45:26.062475676 +0200 -+++ openssh-6.1p1/sshd.c 2012-09-15 13:45:28.467522539 +0200 +--- openssh-6.1p1/sshd.c.privsep-selinux 2012-10-12 13:35:03.716980292 +0200 ++++ openssh-6.1p1/sshd.c 2012-10-12 13:35:03.721980271 +0200 @@ -794,6 +794,13 @@ privsep_postauth(Authctxt *authctxt) do_setusercontext(authctxt->pw); diff --git a/openssh.spec b/openssh.spec index 81a6b15..fc258bb 100644 --- a/openssh.spec +++ b/openssh.spec @@ -135,7 +135,7 @@ Patch302: pam_ssh_agent_auth-0.9.2-visibility.patch #https://bugzilla.mindrot.org/show_bug.cgi?id=1641 (WONTFIX) Patch400: openssh-6.0p1-role-mls.patch #? -Patch402: openssh-5.9p1-sftp-chroot.patch +#Patch402: openssh-5.9p1-sftp-chroot.patch #https://bugzilla.mindrot.org/show_bug.cgi?id=1940 #Patch403: openssh-5.9p1-sesandbox.patch #https://bugzilla.redhat.com/show_bug.cgi?id=781634 @@ -409,7 +409,7 @@ popd %if %{WITH_SELINUX} %patch400 -p1 -b .role-mls -%patch402 -p1 -b .sftp-chroot +#%patch402 -p1 -b .sftp-chroot #%patch403 -p1 -b .sesandbox %patch404 -p1 -b .privsep-selinux %endif