|
Petr Lautrbach |
afd52c |
diff -up openssh-6.1p1/openbsd-compat/port-linux.c.privsep-selinux openssh-6.1p1/openbsd-compat/port-linux.c
|
|
bach |
dfa0cd |
--- openssh-6.1p1/openbsd-compat/port-linux.c.privsep-selinux 2012-11-05 14:46:39.334809203 +0100
|
|
bach |
dfa0cd |
+++ openssh-6.1p1/openbsd-compat/port-linux.c 2012-11-05 14:54:32.614504884 +0100
|
|
bach |
dfa0cd |
@@ -505,6 +505,25 @@ ssh_selinux_change_context(const char *n
|
|
Petr Lautrbach |
afd52c |
xfree(newctx);
|
|
Petr Lautrbach |
afd52c |
}
|
|
Petr Lautrbach |
afd52c |
|
|
Petr Lautrbach |
afd52c |
+void
|
|
Petr Lautrbach |
afd52c |
+ssh_selinux_copy_context(void)
|
|
Petr Lautrbach |
afd52c |
+{
|
|
bach |
dfa0cd |
+ security_context_t *ctx;
|
|
Petr Lautrbach |
afd52c |
+
|
|
Petr Lautrbach |
afd52c |
+ if (!ssh_selinux_enabled())
|
|
Petr Lautrbach |
afd52c |
+ return;
|
|
Petr Lautrbach |
afd52c |
+
|
|
Petr Lautrbach |
afd52c |
+ if (getexeccon((security_context_t *)&ctx) != 0) {
|
|
Petr Lautrbach |
afd52c |
+ logit("%s: getcon failed with %s", __func__, strerror (errno));
|
|
Petr Lautrbach |
afd52c |
+ return;
|
|
Petr Lautrbach |
afd52c |
+ }
|
|
bach |
dfa0cd |
+ if (ctx != NULL) {
|
|
bach |
dfa0cd |
+ if (setcon(ctx) != 0)
|
|
bach |
dfa0cd |
+ logit("%s: setcon failed with %s", __func__, strerror (errno));
|
|
bach |
dfa0cd |
+ freecon(ctx);
|
|
bach |
dfa0cd |
+ }
|
|
Petr Lautrbach |
afd52c |
+}
|
|
Petr Lautrbach |
afd52c |
+
|
|
Petr Lautrbach |
afd52c |
#endif /* WITH_SELINUX */
|
|
Petr Lautrbach |
afd52c |
|
|
Petr Lautrbach |
afd52c |
#ifdef LINUX_OOM_ADJUST
|
|
Petr Lautrbach |
afd52c |
diff -up openssh-6.1p1/openbsd-compat/port-linux.h.privsep-selinux openssh-6.1p1/openbsd-compat/port-linux.h
|
|
Petr Lautrbach |
afd52c |
--- openssh-6.1p1/openbsd-compat/port-linux.h.privsep-selinux 2011-01-25 02:16:18.000000000 +0100
|
|
bach |
dfa0cd |
+++ openssh-6.1p1/openbsd-compat/port-linux.h 2012-11-05 14:46:39.339809234 +0100
|
|
Petr Lautrbach |
afd52c |
@@ -24,6 +24,7 @@ int ssh_selinux_enabled(void);
|
|
Petr Lautrbach |
afd52c |
void ssh_selinux_setup_pty(char *, const char *);
|
|
Petr Lautrbach |
afd52c |
void ssh_selinux_setup_exec_context(char *);
|
|
Petr Lautrbach |
afd52c |
void ssh_selinux_change_context(const char *);
|
|
Petr Lautrbach |
afd52c |
+void ssh_selinux_copy_context(void);
|
|
Petr Lautrbach |
afd52c |
void ssh_selinux_setfscreatecon(const char *);
|
|
Petr Lautrbach |
afd52c |
#endif
|
|
Petr Lautrbach |
afd52c |
|
|
Petr Lautrbach |
581bf3 |
diff -up openssh-6.1p1/session.c.privsep-selinux openssh-6.1p1/session.c
|
|
bach |
dfa0cd |
--- openssh-6.1p1/session.c.privsep-selinux 2012-11-05 14:46:39.314809081 +0100
|
|
bach |
dfa0cd |
+++ openssh-6.1p1/session.c 2012-11-05 14:46:39.340809241 +0100
|
|
Petr Lautrbach |
afd52c |
@@ -1513,6 +1513,10 @@ do_setusercontext(struct passwd *pw)
|
|
Petr Lautrbach |
581bf3 |
|
|
Petr Lautrbach |
581bf3 |
platform_setusercontext_post_groups(pw);
|
|
Petr Lautrbach |
581bf3 |
|
|
Petr Lautrbach |
581bf3 |
+
|
|
Petr Lautrbach |
0c438f |
+#ifdef WITH_SELINUX
|
|
Petr Lautrbach |
581bf3 |
+ ssh_selinux_copy_context();
|
|
Petr Lautrbach |
0c438f |
+#endif
|
|
Petr Lautrbach |
afd52c |
if (options.chroot_directory != NULL &&
|
|
Petr Lautrbach |
afd52c |
strcasecmp(options.chroot_directory, "none") != 0) {
|
|
Petr Lautrbach |
afd52c |
tmp = tilde_expand_filename(options.chroot_directory,
|
|
Petr Lautrbach |
afd52c |
@@ -1787,9 +1791,6 @@ do_child(Session *s, const char *command
|
|
Petr Lautrbach |
afd52c |
argv[i] = NULL;
|
|
Petr Lautrbach |
afd52c |
optind = optreset = 1;
|
|
Petr Lautrbach |
afd52c |
__progname = argv[0];
|
|
Petr Lautrbach |
afd52c |
-#ifdef WITH_SELINUX
|
|
Petr Lautrbach |
afd52c |
- ssh_selinux_change_context("sftpd_t");
|
|
Petr Lautrbach |
afd52c |
-#endif
|
|
Petr Lautrbach |
afd52c |
exit(sftp_server_main(i, argv, s->pw));
|
|
Petr Lautrbach |
cd5891 |
}
|
|
Petr Lautrbach |
cd5891 |
|
|
Petr Lautrbach |
581bf3 |
diff -up openssh-6.1p1/sshd.c.privsep-selinux openssh-6.1p1/sshd.c
|
|
bach |
dfa0cd |
--- openssh-6.1p1/sshd.c.privsep-selinux 2012-11-05 14:46:39.335809209 +0100
|
|
bach |
dfa0cd |
+++ openssh-6.1p1/sshd.c 2012-11-05 14:46:39.341809247 +0100
|
|
Petr Lautrbach |
581bf3 |
@@ -794,6 +794,13 @@ 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 |
581bf3 |
+ if (authctxt->pw->pw_uid == 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 |
|