Skip to content

Commit b031b21

Browse files
authored
Merge pull request #16133 from jefferyto/addrwatch-fixes-openwrt-19.07
[openwrt-19.07] addrwatch: Update to 1.0.2 and various fixes
2 parents 8798389 + a673a23 commit b031b21

8 files changed

Lines changed: 274 additions & 80 deletions

net/addrwatch/Makefile

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,21 @@
88
include $(TOPDIR)/rules.mk
99

1010
PKG_NAME:=addrwatch
11-
PKG_VERSION:=1.0.1
12-
PKG_RELEASE:=2
11+
PKG_VERSION:=1.0.2
12+
PKG_RELEASE:=3
1313

1414
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
15-
PKG_SOURCE_URL:=https://codeload.github.com/fln/addrwatch/tar.gz/v$(PKG_VERSION)?
16-
PKG_HASH:=be70150a357558481de8488665da1d6efdfa5dc37666d9fa68e8e73a8b59ade6
17-
PKG_LICENSE:=GPL-3.0
15+
PKG_SOURCE_URL:=https://github.com/fln/addrwatch/releases/download/v$(PKG_VERSION)
16+
PKG_HASH:=f04e143da881cd63c299125b592cfb85e4812abbd146f419a1894c00f2ae6208
17+
18+
PKG_MAINTAINER:=Ondrej Caletka <ondrej@caletka.cz>
19+
PKG_LICENSE:=GPL-3.0-or-later
1820
PKG_LICENSE_FILES:=COPYING
19-
PKG_FIXUP:=autoreconf
21+
22+
PKG_INSTALL:=1
23+
PKG_BUILD_PARALLEL:=1
2024
PKG_BUILD_DEPENDS:=USE_UCLIBC:argp-standalone USE_MUSL:argp-standalone
25+
PKG_FIXUP:=autoreconf
2126

2227
include $(INCLUDE_DIR)/package.mk
2328

@@ -27,7 +32,6 @@ define Package/addrwatch
2732
DEPENDS:=+libpcap +libevent2
2833
TITLE:=IPv4/IPv6 and ethernet address pairing tool
2934
URL:=https://github.com/fln/addrwatch
30-
MAINTAINER:=Ondrej Caletka <ondrej@caletka.cz>
3135
endef
3236

3337
define Package/addrwatch/description
@@ -38,12 +42,13 @@ define Package/addrwatch/description
3842
endef
3943

4044
define Package/addrwatch/conffiles
41-
/etc/config/addrwatch
45+
/etc/config/addrwatch
4246
endef
4347

4448
define Package/addrwatch/install
4549
$(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/config $(1)/etc/init.d
46-
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/addrwatch $(1)/usr/sbin/
50+
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/addrwatch $(1)/usr/sbin/
51+
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/addrwatch_syslog $(1)/usr/sbin/
4752
$(INSTALL_BIN) ./files/addrwatch.init $(1)/etc/init.d/addrwatch
4853
$(INSTALL_CONF) ./files/addrwatch.config $(1)/etc/config/addrwatch
4954
endef

net/addrwatch/files/addrwatch.init

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,13 @@ start_instance() {
3636
done
3737

3838
procd_open_instance
39-
procd_set_param command /usr/sbin/addrwatch
40-
[ "$syslog" -eq 1 ] && procd_append_param command --syslog
41-
[ -n "$output" ] && procd_append_param command --output "$output"
42-
[ "$quiet" -eq 1 ] && procd_append_param command --quiet
43-
[ "$verbose" -eq 1 ] && procd_append_param command --verbose
44-
[ "$ipv4only" -eq 1 ] && procd_append_param command --ipv4only
45-
[ "$ipv6only" -eq 1 ] && procd_append_param command --ipv6only
46-
[ -n "$hashsize" ] && procd_append_param command --hashsize "$hashsize"
47-
[ -n "$ratelimit" ] && procd_append_param command --ratelimit "$ratelimit"
39+
procd_set_param command /usr/sbin/addrwatch --quiet
40+
[ -n "$output" ] && procd_append_param command "--output=$output"
41+
[ "$verbose" -eq 1 ] && procd_append_param command "--verbose"
42+
[ "$ipv4only" -eq 1 ] && procd_append_param command "--ipv4-only"
43+
[ "$ipv6only" -eq 1 ] && procd_append_param command "--ipv6-only"
44+
[ -n "$hashsize" ] && procd_append_param command "--hashsize=$hashsize"
45+
[ -n "$ratelimit" ] && procd_append_param command "--ratelimit=$ratelimit"
4846
for blitem in $blacklist; do
4947
procd_append_param command "--blacklist=$blitem"
5048
done
@@ -57,6 +55,17 @@ start_instance() {
5755
done
5856
procd_close_trigger
5957
procd_close_instance
58+
59+
[ "$syslog" -eq 1 ] && {
60+
if [ -x /usr/sbin/addrwatch_syslog ]; then
61+
procd_open_instance
62+
procd_set_param command /usr/sbin/addrwatch_syslog
63+
procd_set_param respawn
64+
procd_close_instance
65+
else
66+
echo "Cannot find /usr/sbin/addrwatch_syslog" >&2
67+
fi
68+
}
6069
}
6170

6271
start_service() {

net/addrwatch/patches/001-fix-sys_siglist.patch

Lines changed: 0 additions & 36 deletions
This file was deleted.

net/addrwatch/patches/002-fix-uclibc-sysconf.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
--- a/src/addrwatch.c
22
+++ b/src/addrwatch.c
3-
@@ -485,7 +485,7 @@ int main(int argc, char *argv[])
3+
@@ -501,7 +501,7 @@ int main(int argc, char *argv[])
44
argp_parse(&argp, argc, argv, 0, &optind, 0);
55

66
if (!cfg.hostname) {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
From 374cfd2cabe4db9882d8a210adff430cc579f859 Mon Sep 17 00:00:00 2001
2+
From: Julius Kriukas <julius@kriukas.lt>
3+
Date: Sun, 8 Mar 2020 12:46:55 +0200
4+
Subject: [PATCH] Use HOST_NAME_MAX+1 to add space for null byte
5+
6+
---
7+
src/addrwatch.c | 2 +-
8+
1 file changed, 1 insertion(+), 1 deletion(-)
9+
10+
--- a/src/addrwatch.c
11+
+++ b/src/addrwatch.c
12+
@@ -501,7 +501,7 @@ int main(int argc, char *argv[])
13+
argp_parse(&argp, argc, argv, 0, &optind, 0);
14+
15+
if (!cfg.hostname) {
16+
- cfg.hostname_len = HOST_NAME_MAX;
17+
+ cfg.hostname_len = HOST_NAME_MAX + 1;
18+
cfg.hostname = (char *)calloc(cfg.hostname_len, sizeof(char));
19+
gethostname(cfg.hostname, cfg.hostname_len);
20+
}

net/addrwatch/patches/003-fix-pkt-hash.patch

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
From 1988f6228225e10bccc50941798f1e1b4ca1ff62 Mon Sep 17 00:00:00 2001
2+
From: Jeffery To <jeffery.to@gmail.com>
3+
Date: Fri, 18 Jun 2021 15:46:47 +0800
4+
Subject: [PATCH] More specific library linking
5+
6+
Currently, the main binary and all output modules are linked to the same
7+
set of libraries. This changes the linking so that only the main binary
8+
is linked to pcap, and only addrwatch_mysql is linked to mysqlclient.
9+
10+
This allows the main binary and output modules to be packaged separately
11+
with fewer dependencies for each individual package.
12+
---
13+
configure.ac | 4 ++--
14+
src/Makefile.am | 3 ++-
15+
2 files changed, 4 insertions(+), 3 deletions(-)
16+
17+
--- a/configure.ac
18+
+++ b/configure.ac
19+
@@ -12,7 +12,7 @@ optional_modules=""
20+
AC_SUBST([optional_modules])
21+
22+
# Checks for libraries.
23+
-AC_CHECK_LIB([pcap], [pcap_open_live])
24+
+AC_CHECK_LIB([pcap], [pcap_open_live], :)
25+
AC_CHECK_LIB([rt], [shm_open])
26+
27+
PKG_CHECK_MODULES(LIBEVENT, [libevent >= 1.4], , [
28+
@@ -46,7 +46,7 @@ AC_ARG_ENABLE([sqlite3],
29+
)
30+
AC_ARG_ENABLE([mysql],
31+
AS_HELP_STRING([--enable-mysql], [Enable MySQL database output]),
32+
- AC_CHECK_LIB([mysqlclient], [mysql_real_connect], , [
33+
+ AC_CHECK_LIB([mysqlclient], [mysql_real_connect], :, [
34+
AC_MSG_ERROR([Unable to find libmysqlclient.])
35+
])
36+
optional_modules="${optional_modules} addrwatch_mysql"
37+
--- a/src/Makefile.am
38+
+++ b/src/Makefile.am
39+
@@ -9,5 +9,6 @@ addrwatch_stdout_SOURCES = addrwatch_std
40+
addrwatch_syslog_SOURCES = addrwatch_syslog.c shm_client.c shm_client.h
41+
addrwatch_mysql_SOURCES = addrwatch_mysql.c shm_client.c shm_client.h util.c util.h
42+
43+
-addrwatch_LDADD = @LIBEVENT_LIBS@
44+
+addrwatch_LDADD = @LIBEVENT_LIBS@ -lpcap
45+
+addrwatch_mysql_LDADD = -lmysqlclient
46+

0 commit comments

Comments
 (0)