|
Jan F. Chadima |
69dd72 |
diff -up openssh-5.9p0/openbsd-compat/port-linux.c.sftp-chroot openssh-5.9p0/openbsd-compat/port-linux.c
|
|
Jan F. Chadima |
69dd72 |
--- openssh-5.9p0/openbsd-compat/port-linux.c.sftp-chroot 2011-09-01 04:12:22.743024608 +0200
|
|
Jan F. Chadima |
69dd72 |
+++ openssh-5.9p0/openbsd-compat/port-linux.c 2011-09-01 04:12:23.069088065 +0200
|
|
Jan F. Chadima |
69dd72 |
@@ -503,6 +503,23 @@ ssh_selinux_change_context(const char *n
|
|
Jan F. Chadima |
69dd72 |
xfree(newctx);
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
+void
|
|
Jan F. Chadima |
69dd72 |
+ssh_selinux_copy_context(void)
|
|
Jan F. Chadima |
69dd72 |
+{
|
|
Jan F. Chadima |
69dd72 |
+ char *ctx;
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ if (!ssh_selinux_enabled())
|
|
Jan F. Chadima |
69dd72 |
+ return;
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ if (getexeccon((security_context_t *)&ctx) < 0) {
|
|
Jan F. Chadima |
69dd72 |
+ logit("%s: getcon failed with %s", __func__, strerror (errno));
|
|
Jan F. Chadima |
69dd72 |
+ return;
|
|
Jan F. Chadima |
69dd72 |
+ }
|
|
Jan F. Chadima |
69dd72 |
+ if (setcon(ctx) < 0)
|
|
Jan F. Chadima |
69dd72 |
+ logit("%s: setcon failed with %s", __func__, strerror (errno));
|
|
Jan F. Chadima |
69dd72 |
+ xfree(ctx);
|
|
Jan F. Chadima |
69dd72 |
+}
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
#endif /* WITH_SELINUX */
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
#ifdef LINUX_OOM_ADJUST
|
|
Jan F. Chadima |
69dd72 |
diff -up openssh-5.9p0/openbsd-compat/port-linux.h.sftp-chroot openssh-5.9p0/openbsd-compat/port-linux.h
|
|
Jan F. Chadima |
69dd72 |
--- openssh-5.9p0/openbsd-compat/port-linux.h.sftp-chroot 2011-01-25 02:16:18.000000000 +0100
|
|
Jan F. Chadima |
69dd72 |
+++ openssh-5.9p0/openbsd-compat/port-linux.h 2011-09-01 04:12:23.163088777 +0200
|
|
Jan F. Chadima |
69dd72 |
@@ -24,6 +24,7 @@ int ssh_selinux_enabled(void);
|
|
Jan F. Chadima |
69dd72 |
void ssh_selinux_setup_pty(char *, const char *);
|
|
Jan F. Chadima |
69dd72 |
void ssh_selinux_setup_exec_context(char *);
|
|
Jan F. Chadima |
69dd72 |
void ssh_selinux_change_context(const char *);
|
|
Jan F. Chadima |
69dd72 |
+void ssh_selinux_chopy_context(void);
|
|
Jan F. Chadima |
69dd72 |
void ssh_selinux_setfscreatecon(const char *);
|
|
Jan F. Chadima |
69dd72 |
#endif
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
diff -up openssh-5.9p0/session.c.sftp-chroot openssh-5.9p0/session.c
|
|
Jan F. Chadima |
69dd72 |
--- openssh-5.9p0/session.c.sftp-chroot 2011-09-01 04:12:19.698049195 +0200
|
|
Jan F. Chadima |
69dd72 |
+++ openssh-5.9p0/session.c 2011-09-01 04:40:03.598148719 +0200
|
|
Jan F. Chadima |
69dd72 |
@@ -1519,6 +1519,9 @@ do_setusercontext(struct passwd *pw)
|
|
Jan F. Chadima |
69dd72 |
pw->pw_uid);
|
|
Jan F. Chadima |
69dd72 |
chroot_path = percent_expand(tmp, "h", pw->pw_dir,
|
|
Jan F. Chadima |
69dd72 |
"u", pw->pw_name, (char *)NULL);
|
|
Jan F. Chadima |
69dd72 |
+#ifdef WITH_SELINUX
|
|
Jan F. Chadima |
69dd72 |
+ ssh_selinux_change_context("chroot_user_t");
|
|
Jan F. Chadima |
69dd72 |
+#endif
|
|
Jan F. Chadima |
69dd72 |
safely_chroot(chroot_path, pw->pw_uid);
|
|
Jan F. Chadima |
69dd72 |
free(tmp);
|
|
Jan F. Chadima |
69dd72 |
free(chroot_path);
|
|
Jan F. Chadima |
69dd72 |
@@ -1788,7 +1791,10 @@ do_child(Session *s, const char *command
|
|
Jan F. Chadima |
69dd72 |
optind = optreset = 1;
|
|
Jan F. Chadima |
69dd72 |
__progname = argv[0];
|
|
Jan F. Chadima |
69dd72 |
#ifdef WITH_SELINUX
|
|
Jan F. Chadima |
69dd72 |
- ssh_selinux_change_context("sftpd_t");
|
|
Jan F. Chadima |
69dd72 |
+ if (options.chroot_directory == NULL ||
|
|
Jan F. Chadima |
69dd72 |
+ strcasecmp(options.chroot_directory, "none") == 0) {
|
|
Jan F. Chadima |
69dd72 |
+ ssh_selinux_copy_context();
|
|
Jan F. Chadima |
69dd72 |
+ }
|
|
Jan F. Chadima |
69dd72 |
#endif
|
|
Jan F. Chadima |
69dd72 |
exit(sftp_server_main(i, argv, s->pw));
|
|
Jan F. Chadima |
69dd72 |
}
|