arpwatch: add arpwatch as common package

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
This commit is contained in:
Vincent Li
2025-09-25 21:36:38 +00:00
parent ca64eb8761
commit a81b1f8f2b
8 changed files with 248 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
# Interface to monitor
INTERFACES="green0 blue0"
# Email address to send alerts to
WATCHER=hostmaster@somewhere.example.com
# Sender email address
WATCHEE=hostmaster@somewhere.example.com

View File

@@ -0,0 +1,81 @@
#!/bin/sh
###############################################################################
# #
# IPFire.org - A linux based firewall #
# Copyright (C) 2007-2022 IPFire Team <info@ipfire.org> #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
###############################################################################
. /etc/sysconfig/rc
. ${rc_functions}
# Optionally load the configuration file
if [ -r "/etc/sysconfig/arpwatch" ]; then
. /etc/sysconfig/arpwatch
fi
case "${1}" in
start)
args=(
-D /var/lib/arpwatch
)
# Add the watcher
if [ -n "${WATCHER}" ]; then
args+=( "-w" "${WATCHER}" )
fi
# Add the watchee
if [ -n "${WATCHEE}" ]; then
args+=( "-W" "${WATCHEE}" )
fi
for intf in ${INTERFACES}; do
boot_mesg "Starting ARP Watch on ${intf}..."
# Create the data file for this interface
if [ ! -e "/var/lib/arpwatch/${intf}.dat" ]; then
: > "/var/lib/arpwatch/${intf}.dat"
fi
PIDFILE="/var/run/arpwatch-${intf}.pid" \
loadproc -f \
/usr/sbin/arpwatch "${args[@]}" \
-P "/var/run/arpwatch-${intf}.pid" \
-f "/var/lib/arpwatch/${intf}.dat" \
-i "${intf}"
done
;;
stop)
for intf in ${INTERFACES}; do
boot_mesg "Stopping ARP Watch on ${intf}..."
PIDFILE="/var/run/arpwatch-${intf}.pid" \
killproc /usr/sbin/arpwatch
done
;;
restart)
${0} stop
sleep 1
${0} start
;;
*)
echo "Usage: ${0} {start|stop|restart}"
exit 1
;;
esac

View File

@@ -0,0 +1,25 @@
Description: replace private function _getshort with ns_get16
_getshort is a private function, triggers a build log warning because it's
not present in any header file. We switch to the functionally equivalent
ns_get16.
Author: Lukas Schwaighofer <lukas@schwaighofer.name>
---
dns.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
--- a/dns.c
+++ b/dns.c
@@ -115,10 +115,10 @@
(u_char *)cp, (char *)bp, buflen)) < 0)
break;
cp += n;
- type = _getshort(cp);
+ type = ns_get16(cp);
cp += sizeof(u_short); /* class */
cp += sizeof(u_short) + sizeof(u_int32_t);
- n = _getshort(cp);
+ n = ns_get16(cp);
cp += sizeof(u_short);
if (type == T_HINFO) {
/* Unpack */