class Sshguard < Formula desc "Protect from brute force attacks against SSH" homepage "http://www.sshguard.net/" url "https://downloads.sourceforge.net/project/sshguard/sshguard/1.7.1/sshguard-1.7.1.tar.gz" sha256 "2e527589c9b33219222d827dff63974229d044de945729aa47271c4a29aaa195" version_scheme 1 bottle do rebuild 1 sha256 "d2dd3b58c7e5d2a43b8bc98c13e81a40c060ab2ee04c7b21861cf55a49d1a4d3" => :sierra sha256 "7d2899ef89c63d76c1df72699d0a0e9097e23dfafe5b70232bbeedfeb35f0340" => :el_capitan sha256 "143a53ee53f8ad7ce7ac1afb445705e8d8e580a80f8a14ce5f3db199b45745df" => :yosemite end depends_on "automake" => :build depends_on "autoconf" => :build def install system "./configure", "--disable-debug", "--disable-dependency-tracking", "--disable-silent-rules", "--prefix=#{prefix}", "--with-firewall=#{firewall}" system "make", "install" end def firewall MacOS.version >= :lion ? "pf" : "ipfw" end def log_path MacOS.version >= :lion ? "/var/log/system.log" : "/var/log/secure.log" end def caveats if MacOS.version >= :lion then <<-EOS.undent Add the following lines to /etc/pf.conf to block entries in the sshguard table (replace $ext_if with your WAN interface): table persist block in quick on $ext_if proto tcp from to any port 22 label "ssh bruteforce" Then run sudo pfctl -f /etc/pf.conf to reload the rules. EOS end end plist_options :startup => true def plist; <<-EOS.undent Label #{plist_name} KeepAlive ProgramArguments #{opt_sbin}/sshguard -l #{log_path} RunAtLoad EOS end test do assert_match version.to_s, shell_output("#{sbin}/sshguard -v 2>&1", 64) end end