Bug 242673 - net-mgmt/arpwatch: rc script breaks when arpwatch_interfaces contains a dot
Summary: net-mgmt/arpwatch: rc script breaks when arpwatch_interfaces contains a dot
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: Craig Leres
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-12-16 22:31 UTC by Daniel Duerr
Modified: 2019-12-17 05:35 UTC (History)
0 users

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Duerr 2019-12-16 22:31:02 UTC
Hi,

I just installed the 3.0 update and found a bug.  Here’s how we configure arpwatch on our firewalls:

[dd@fw1 etc]$ grep arpwatch /etc/rc.conf
arpwatch_enable="YES"
arpwatch_interfaces="lagg0.6 lagg0.7 lagg0.10"

Here’s what happened on start:

[dd@fw1 dd]$ sudo service arpwatch start
Starting arpwatch.
Version 3.0
usage: arpwatch [-CdFNpqsvzZ] [-D arpdir] [-f datafile] [-i interface]
	 [-P pidfile] [-w watcher@email] [-W watchee@email]
	 [-n net[/width]] [-x net[/width]] [-r file]
/usr/local/etc/rc.d/arpwatch: WARNING: failed to start arpwatch
Starting arpwatch.
Version 3.0
usage: arpwatch [-CdFNpqsvzZ] [-D arpdir] [-f datafile] [-i interface]
	 [-P pidfile] [-w watcher@email] [-W watchee@email]
	 [-n net[/width]] [-x net[/width]] [-r file]
/usr/local/etc/rc.d/arpwatch: WARNING: failed to start arpwatch
Starting arpwatch.
Version 3.0
usage: arpwatch [-CdFNpqsvzZ] [-D arpdir] [-f datafile] [-i interface]
	 [-P pidfile] [-w watcher@email] [-W watchee@email]
	 [-n net[/width]] [-x net[/width]] [-r file]
/usr/local/etc/rc.d/arpwatch: WARNING: failed to start arpwatch

Turns out it was a simple bug in the `eval` of the rc.d/arpwatch script.  Here’s what fixed it for me:

[dd@fw1 etc]$ diff -u rc.d/arpwatch.bad rc.d/arpwatch
--- rc.d/arpwatch.bad	2019-12-16 02:02:32.000000000 -0800
+++ rc.d/arpwatch	2019-12-16 12:33:12.376475000 -0800
@@ -47,7 +47,8 @@
 	if [ $cmd == start ]; then
 		prep_datfile ${fn}
 	fi
-	eval options=\$arpwatch_${interface}_options
+	options_interface=`echo ${interface} | tr '.' '_'`
+	eval options=\$arpwatch_${options_interface}_options
 	command_args="-i ${interface} -f ${fn} -P ${pidfile} ${options}"
 }

My fix is probably a bit primitive, but should help someone make the permanent fix.

Thanks,
Daniel
Comment 1 commit-hook freebsd_committer 2019-12-17 00:53:25 UTC
A commit references this bug:

Author: leres
Date: Tue Dec 17 00:53:08 UTC 2019
New revision: 520290
URL: https://svnweb.freebsd.org/changeset/ports/520290

Log:
  net-mgmt/arpwatch: Fix the rc.d script to handle interface names
  with '.' in them based on a patch from Daniel Duerr. Remove obsolete
  port version of the rc.d script.

  PR:		242673
  Submitted by:	Daniel Duerr
  Approved by:	ler (mentor, implicit)

Changes:
  head/net-mgmt/arpwatch/Makefile
  head/net-mgmt/arpwatch/files/arpwatch.in
  head/net-mgmt/arpwatch/files/patch-arpwatch.sh.in
Comment 2 Craig Leres freebsd_committer 2019-12-17 00:56:18 UTC
I committed a fix based on yours which will be in a future release of arpwatch.

Thanks for the patch!
Comment 3 Daniel Duerr 2019-12-17 05:35:52 UTC
Sweet, thanks Craig!  Happy to help.