Bug 201323 - security/sshguard convert to OPTIONS & add new null backend
Summary: security/sshguard convert to OPTIONS & add new null backend
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Mark Felder
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-07-04 05:52 UTC by Alastair Hogge
Modified: 2015-10-09 14:54 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (feld)


Attachments
Convert all sshguard ports into one port & make use the OPTIONS framework (4.33 KB, patch)
2015-07-04 05:52 UTC, Alastair Hogge
no flags Details | Diff
Udpated patch to make use of .elif for OPTIONS (4.31 KB, patch)
2015-07-04 06:30 UTC, Alastair Hogge
no flags Details | Diff
sshguard-null slave port (3.19 KB, patch)
2015-07-17 14:26 UTC, Mark Felder
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alastair Hogge 2015-07-04 05:52:24 UTC
Created attachment 158319 [details]
Convert all sshguard ports into one port & make use the OPTIONS framework

Hi,

Patch that converts the sshguard(8) port to use the OPTIONS framework which eliminates the slave ports.  Patch also includes support for the NULL backend.  The NULL back does not call any firewall command at all, it can however, be used to call a custom script or binary.  Users can specify a custom script or binary by:
# sysrc sshguard_flags="-e /usr/local/sbin/sshguard-null"

Attached is the patch to convert all sshguard ports into one port. Following is sample custom script to call ipfw(4) making use of the table name sshguard instead of a table number:

$ cat /usr/local/sbin/sshguard-null 
#!/bin/sh

# Sourced from:
# https://sourceforge.net/p/sshguard/mailman/message/34151601/

fwcmd="/sbin/ipfw"
table_id="sshguard"
print_debug="0"

fwcmd_debug() {
        if [ ${print_debug} -gt 0 ]; then
                /usr/bin/logger -i -p local0.notice -t sshguard-null ${@}
        fi
}

fwcmd_debug "${0}: Incoming sshguard(8) action"

case ${SSHG_ACTION} in
        init)
                fwcmd_debug "${SSHG_ACTION}"
                ;;
        fin)
                fwcmd_debug "${fwcmd} table ${table_id} flush"
                ${fwcmd} table ${table_id} flush
                ;;
        block)
                fwcmd_debug "${fwcmd} table ${table_id} add ${SSHG_ADDR}"
                ${fwcmd} table ${table_id} add ${SSHG_ADDR}
                ;;
        block_list)
                for a in `echo ${SSHG_ADDR} | sed 's/,/ /g'` ; do
                        fwcmd_debug "${fwcmd} table ${table_id} add ${a}"
                        ${fwcmd} table ${table_id} add ${a}
                done
                ;;
        release)
                fwcmd_debug "${fwcmd} table ${table_id} delete ${SSHG_ADDR}"
                ${fwcmd} table ${table_id} delete ${SSHG_ADDR}
                ;;
        flush)
                fwcmd_debug "${fwcmd} table ${table_id} flush"
                ${fwcmd} table ${table_id} flush
                ;;
        *)
                fwcmd_debug "${SSHG_ACTION} unsupported"
                ;;
esac

exit 0
Comment 1 Alastair Hogge 2015-07-04 06:30:04 UTC
Created attachment 158321 [details]
Udpated patch to make use of .elif for OPTIONS
Comment 2 Mark Felder freebsd_committer freebsd_triage 2015-07-06 00:34:09 UTC
Hello,

This is great work. However I have just realized that the primary benefit of the slave ports is that official packages are built for each backend. After this change users will have to compile their own sshguard if they did not want the default backend OPTION (null) and very few people will want that backend.

Even if we change the default OPTION to a more popular backend like pf I am still unsure how many users this will displace. I will need to think about this for a while and maybe consult with some others.

Please do not be discouraged from submitting future patches to ports. Patches are *good* and invoke important thought and discussion. :-)


Cheers!
Comment 3 Alastair Hogge 2015-07-17 07:51:46 UTC
(In reply to Mark Felder from comment #2)

When time permits, I will submit another patch that adds a separate security/sshguard-null port.

It is my understanding that there is work in progress for pkg to handle different flavours of the one port; the flavours coming from the configurable port options.  Perhaps we could review the single sshguard port then?
Comment 4 Mark Felder freebsd_committer freebsd_triage 2015-07-17 13:57:07 UTC
(In reply to Alastair Hogge from comment #3)

Yes that would be the ideal way to approach this.

I'll take a quick look at creating another slave port for the null backend. I'm sure it's easy.
Comment 5 Mark Felder freebsd_committer freebsd_triage 2015-07-17 14:20:48 UTC
reopening so we can get an sshguard-null slave port
Comment 6 Mark Felder freebsd_committer freebsd_triage 2015-07-17 14:26:11 UTC
Created attachment 158911 [details]
sshguard-null slave port

Would you mind testing this patch?
Comment 7 Alastair Hogge 2015-07-26 02:56:25 UTC
(In reply to Mark Felder from comment #6)
Tested & works.  Thanks
Comment 8 commit-hook freebsd_committer freebsd_triage 2015-07-26 15:05:08 UTC
A commit references this bug:

Author: feld
Date: Sun Jul 26 15:04:37 UTC 2015
New revision: 392923
URL: https://svnweb.freebsd.org/changeset/ports/392923

Log:
  security/sshguard-null

  portable do-nothing backend for applying detection but not prevention

  PR:		201323

Changes:
  head/security/Makefile
  head/security/sshguard/Makefile
  head/security/sshguard-ipfilter/Makefile
  head/security/sshguard-ipfw/Makefile
  head/security/sshguard-null/
  head/security/sshguard-null/Makefile
  head/security/sshguard-pf/Makefile