[116989] trunk/dports/net/openssh
cal at macports.org
cal at macports.org
Tue Feb 11 17:31:19 PST 2014
Revision: 116989
https://trac.macports.org/changeset/116989
Author: cal at macports.org
Date: 2014-02-11 17:31:19 -0800 (Tue, 11 Feb 2014)
Log Message:
-----------
openssh: fix sandboxing feature, fix password auth by forcing PAM, closes #36291
Modified Paths:
--------------
trunk/dports/net/openssh/Portfile
Added Paths:
-----------
trunk/dports/net/openssh/files/org.openssh.sshd.sb
trunk/dports/net/openssh/files/patch-sandbox-darwin.c-apple-sandbox-named-external.diff
trunk/dports/net/openssh/files/patch-sshd.c-apple-sandbox-named-external.diff
Modified: trunk/dports/net/openssh/Portfile
===================================================================
--- trunk/dports/net/openssh/Portfile 2014-02-12 00:39:10 UTC (rev 116988)
+++ trunk/dports/net/openssh/Portfile 2014-02-12 01:31:19 UTC (rev 116989)
@@ -5,7 +5,7 @@
name openssh
version 6.5p1
-revision 1
+revision 2
categories net
platforms darwin
@@ -46,12 +46,29 @@
# the HPN patch needs this, so rewrite all other patches to support it, too
patch.args -p1
-patchfiles launchd.patch
+patchfiles launchd.patch \
+ pam.patch \
+ patch-sandbox-darwin.c-apple-sandbox-named-external.diff \
+ patch-sshd.c-apple-sandbox-named-external.diff
+# We need a couple of patches
+# - pam.patch
+# getpwnam(3) on OS X always returns "*********" in the pw_passwd field even
+# when run as root, so it can't be used for authentication. This patch just
+# forces the use of PAM regardless of the configuration.
+# - patch-*-apple-sandbox-named-external.diff
+# Use Apple's sandbox_init(3) in addition to standard privilege separation.
+# This requires a sandbox profile (which we provide) and the sandbox_init(3)
+# call before the chroot(2) to privsep-path ($prefix/var/empty), or it will
+# fail to load the sandbox description and libsandbox.1.dylib.
-# Specified -fno-builtin because GCC 3.3 has log() as a builtin
-# (from math.h) while OpenSSH has its own log() function
-# -- from fink.
-configure.cppflags-append -fno-builtin
+post-patch {
+ # reinplace prefix in path to sandbox definition added by
+ # patch-sandbox-darwin.c-apple-sandbox-named-external.diff
+ reinplace "s|@PREFIX@|${prefix}|g" ${worksrcpath}/sandbox-darwin.c
+}
+
+# Use Apple's sandboxing feature
+configure.cppflags-append -D__APPLE_SANDBOX_NAMED_EXTERNAL__
configure.args --with-ssl-dir=${prefix} \
--sysconfdir=${prefix}/etc/ssh \
--with-privsep-path=${prefix}/var/empty \
@@ -76,9 +93,18 @@
post-destroot {
destroot.keepdirs ${destroot}${prefix}/var/run ${destroot}${prefix}/var/empty
+
+ # switch default port to avoid conflict with system sshd
reinplace "s|#Port 22|Port 2222|g" ${destroot}${prefix}/etc/ssh/sshd_config
+
+ # provide ssh-copy-id
xinstall -m 755 ${worksrcpath}/contrib/ssh-copy-id ${destroot}${prefix}/bin
xinstall -m 644 ${worksrcpath}/contrib/ssh-copy-id.1 ${destroot}${prefix}/share/man/man1
+
+ # install sandbox definition
+ xinstall -m 755 -d ${destroot}${prefix}/share/${name}
+ xinstall -m 644 ${filespath}/org.openssh.sshd.sb ${destroot}${prefix}/share/${name}
+
file rename "${destroot}${prefix}/etc/ssh/sshd_config" "${destroot}${prefix}/etc/ssh/sshd_config.example"
file rename "${destroot}${prefix}/etc/ssh/ssh_config" "${destroot}${prefix}/etc/ssh/ssh_config.example"
}
Added: trunk/dports/net/openssh/files/org.openssh.sshd.sb
===================================================================
--- trunk/dports/net/openssh/files/org.openssh.sshd.sb (rev 0)
+++ trunk/dports/net/openssh/files/org.openssh.sshd.sb 2014-02-12 01:31:19 UTC (rev 116989)
@@ -0,0 +1,21 @@
+;; Copyright (c) 2008 Apple Inc. All Rights reserved.
+;;
+;; sshd - profile for privilege separated children
+;;
+;; WARNING: The sandbox rules in this file currently constitute
+;; Apple System Private Interface and are subject to change at any time and
+;; without notice.
+;;
+
+(version 1)
+
+(deny default)
+
+(allow file-chroot)
+(allow file-read-metadata (literal "/var"))
+
+(allow sysctl-read)
+(allow mach-per-user-lookup)
+(allow mach-lookup
+ (global-name "com.apple.system.notification_center")
+ (global-name "com.apple.system.logger"))
Added: trunk/dports/net/openssh/files/patch-sandbox-darwin.c-apple-sandbox-named-external.diff
===================================================================
--- trunk/dports/net/openssh/files/patch-sandbox-darwin.c-apple-sandbox-named-external.diff (rev 0)
+++ trunk/dports/net/openssh/files/patch-sandbox-darwin.c-apple-sandbox-named-external.diff 2014-02-12 01:31:19 UTC (rev 116989)
@@ -0,0 +1,19 @@
+--- a/sandbox-darwin.c.orig 2014-02-12 01:31:10.000000000 +0100
++++ b/sandbox-darwin.c 2014-02-12 01:31:54.000000000 +0100
+@@ -62,8 +62,16 @@
+ struct rlimit rl_zero;
+
+ debug3("%s: starting Darwin sandbox", __func__);
++#ifdef __APPLE_SANDBOX_NAMED_EXTERNAL__
++#ifndef SANDBOX_NAMED_EXTERNAL
++#define SANDBOX_NAMED_EXTERNAL (0x3)
++#endif
++ if (sandbox_init("@PREFIX@/share/openssh/org.openssh.sshd.sb",
++ SANDBOX_NAMED_EXTERNAL, &errmsg) == -1)
++#else
+ if (sandbox_init(kSBXProfilePureComputation, SANDBOX_NAMED,
+ &errmsg) == -1)
++#endif
+ fatal("%s: sandbox_init: %s", __func__, errmsg);
+
+ /*
Added: trunk/dports/net/openssh/files/patch-sshd.c-apple-sandbox-named-external.diff
===================================================================
--- trunk/dports/net/openssh/files/patch-sshd.c-apple-sandbox-named-external.diff (rev 0)
+++ trunk/dports/net/openssh/files/patch-sshd.c-apple-sandbox-named-external.diff 2014-02-12 01:31:19 UTC (rev 116989)
@@ -0,0 +1,21 @@
+--- a/sshd.c 2014-02-11 23:55:15.000000000 +0100
++++ b/sshd.c 2013-07-03 01:09:16.000000000 +0200
+@@ -708,11 +699,18 @@
+ set_log_handler(mm_log_handler, pmonitor);
+
+ /* Demote the child */
++#ifdef __APPLE_SANDBOX_NAMED_EXTERNAL__
++ /* We need to do this before we chroot() so we can read sshd.sb */
++ if (box != NULL)
++ ssh_sandbox_child(box);
++#endif
+ if (getuid() == 0 || geteuid() == 0)
+ privsep_preauth_child();
+ setproctitle("%s", "[net]");
++#ifndef __APPLE_SANDBOX_NAMED_EXTERNAL__
+ if (box != NULL)
+ ssh_sandbox_child(box);
++#endif
+
+ return 0;
+ }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20140211/0daaf5d5/attachment.html>
More information about the macports-changes
mailing list