From f4ea97c1fa6f430d57cfecee8dff9f297ef99c30 Mon Sep 17 00:00:00 2001 From: cyrus Date: Fri, 30 May 2014 10:26:27 +0000 Subject: [PATCH] miniupnpd: moved and updated in routing feed git-svn-id: svn://svn.openwrt.org/openwrt/packages@40883 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- net/miniupnpd/Makefile | 67 -------- net/miniupnpd/files/firewall.include | 15 -- net/miniupnpd/files/miniupnpd.defaults | 13 -- net/miniupnpd/files/miniupnpd.hotplug | 8 - net/miniupnpd/files/miniupnpd.init | 184 --------------------- net/miniupnpd/files/upnpd.config | 25 --- .../100-gracefully-handle-missing-ipv6.patch | 120 -------------- 7 files changed, 432 deletions(-) delete mode 100644 net/miniupnpd/Makefile delete mode 100644 net/miniupnpd/files/firewall.include delete mode 100644 net/miniupnpd/files/miniupnpd.defaults delete mode 100644 net/miniupnpd/files/miniupnpd.hotplug delete mode 100644 net/miniupnpd/files/miniupnpd.init delete mode 100644 net/miniupnpd/files/upnpd.config delete mode 100644 net/miniupnpd/patches/100-gracefully-handle-missing-ipv6.patch diff --git a/net/miniupnpd/Makefile b/net/miniupnpd/Makefile deleted file mode 100644 index ec5a132a9..000000000 --- a/net/miniupnpd/Makefile +++ /dev/null @@ -1,67 +0,0 @@ -# -# Copyright (C) 2006-2013 OpenWrt.org -# -# This is free software, licensed under the GNU General Public License v2. -# See /LICENSE for more information. -# - -include $(TOPDIR)/rules.mk - -PKG_NAME:=miniupnpd -PKG_VERSION:=1.8.20130426 -PKG_RELEASE:=1 - -PKG_SOURCE_URL:=http://miniupnp.free.fr/files -PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz -PKG_MD5SUM:=ca5344eba200e4a6d1313849d68310f6 - -include $(INCLUDE_DIR)/package.mk - -define Package/miniupnpd - SECTION:=net - CATEGORY:=Network - DEPENDS:=+iptables +libip4tc +IPV6:libip6tc +libnfnetlink - TITLE:=Lightweight UPnP daemon - SUBMENU:=Firewall - URL:=http://miniupnp.free.fr/ - MAINTAINER:=Daniel Dickinson -endef - -define Package/miniupnpd/conffiles -/etc/config/upnpd -endef - -define Package/miniupnpd/postinst -#!/bin/sh - -if [ -z "$$IPKG_INSTROOT" ]; then - ( . /etc/uci-defaults/99-miniupnpd ) - rm -f /etc/uci-defaults/99-miniupnpd -fi - -exit 0 -endef - -define Build/Prepare - $(call Build/Prepare/Default) - echo "OpenWrt/$(OPENWRTVERSION)" | tr \(\)\ _ >$(PKG_BUILD_DIR)/os.openwrt -endef - -MAKE_FLAGS += \ - LIBS="" \ - CC="$(TARGET_CC) -DIPTABLES_143 -lnfnetlink -lip4tc $(if $(CONFIG_IPV6),-lip6tc)" \ - CONFIG_OPTIONS="$(if $(CONFIG_IPV6),--ipv6) --leasefile" \ - -f Makefile.linux \ - miniupnpd - -define Package/miniupnpd/install - $(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/init.d $(1)/etc/config $(1)/etc/uci-defaults $(1)/etc/hotplug.d/iface $(1)/usr/share/miniupnpd - $(INSTALL_BIN) $(PKG_BUILD_DIR)/miniupnpd $(1)/usr/sbin/miniupnpd - $(INSTALL_BIN) ./files/miniupnpd.init $(1)/etc/init.d/miniupnpd - $(INSTALL_CONF) ./files/upnpd.config $(1)/etc/config/upnpd - $(INSTALL_DATA) ./files/miniupnpd.hotplug $(1)/etc/hotplug.d/iface/50-miniupnpd - $(INSTALL_DATA) ./files/miniupnpd.defaults $(1)/etc/uci-defaults/99-miniupnpd - $(INSTALL_DATA) ./files/firewall.include $(1)/usr/share/miniupnpd/firewall.include -endef - -$(eval $(call BuildPackage,miniupnpd)) diff --git a/net/miniupnpd/files/firewall.include b/net/miniupnpd/files/firewall.include deleted file mode 100644 index 64c58214a..000000000 --- a/net/miniupnpd/files/firewall.include +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh -# miniupnpd integration for firewall3 - -iptables -t filter -N MINIUPNPD 2>/dev/null -iptables -t nat -N MINIUPNPD 2>/dev/null - -local ext_iface -for ext_iface in $(uci -q get upnpd.config.external_iface); do - local ext_zone - for ext_zone in $(fw3 -q network "$ext_iface"); do - iptables -t filter -I zone_${ext_zone}_forward -j MINIUPNPD - iptables -t nat -I zone_${ext_zone}_prerouting -j MINIUPNPD - done -done - diff --git a/net/miniupnpd/files/miniupnpd.defaults b/net/miniupnpd/files/miniupnpd.defaults deleted file mode 100644 index c6bc19a87..000000000 --- a/net/miniupnpd/files/miniupnpd.defaults +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -uci -q batch <<-EOT - delete firewall.miniupnpd - set firewall.miniupnpd=include - set firewall.miniupnpd.type=script - set firewall.miniupnpd.path=/usr/share/miniupnpd/firewall.include - set firewall.miniupnpd.family=IPv4 - set firewall.miniupnpd.reload=1 - commit firewall -EOT - -exit 0 diff --git a/net/miniupnpd/files/miniupnpd.hotplug b/net/miniupnpd/files/miniupnpd.hotplug deleted file mode 100644 index 472b8c2e7..000000000 --- a/net/miniupnpd/files/miniupnpd.hotplug +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -/etc/init.d/miniupnpd enabled && [ "$ACTION" = "ifup" ] && { - local iface - for iface in $(uci_get upnpd config internal_iface; uci_get upnpd config external_iface); do - [ "$INTERFACE" = "$iface" ] && /etc/init.d/miniupnpd restart - done -} diff --git a/net/miniupnpd/files/miniupnpd.init b/net/miniupnpd/files/miniupnpd.init deleted file mode 100644 index ef67d7246..000000000 --- a/net/miniupnpd/files/miniupnpd.init +++ /dev/null @@ -1,184 +0,0 @@ -#!/bin/sh /etc/rc.common -# Copyright (C) 2006-2011 OpenWrt.org - -START=95 - -SERVICE_USE_PID=1 - -upnpd_get_port_range() { - local _var="$1"; shift - local _val - - config_get _val "$@" - - case "$_val" in - [0-9]*[:-][0-9]*) - export -n -- "${_var}_start=${_val%%[:-]*}" - export -n -- "${_var}_end=${_val##*[:-]}" - ;; - [0-9]*) - export -n -- "${_var}_start=$_val" - export -n -- "${_var}_end=" - ;; - esac -} - -conf_rule_add() { - local cfg="$1" - local tmpconf="$2" - local action external_port_start external_port_end int_addr - local internal_port_start internal_port_end - - config_get action "$cfg" action "deny" # allow or deny - upnpd_get_port_range "ext" "$cfg" ext_ports "0-65535" # external ports: x, x-y, x:y - config_get int_addr "$cfg" int_addr "0.0.0.0/0" # ip or network and subnet mask (internal) - upnpd_get_port_range "int" "$cfg" int_ports "0-65535" # internal ports: x, x-y, x:y or range - - # Make a single IP IP/32 so that miniupnpd.conf can use it. - case "$int_addr" in - */*) ;; - *) int_addr="$int_addr/32" ;; - esac - - echo "${action} ${ext_start}${ext_end:+-}${ext_end} ${int_addr} ${int_start}${int_end:+-}${int_end}" >>$tmpconf -} - -upnpd_write_bool() { - local opt="$1" - local def="${2:-0}" - local alt="$3" - local val - - config_get_bool val config "$opt" "$def" - if [ "$val" -eq 0 ]; then - echo "${alt:-$opt}=no" >> $tmpconf - else - echo "${alt:-$opt}=yes" >> $tmpconf - fi -} - -boot() { - return -} - -start() { - config_load "upnpd" - local extiface intiface upload download logging secure enabled natpmp - local extip port usesysuptime conffile serial_number model_number - local uuid notify_interval presentation_url enable_upnp - local upnp_lease_file clean_ruleset_threshold clean_ruleset_interval - - config_get extiface config external_iface - config_get intiface config internal_iface - config_get extip config external_ip - config_get port config port 5000 - config_get upload config upload - config_get download config download - config_get_bool logging config log_output 0 - config_get conffile config config_file - config_get serial_number config serial_number - config_get model_number config model_number - config_get uuid config uuid - config_get notify_interval config notify_interval - config_get presentation_url config presentation_url - config_get upnp_lease_file config upnp_lease_file - config_get clean_ruleset_threshold config clean_ruleset_threshold - config_get clean_ruleset_interval config clean_ruleset_interval - - local args - - . /lib/functions/network.sh - - local ifname - network_get_device ifname ${extiface:-wan} - - if [ -n "$conffile" ]; then - args="-f $conffile" - else - local tmpconf="/var/etc/miniupnpd.conf" - args="-f $tmpconf" - mkdir -p /var/etc - - echo "ext_ifname=$ifname" >$tmpconf - - [ -n "$extip" ] && \ - echo "ext_ip=$extip" >>$tmpconf - - local iface - for iface in ${intiface:-lan}; do - local device - network_get_device device "$iface" && { - echo "listening_ip=$device" >>$tmpconf - } - done - - [ "$port" != "auto" ] && \ - echo "port=$port" >>$tmpconf - - config_load "upnpd" - upnpd_write_bool enable_natpmp 1 - upnpd_write_bool enable_upnp 1 - upnpd_write_bool secure_mode 1 - upnpd_write_bool system_uptime 1 - - [ -n "$upnp_lease_file" ] && \ - echo "lease_file=$upnp_lease_file" >>$tmpconf - - [ -n "$upload" -a -n "$download" ] && { - echo "bitrate_down=$(($download * 1024 * 8))" >>$tmpconf - echo "bitrate_up=$(($upload * 1024 * 8))" >>$tmpconf - } - - [ -n "${presentation_url}" ] && \ - echo "presentation_url=${presentation_url}" >>$tmpconf - - [ -n "${notify_interval}" ] && \ - echo "notify_interval=${notify_interval}" >>$tmpconf - - [ -n "${clean_ruleset_threshold}" ] && \ - echo "clean_ruleset_threshold=${clean_ruleset_threshold}" >>$tmpconf - - [ -n "${clean_ruleset_interval}" ] && \ - echo "clean_ruleset_interval=${clean_ruleset_interval}" >>$tmpconf - - [ -z "$uuid" ] && { - uuid="$(cat /proc/sys/kernel/random/uuid)" - uci set upnpd.config.uuid=$uuid - uci commit upnpd - } - - [ "$uuid" = "nocli" ] || \ - echo "uuid=$uuid" >>$tmpconf - - [ -n "${serial_number}" ] && \ - echo "serial=${serial_number}" >>$tmpconf - - [ -n "${model_number}" ] && \ - echo "model_number=${model_number}" >>$tmpconf - - config_foreach conf_rule_add perm_rule "$tmpconf" - fi - - - 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 -} - -stop() { - service_stop /usr/sbin/miniupnpd - - iptables -t nat -F MINIUPNPD 2>/dev/null - iptables -t filter -F MINIUPNPD 2>/dev/null -} diff --git a/net/miniupnpd/files/upnpd.config b/net/miniupnpd/files/upnpd.config deleted file mode 100644 index 002e20716..000000000 --- a/net/miniupnpd/files/upnpd.config +++ /dev/null @@ -1,25 +0,0 @@ -config upnpd config - option enable_natpmp 1 - option enable_upnp 1 - option secure_mode 1 - option log_output 0 - option download 1024 - option upload 512 - option external_iface wan - option internal_iface lan - option port 5000 - option upnp_lease_file /var/upnp.leases - -config perm_rule - option action allow - option ext_ports 1024-65535 - option int_addr 0.0.0.0/0 # Does not override secure_mode - option int_ports 1024-65535 - option comment "Allow high ports" - -config perm_rule - option action deny - option ext_ports 0-65535 - option int_addr 0.0.0.0/0 - option int_ports 0-65535 - option comment "Default deny" diff --git a/net/miniupnpd/patches/100-gracefully-handle-missing-ipv6.patch b/net/miniupnpd/patches/100-gracefully-handle-missing-ipv6.patch deleted file mode 100644 index 9378dedb4..000000000 --- a/net/miniupnpd/patches/100-gracefully-handle-missing-ipv6.patch +++ /dev/null @@ -1,120 +0,0 @@ ---- a/miniupnpd.c -+++ b/miniupnpd.c -@@ -106,25 +106,20 @@ volatile sig_atomic_t should_send_public - /* OpenAndConfHTTPSocket() : - * setup the socket used to handle incoming HTTP connections. */ - static int --OpenAndConfHTTPSocket(unsigned short port) -+OpenAndConfHTTPSocket(unsigned short port, int family) - { - int s; - int i = 1; --#ifdef ENABLE_IPV6 -- struct sockaddr_in6 listenname; --#else -- struct sockaddr_in listenname; --#endif -+ struct sockaddr_storage listenname; -+ struct sockaddr_in *ln4 = (struct sockaddr_in *)&listenname; -+ struct sockaddr_in6 *ln6 = (struct sockaddr_in6 *)&listenname; - socklen_t listenname_len; - -- if( (s = socket( --#ifdef ENABLE_IPV6 -- PF_INET6, --#else -- PF_INET, --#endif -- SOCK_STREAM, 0)) < 0) -+ if( (s = socket(family, SOCK_STREAM, 0)) < 0) - { -+ if ((family == AF_INET6) && (errno == EAFNOSUPPORT)) -+ return OpenAndConfHTTPSocket(port, AF_INET); -+ - syslog(LOG_ERR, "socket(http): %m"); - return -1; - } -@@ -147,18 +142,20 @@ OpenAndConfHTTPSocket(unsigned short por - syslog(LOG_WARNING, "set_non_blocking(http): %m"); - } - --#ifdef ENABLE_IPV6 -- memset(&listenname, 0, sizeof(struct sockaddr_in6)); -- listenname.sin6_family = AF_INET6; -- listenname.sin6_port = htons(port); -- listenname.sin6_addr = in6addr_any; -- listenname_len = sizeof(struct sockaddr_in6); --#else -- listenname.sin_family = AF_INET; -- listenname.sin_port = htons(port); -- listenname.sin_addr.s_addr = htonl(INADDR_ANY); -- listenname_len = sizeof(struct sockaddr_in); --#endif -+ memset(&listenname, 0, sizeof(listenname)); -+ ln6->sin6_family = family; -+ ln6->sin6_port = htons(port); -+ -+ if (family == AF_INET6) -+ { -+ ln6->sin6_addr = in6addr_any; -+ listenname_len = sizeof(struct sockaddr_in6); -+ } -+ else -+ { -+ ln4->sin_addr.s_addr = htonl(INADDR_ANY); -+ listenname_len = sizeof(struct sockaddr_in); -+ } - - if(bind(s, (struct sockaddr *)&listenname, listenname_len) < 0) - { -@@ -1254,6 +1251,9 @@ main(int argc, char * * argv) - int sudp = -1; /* IP v4 socket for receiving SSDP */ - #ifdef ENABLE_IPV6 - int sudpv6 = -1; /* IP v6 socket for receiving SSDP */ -+ int addr_family = AF_INET6; -+#else -+ int addr_family = AF_INET; - #endif - #ifdef ENABLE_NATPMP - int * snatpmp = NULL; -@@ -1338,7 +1338,7 @@ main(int argc, char * * argv) - { - - /* open socket for HTTP connections. Listen on the 1st LAN address */ -- shttpl = OpenAndConfHTTPSocket((v.port > 0) ? v.port : 0); -+ shttpl = OpenAndConfHTTPSocket((v.port > 0) ? v.port : 0, addr_family); - if(shttpl < 0) - { - syslog(LOG_ERR, "Failed to open socket for HTTP. EXITING"); ---- a/minissdp.c -+++ b/minissdp.c -@@ -277,8 +277,6 @@ OpenAndConfSSDPNotifySockets(int * socke - i++; - #ifdef ENABLE_IPV6 - sockets[i] = OpenAndConfSSDPNotifySocketIPv6(lan_addr->index); -- if(sockets[i] < 0) -- goto error; - i++; - #endif - } -@@ -495,6 +493,9 @@ SendSSDPNotifies(int s, const char * hos - int i=0; - char ver_str[4]; - -+ if (s < 0) -+ return; -+ - memset(&sockname, 0, sizeof(sockname)); - #ifdef ENABLE_IPV6 - if(ipv6) -@@ -868,6 +869,10 @@ SendSSDPGoodbye(int * sockets, int n_soc - #ifdef ENABLE_IPV6 - ipv6 = j & 1; - #endif -+ -+ if (sockets[j] < 0) -+ continue; -+ - for(i=0; known_service_types[i].s; i++) - { - if(i==0) -- 2.11.0