homebrew-core/Formula/openssh.rb

108 lines
4.0 KiB
Ruby

class Openssh < Formula
desc "OpenBSD freely-licensed SSH connectivity tools"
homepage "https://www.openssh.com/"
url "https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.1p1.tar.gz"
mirror "https://cloudflare.cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.1p1.tar.gz"
version "9.1p1"
sha256 "19f85009c7e3e23787f0236fbb1578392ab4d4bf9f8ec5fe6bc1cd7e8bfdd288"
license "SSH-OpenSSH"
livecheck do
url "https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/"
regex(/href=.*?openssh[._-]v?(\d+(?:\.\d+)+(?:p\d+)?)\.t/i)
end
bottle do
sha256 arm64_ventura: "30dbc217ba91a3b7246dd21cc8662d1fd3bcf19d0f869c4bdfdb61a126711bf4"
sha256 arm64_monterey: "0a542c0f11d8d94245d96a26700dc2169a61d5e6712ae1f692a7eaa36aa0c91e"
sha256 arm64_big_sur: "50e41ea5da92f0a11fa766f769c1f95a71c5902d7f2b4efb1d7c47cd5652faa9"
sha256 ventura: "d02a77aecb957d5cf45654ade0505f1bbbf577a182fa1cea7d69d0a5e225992d"
sha256 monterey: "b1ed4e0f37f5b600403036fc2d14de298a81c57ff1ee96fba6b87103f2970982"
sha256 big_sur: "2ae6602db02ad26f680b37bbb2a9aa9b20a508237a5be509395b22fa02ee3be2"
sha256 catalina: "e8e6e6727003343dc912216f3b255974db09f8453a87551a61f4c507cf5a7920"
sha256 x86_64_linux: "bf000bf4474311a85a2c8b2884963382012802f7aa82f58398bd998a0c0b1d86"
end
# Please don't resubmit the keychain patch option. It will never be accepted.
# https://archive.is/hSB6d#10%25
depends_on "pkg-config" => :build
depends_on "ldns"
depends_on "libfido2"
depends_on "openssl@1.1"
uses_from_macos "lsof" => :test
uses_from_macos "krb5"
uses_from_macos "libedit"
uses_from_macos "libxcrypt"
uses_from_macos "zlib"
on_macos do
# Both these patches are applied by Apple.
# https://github.com/apple-oss-distributions/OpenSSH/blob/main/openssh/sandbox-darwin.c#L66
patch do
url "https://raw.githubusercontent.com/Homebrew/patches/1860b0a745f1fe726900974845d1b0dd3c3398d6/openssh/patch-sandbox-darwin.c-apple-sandbox-named-external.diff"
sha256 "d886b98f99fd27e3157b02b5b57f3fb49f43fd33806195970d4567f12be66e71"
end
# https://github.com/apple-oss-distributions/OpenSSH/blob/main/openssh/sshd.c#L532
patch do
url "https://raw.githubusercontent.com/Homebrew/patches/d8b2d8c2612fd251ac6de17bf0cc5174c3aab94c/openssh/patch-sshd.c-apple-sandbox-named-external.diff"
sha256 "3505c58bf1e584c8af92d916fe5f3f1899a6b15cc64a00ddece1dc0874b2f78f"
end
end
on_linux do
depends_on "linux-pam"
end
resource "com.openssh.sshd.sb" do
url "https://raw.githubusercontent.com/apple-oss-distributions/OpenSSH/OpenSSH-268.100.4/com.openssh.sshd.sb"
sha256 "a273f86360ea5da3910cfa4c118be931d10904267605cdd4b2055ced3a829774"
end
def install
if OS.mac?
ENV.append "CPPFLAGS", "-D__APPLE_SANDBOX_NAMED_EXTERNAL__"
# Ensure sandbox profile prefix is correct.
# We introduce this issue with patching, it's not an upstream bug.
inreplace "sandbox-darwin.c", "@PREFIX@/share/openssh", etc/"ssh"
end
args = *std_configure_args + %W[
--sysconfdir=#{etc}/ssh
--with-ldns
--with-libedit
--with-kerberos5
--with-pam
--with-ssl-dir=#{Formula["openssl@1.1"].opt_prefix}
--with-security-key-builtin
]
args << "--with-privsep-path=#{var}/lib/sshd" if OS.linux?
system "./configure", *args
system "make"
ENV.deparallelize
system "make", "install"
# This was removed by upstream with very little announcement and has
# potential to break scripts, so recreate it for now.
# Debian have done the same thing.
bin.install_symlink bin/"ssh" => "slogin"
buildpath.install resource("com.openssh.sshd.sb")
(etc/"ssh").install "com.openssh.sshd.sb" => "org.openssh.sshd.sb"
end
test do
assert_match "OpenSSH_", shell_output("#{bin}/ssh -V 2>&1")
port = free_port
fork { exec sbin/"sshd", "-D", "-p", port.to_s }
sleep 2
assert_match "sshd", shell_output("lsof -i :#{port}")
end
end