Jan F 84d568a
diff -up openssh-5.6p1/configure.ac.selabel openssh-5.6p1/configure.ac
Jan F 84d568a
--- openssh-5.6p1/configure.ac.selabel	2010-09-13 11:20:47.000000000 +0200
Jan F 84d568a
+++ openssh-5.6p1/configure.ac	2010-09-13 11:20:50.000000000 +0200
Jan F 84d568a
@@ -700,7 +700,6 @@ mips-sony-bsd|mips-sony-newsos4)
Jan F 84d568a
 			[ AC_DEFINE(USE_SOLARIS_PROCESS_CONTRACTS, 1,
Jan F 84d568a
 				[Define if you have Solaris process contracts])
Jan F 84d568a
 			  SSHDLIBS="$SSHDLIBS -lcontract"
Jan F 84d568a
-			  AC_SUBST(SSHDLIBS)
Jan F 84d568a
 			  SPC_MSG="yes" ], )
Jan F 84d568a
 		],
Jan F 84d568a
 	)
Jan F 84d568a
@@ -3500,6 +3499,7 @@ AC_ARG_WITH(selinux,
Jan F 84d568a
 			],
Jan F 84d568a
 			AC_MSG_ERROR(SELinux support requires libselinux library))
Jan F 84d568a
 		SSHDLIBS="$SSHDLIBS $LIBSELINUX"
Jan F 84d568a
+		SSHLIBS="$SSHLIBS $LIBSELINUX"
Jan F 84d568a
 		LIBS="$LIBS $LIBSELINUX"
Jan F 84d568a
 		AC_CHECK_FUNCS(getseuserbyname get_default_context_with_level)
Jan F 84d568a
 		AC_CHECK_FUNCS(setkeycreatecon)
Jan F 84d568a
@@ -4269,6 +4269,8 @@ else
Jan F 84d568a
 fi
Jan F 84d568a
 AC_CHECK_DECL(BROKEN_GETADDRINFO,  TEST_SSH_IPV6=no)
Jan F 84d568a
 AC_SUBST(TEST_SSH_IPV6, $TEST_SSH_IPV6)
Jan F 84d568a
+AC_SUBST(SSHLIBS)
Jan F 84d568a
+AC_SUBST(SSHDLIBS)
Jan F 84d568a
 
Jan F 84d568a
 AC_EXEEXT
Jan F 84d568a
 AC_CONFIG_FILES([Makefile buildpkg.sh opensshd.init openssh.xml \
Jan F 84d568a
@@ -4345,6 +4347,9 @@ echo "         Libraries: ${LIBS}"
Jan F 84d568a
 if test ! -z "${SSHDLIBS}"; then
Jan F 84d568a
 echo "         +for sshd: ${SSHDLIBS}"
Jan F 84d568a
 fi
Jan F 84d568a
+if test ! -z "${SSHLIBS}"; then
Jan F 84d568a
+echo "         +for ssh: ${SSHLIBS}"
Jan F 84d568a
+fi
Jan F 84d568a
 
Jan F 84d568a
 echo ""
Jan F 84d568a
 
Jan F. Chadima 1b8a267
diff -up openssh-5.6p1/contrib/ssh-copy-id.selabel openssh-5.6p1/contrib/ssh-copy-id
Jan F. Chadima 1b8a267
--- openssh-5.6p1/contrib/ssh-copy-id.selabel	2010-08-10 05:36:09.000000000 +0200
Jan F 84d568a
+++ openssh-5.6p1/contrib/ssh-copy-id	2010-09-13 11:20:50.000000000 +0200
Jan F. Chadima 1b8a267
@@ -41,7 +41,7 @@ fi
Jan F. Chadima 1b8a267
 # strip any trailing colon
Jan F. Chadima 1b8a267
 host=`echo $1 | sed 's/:$//'`
ca05b36
 
Jan F. Chadima 1b8a267
-{ eval "$GET_ID" ; } | ssh $host "umask 077; test -d ~/.ssh || mkdir ~/.ssh ; cat >> ~/.ssh/authorized_keys" || exit 1
Jan F. Chadima 1b8a267
+{ eval "$GET_ID" ; } | ssh $host "umask 077; test -d ~/.ssh || mkdir ~/.ssh ; cat >> ~/.ssh/authorized_keys; test -x /sbin/restorecon && /sbin/restorecon ~/.ssh ~/.ssh/authorized_keys" || exit 1
ca05b36
 
ca05b36
 cat <
Jan F. Chadima 1b8a267
 Now try logging into the machine, with "ssh '$host'", and check in:
Jan F. Chadima 1b8a267
diff -up openssh-5.6p1/Makefile.in.selabel openssh-5.6p1/Makefile.in
Jan F 84d568a
--- openssh-5.6p1/Makefile.in.selabel	2010-09-13 11:20:49.000000000 +0200
Jan F 84d568a
+++ openssh-5.6p1/Makefile.in	2010-09-13 11:20:50.000000000 +0200
Jan F 84d568a
@@ -47,6 +47,7 @@ LD=@LD@
Jan F 84d568a
 CFLAGS=@CFLAGS@
Jan F 84d568a
 CPPFLAGS=-I. -I$(srcdir) @CPPFLAGS@ $(PATHS) @DEFS@
Jan F 84d568a
 LIBS=@LIBS@
Jan F 84d568a
+SSHLIBS=@SSHLIBS@
Jan F 84d568a
 SSHDLIBS=@SSHDLIBS@
Jan F 84d568a
 LIBEDIT=@LIBEDIT@
Jan F 84d568a
 AR=@AR@
Jan F 84d568a
@@ -141,7 +142,7 @@ libssh.a: $(LIBSSH_OBJS)
ca05b36
 	$(RANLIB) $@
ca05b36
 
ca05b36
 ssh$(EXEEXT): $(LIBCOMPAT) libssh.a $(SSHOBJS)
ca05b36
-	$(LD) -o $@ $(SSHOBJS) $(LDFLAGS) -lssh -lopenbsd-compat -lfipscheck $(LIBS)
Jan F 84d568a
+	$(LD) -o $@ $(SSHOBJS) $(LDFLAGS) -lssh -lopenbsd-compat -lfipscheck $(SSHLIBS) $(LIBS)
ca05b36
 
ca05b36
 sshd$(EXEEXT): libssh.a	$(LIBCOMPAT) $(SSHDOBJS)
c54a8b0
 	$(LD) -o $@ $(SSHDOBJS) $(LDFLAGS) -lssh -lopenbsd-compat -lfipscheck $(SSHDLIBS) $(LIBS)
Jan F 84d568a
diff -up openssh-5.6p1/openbsd-compat/port-linux.h.selabel openssh-5.6p1/openbsd-compat/port-linux.h
Jan F 84d568a
--- openssh-5.6p1/openbsd-compat/port-linux.h.selabel	2009-12-08 03:39:48.000000000 +0100
Jan F 84d568a
+++ openssh-5.6p1/openbsd-compat/port-linux.h	2010-09-13 11:20:50.000000000 +0200
Jan F 84d568a
@@ -20,6 +20,7 @@
Jan F 84d568a
 #define _PORT_LINUX_H
ca05b36
 
Jan F 84d568a
 #ifdef WITH_SELINUX
Jan F 84d568a
+#include <selinux/selinux.h>
Jan F 84d568a
 int ssh_selinux_enabled(void);
Jan F 84d568a
 void ssh_selinux_setup_pty(char *, const char *);
Jan F 84d568a
 void ssh_selinux_setup_exec_context(char *);
Jan F 84d568a
diff -up openssh-5.6p1/ssh.c.selabel openssh-5.6p1/ssh.c
Jan F 84d568a
--- openssh-5.6p1/ssh.c.selabel	2010-09-13 11:20:50.000000000 +0200
Jan F 84d568a
+++ openssh-5.6p1/ssh.c	2010-09-13 11:23:02.000000000 +0200
Jan F 84d568a
@@ -848,10 +848,21 @@ main(int ac, char **av)
ca05b36
 	 */
3d6b00a
 	r = snprintf(buf, sizeof buf, "%s%s%s", pw->pw_dir,
ca05b36
 	    strcmp(pw->pw_dir, "/") ? "/" : "", _PATH_SSH_USER_DIR);
3d6b00a
-	if (r > 0 && (size_t)r < sizeof(buf) && stat(buf, &st) < 0)
3d6b00a
+	if (r > 0 && (size_t)r < sizeof(buf) && stat(buf, &st) < 0) {
Jan F 84d568a
+#ifdef WITH_SELINUX
ca05b36
+		char *scon;
ca05b36
+
Jan F 93909d9
+		if (matchpathcon(buf, 0700, &scon) != -1) {
Jan F 93909d9
+			setfscreatecon(scon);
Jan F 93909d9
+			matchpathcon_fini();
Jan F 93909d9
+		}
Jan F 84d568a
+#endif
ca05b36
 		if (mkdir(buf, 0700) < 0)
ca05b36
 			error("Could not create directory '%.200s'.", buf);
ca05b36
-
Jan F 84d568a
+#ifdef WITH_SELINUX
ca05b36
+		setfscreatecon(NULL);
Jan F 84d568a
+#endif
ca05b36
+	}
ca05b36
 	/* load options.identity_files */
ca05b36
 	load_public_identity_files();
ca05b36