miniupnpd: convert to procd daemon

This commit is contained in:
coolsnowwolf 2022-12-21 01:02:22 +08:00
parent 12674bdfbd
commit 1cd7a3d0ca
4 changed files with 47 additions and 20 deletions

View File

@ -11,9 +11,6 @@ PKG_NAME:=miniupnpd
PKG_VERSION:=2.0.20170421
PKG_RELEASE:=3
# Content-Encoding conflict, can refer to this [issue](https://github.com/miniupnp/miniupnp/issues/605)
# so switch mirror repo to http://miniupnp.tuxfamily.org
# PKG_SOURCE_URL:=http://miniupnp.free.fr/files
PKG_SOURCE_URL:=http://miniupnp.tuxfamily.org/files
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_HASH:=9677aeccadf73b4bf8bb9d832c32b5da8266b4d58eed888f3fd43d7656405643

View File

@ -4,7 +4,8 @@
START=94
STOP=15
SERVICE_USE_PID=1
USE_PROCD=1
PROG=/usr/sbin/miniupnpd
upnpd_get_port_range() {
local _var="$1"; shift
@ -62,7 +63,7 @@ boot() {
return
}
start() {
upnpd() {
config_load "upnpd"
local extiface intiface upload download logging secure enabled natpmp
local extip port usesysuptime conffile serial_number model_number
@ -187,22 +188,19 @@ start() {
if [ -n "$ifname" ]; then
# start firewall
iptables -L MINIUPNPD >/dev/null 2>/dev/null || fw3 reload
if [ "$logging" = "1" ]; then
SERVICE_DAEMONIZE=1 \
service_start /usr/sbin/miniupnpd $args -d
else
SERVICE_DAEMONIZE= \
service_start /usr/sbin/miniupnpd $args
fi
else
logger -t "upnp daemon" "external interface not found, not starting"
fi
procd_open_instance
procd_set_param command "$PROG"
procd_set_param respawn
procd_append_param command -f "$tmpconf"
[ "$log_output" = "1" ] && procd_append_param command -d
procd_close_instance
}
stop() {
service_stop /usr/sbin/miniupnpd
stop_service() {
iptables -t nat -F MINIUPNPD 2>/dev/null
iptables -t filter -F MINIUPNPD 2>/dev/null
@ -210,3 +208,12 @@ stop() {
ip6tables -t filter -F MINIUPNPD 2>/dev/null
}
}
start_service() {
config_load "upnpd"
config_foreach upnpd "upnpd"
}
service_triggers() {
procd_add_reload_trigger "upnpd"
}

View File

@ -0,0 +1,25 @@
--- a/miniupnpd.c
+++ b/miniupnpd.c
@@ -1727,21 +1727,7 @@ init(int argc, char * * argv, struct runtime_vars * v)
}
}
- if(debug_flag)
- {
- pid = getpid();
- }
- else
- {
-#ifdef USE_DAEMON
- if(daemon(0, 0)<0) {
- perror("daemon()");
- }
- pid = getpid();
-#else
- pid = daemonize();
-#endif
- }
+ pid = getpid();
openlog_option = LOG_PID|LOG_CONS;
if(debug_flag)

View File

@ -1,7 +1,5 @@
Index: miniupnpd-2.0.20170421/netfilter/iptcrdr.c
===================================================================
--- miniupnpd-2.0.20170421.orig/netfilter/iptcrdr.c
+++ miniupnpd-2.0.20170421/netfilter/iptcrdr.c
--- a/netfilter/iptcrdr.c
+++ b/netfilter/iptcrdr.c
@@ -1116,9 +1116,13 @@ addnatrule(int proto, unsigned short epo
} else {
match = get_udp_match(eport, 0);