c54a8b0
diff -up openssh-5.3p1/contrib/ssh-copy-id.selabel openssh-5.3p1/contrib/ssh-copy-id
c54a8b0
--- openssh-5.3p1/contrib/ssh-copy-id.selabel	2009-01-21 10:29:21.000000000 +0100
c54a8b0
+++ openssh-5.3p1/contrib/ssh-copy-id	2009-10-02 14:21:54.000000000 +0200
ca05b36
@@ -38,7 +38,7 @@ if [ "$#" -lt 1 ] || [ "$1" = "-h" ] || 
ca05b36
   exit 1
ca05b36
 fi
ca05b36
 
ca05b36
-{ eval "$GET_ID" ; } | ssh $1 "umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys" || exit 1
ca05b36
+{ eval "$GET_ID" ; } | ssh $1 "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 <
ca05b36
 Now try logging into the machine, with "ssh '$1'", and check in:
c54a8b0
diff -up openssh-5.3p1/Makefile.in.selabel openssh-5.3p1/Makefile.in
c54a8b0
--- openssh-5.3p1/Makefile.in.selabel	2009-10-02 14:21:54.000000000 +0200
c54a8b0
+++ openssh-5.3p1/Makefile.in	2009-10-02 14:23:23.000000000 +0200
c54a8b0
@@ -136,7 +136,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)
ca05b36
+	$(LD) -o $@ $(SSHOBJS) $(LDFLAGS) -lssh -lopenbsd-compat -lfipscheck -lselinux $(LIBS)
ca05b36
 
ca05b36
 sshd$(EXEEXT): libssh.a	$(LIBCOMPAT) $(SSHDOBJS)
c54a8b0
 	$(LD) -o $@ $(SSHDOBJS) $(LDFLAGS) -lssh -lopenbsd-compat -lfipscheck $(SSHDLIBS) $(LIBS)
c54a8b0
diff -up openssh-5.3p1/ssh.c.selabel openssh-5.3p1/ssh.c
c54a8b0
--- openssh-5.3p1/ssh.c.selabel	2009-10-02 14:21:54.000000000 +0200
c54a8b0
+++ openssh-5.3p1/ssh.c	2009-10-02 14:21:54.000000000 +0200
ca05b36
@@ -74,6 +74,7 @@
ca05b36
 #include <openssl/err.h>
ca05b36
 #include <openssl/fips.h>
ca05b36
 #include <fipscheck.h>
ca05b36
+#include <selinux/selinux.h>
ca05b36
 #include "openbsd-compat/openssl-compat.h"
ca05b36
 #include "openbsd-compat/sys-queue.h"
ca05b36
 
c54a8b0
@@ -792,10 +793,15 @@ 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) {
ca05b36
+		char *scon;
ca05b36
+
ca05b36
+		matchpathcon(buf, 0700, &scon);
ca05b36
+		setfscreatecon(scon);
ca05b36
 		if (mkdir(buf, 0700) < 0)
ca05b36
 			error("Could not create directory '%.200s'.", buf);
ca05b36
-
ca05b36
+		setfscreatecon(NULL);
ca05b36
+	}
ca05b36
 	/* load options.identity_files */
ca05b36
 	load_public_identity_files();
ca05b36