diff options
| author | Saverio Proto <zioproto@gmail.com> | 2013-05-11 14:45:52 +0200 |
|---|---|---|
| committer | Saverio Proto <zioproto@gmail.com> | 2013-05-11 14:45:52 +0200 |
| commit | d1183c96df3006d7cc31aba14f0ae800f5caf5a9 (patch) | |
| tree | 202713eb6dc20f7f19d7f4726386f5eb3d326699 /nodogsplash | |
| parent | b8e14d8ec6258721fec9f0349b9b126aaa7130f0 (diff) | |
Rename to subfolder to import into openwrt-routing repository
Diffstat (limited to 'nodogsplash')
| -rw-r--r-- | nodogsplash/Makefile | 79 | ||||
| -rw-r--r-- | nodogsplash/files/nodogsplash.init | 176 | ||||
| -rw-r--r-- | nodogsplash/patches/001-crash_on_missing_rdir_param.patch | 18 | ||||
| -rw-r--r-- | nodogsplash/patches/002-deprecated_iptables_syntax.patch | 11 |
4 files changed, 284 insertions, 0 deletions
diff --git a/nodogsplash/Makefile b/nodogsplash/Makefile new file mode 100644 index 0000000..69ac310 --- /dev/null +++ b/nodogsplash/Makefile @@ -0,0 +1,79 @@ +# +# Copyright (C) 2007-2012 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:=nodogsplash +PKG_VERSION:=0.9_beta9.9.6 +PKG_RELEASE:=3 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=http://kokoro.ucsd.edu/nodogsplash/ \ + http://kokoro.ucsd.edu/nodogsplash/old/ +PKG_MD5SUM:=3ba0d862b4d63ecf97f16176a486faed + +PKG_FIXUP:=autoreconf +PKG_BUILD_PARALLEL:=1 +PKG_INSTALL:=1 + +include $(INCLUDE_DIR)/package.mk + +define Package/nodogsplash + SUBMENU:=Captive Portals + SECTION:=net + CATEGORY:=Network + DEPENDS:=+libpthread +iptables-mod-ipopt + TITLE:=Open public network gateway daemon + URL:=http://kokoro.ucsd.edu/nodogsplash/ +endef + +define Package/nodogsplash/description + Nodogsplash offers a simple way to open a free hotspot providing restricted access to an + internet connection. It is intended for use on wireless access points running OpenWRT + (but may also work on other Linux-based devices). +endef + +define Build/Configure + $(call Build/Configure/Default,\ + --enable-static \ + --enable-shared \ + ) +endef + +define Build/Compile + $(call Build/Compile/Default, \ + mkinstalldirs="$(INSTALL_DIR)") +endef + +define Build/Install + mkdir -p $(PKG_INSTALL_DIR)/usr/{share{,/doc/$(PKG_NAME)-$(PKG_VERSION)},lib,include{,/nodogsplash},bin,sbin}/ + $(call Build/Install/Default, \ + mkinstalldirs="$(INSTALL_DIR)" \ + install) +endef + +define Package/nodogsplash/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/* $(1)/usr/bin/ + $(INSTALL_DIR) $(1)/usr/lib/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/* $(1)/usr/lib/ + $(INSTALL_DIR) $(1)/etc/$(PKG_NAME) + $(INSTALL_CONF) $(PKG_BUILD_DIR)/$(PKG_NAME).conf $(1)/etc/$(PKG_NAME)/ + $(SED) 's,br0,br-lan,' $(1)/etc/$(PKG_NAME)/$(PKG_NAME).conf + $(CP) $(PKG_BUILD_DIR)/htdocs $(1)/etc/$(PKG_NAME)/ + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/$(PKG_NAME).init $(1)/etc/init.d/$(PKG_NAME) + $(SED) 's,\(do_module_tests "imq"\),#\1,' $(1)/etc/init.d/$(PKG_NAME) + $(SED) 's,\(do_module_tests "ipt_IMQ"\),#\1,' $(1)/etc/init.d/$(PKG_NAME) + $(SED) 's,\(do_module_tests "sch_htb"\),#\1,' $(1)/etc/init.d/$(PKG_NAME) +endef + +define Package/nodogsplash/conffiles +/etc/nodogsplash/nodogsplash.conf +endef + +$(eval $(call BuildPackage,nodogsplash)) diff --git a/nodogsplash/files/nodogsplash.init b/nodogsplash/files/nodogsplash.init new file mode 100644 index 0000000..7eba60b --- /dev/null +++ b/nodogsplash/files/nodogsplash.init @@ -0,0 +1,176 @@ +#!/bin/sh /etc/rc.common +# +# description: Startup/shutdown script for nodogsplash captive portal +# +# P. Kube 2007 +# +# (Based on wifidog startup script +# Date : 2004-08-25 +# Version : 1.0 +# Comment by that author: Could be better, but it's working as expected) +# + + +IPT=/usr/sbin/iptables +WD_DIR=/usr/bin +OPTIONS="" +START=65 +STOP=65 +# -s -d 5 runs in background, with level 5 (not so verbose) messages to syslog +# -f -d 7 runs in foreground, with level 7 (verbose) debug messages to terminal +# N.B.: -f will fail if starting at boot from rcS +#OPTIONS="-s -d 5" + +start() { + echo "Starting nodogsplash ... " + if $WD_DIR/ndsctl status 2> /dev/null; then + echo "FAILED: nodogsplash already running" + else + if test_module && $WD_DIR/nodogsplash $OPTIONS; then + echo "OK: nodogsplash started" + else + echo "FAILED: nodogsplash exited with non 0 status" + fi + fi +} + +stop() { + echo "Stopping nodogsplash ... " + if $WD_DIR/ndsctl status 2> /dev/null; then + if $WD_DIR/ndsctl stop; then + echo "OK: nodogsplash stopped" + else + echo "FAILED: ndsctl stop exited with non 0 status" + fi + else + echo "FAILED: nodogsplash was not running" + fi +} + +status() { + $WD_DIR/ndsctl status +} + +test_module() { + + ### Test ipt_mark with iptables + test_ipt_mark () { + ($IPT -A FORWARD -m mark --mark 2 -j ACCEPT 2>&1) > /dev/null + IPTABLES_OK=$? + if [ "$IPTABLES_OK" -eq 0 ]; then + ($IPT -D FORWARD -m mark --mark 2 -j ACCEPT 2>&1) > /dev/null + return 0 + else + return 1 + fi + } + ### Test ipt_mac with iptables + test_ipt_mac () { + ($IPT -A INPUT -m mac --mac-source 00:00:00:00:00:00 -j ACCEPT 2>&1) > /dev/null + IPTABLES_OK=$? + if [ "$IPTABLES_OK" -eq 0 ]; then + ($IPT -D INPUT -m mac --mac-source 00:00:00:00:00:00 -j ACCEPT 2>&1) > /dev/null + return 0 + else + return 1 + fi + } + + ### Test ipt_IMQ with iptables + test_ipt_IMQ () { + ($IPT -t mangle -A PREROUTING -j IMQ --todev 0 2>&1) > /dev/null + IPTABLES_OK=$? + if [ "$IPTABLES_OK" -eq 0 ]; then + ($IPT -t mangle -D PREROUTING -j IMQ --todev 0 2>&1) > /dev/null + return 0 + else + return 1 + fi + } + + ### Test imq with ip + test_imq () { + (ip link set imq0 up 2>&1) > /dev/null + IMQ0_OK=$? + (ip link set imq1 up 2>&1) > /dev/null + IMQ1_OK=$? + if [ "$IMQ0_OK" -eq 0 -a "$IMQ1_OK" -eq 0 ]; then + (ip link set imq0 down 2>&1) > /dev/null + (ip link set imq1 down 2>&1) > /dev/null + return 0 + else + return 1 + fi + } + + ### Test sch_htb with tc; requires imq0 + test_sch_htb () { + (tc qdisc del dev imq0 root 2>&1) > /dev/null + (tc qdisc add dev imq0 root htb 2>&1) > /dev/null + TC_OK=$? + if [ "$TC_OK" -eq 0 ]; then + (tc qdisc del dev imq0 root 2>&1) > /dev/null + return 0 + else + return 1 + fi + } + + + ### Find a module on disk + module_exists () { + EXIST=$(find /lib/modules/`uname -r` -name $1.*o 2> /dev/null) + if [ -n "$EXIST" ]; then + return 0 + else + return 1 + fi + } + + ### Test if a module is in memory + module_in_memory () { + MODULE=$(lsmod | grep $1 | awk '{print $1}') + if [ "$MODULE" = "$1" ]; then + return 0 + else + return 1 + fi + } + + ### Test functionality of a module; load if necessary + do_module_tests () { + echo " Testing module $1 $2" + "test_$1" + if [ $? -ne 0 ]; then + echo " Module $1 $2 needed" + echo " Scanning disk for $1 module" + module_exists $1 + if [ $? -ne 0 ]; then + echo " $1 module missing: please install it" + exit 1 + else + echo " $1 exists, trying to load" + insmod $1 $2 > /dev/null + if [ $? -ne 0 ]; then + echo " Error: insmod $1 $2 failed" + exit 1 + else + echo " $1 $2 loaded successfully" + fi + fi + else + echo " $1 is working" + fi + + } + + echo " Testing required modules" + + do_module_tests "ipt_mac" + do_module_tests "ipt_mark" + # if not using traffic control, + # you can comment out the following 3 lines: + do_module_tests "imq" "numdevs=2" + do_module_tests "ipt_IMQ" + do_module_tests "sch_htb" +} diff --git a/nodogsplash/patches/001-crash_on_missing_rdir_param.patch b/nodogsplash/patches/001-crash_on_missing_rdir_param.patch new file mode 100644 index 0000000..6bcf2e9 --- /dev/null +++ b/nodogsplash/patches/001-crash_on_missing_rdir_param.patch @@ -0,0 +1,18 @@ +--- a/src/http.c ++++ b/src/http.c +@@ -455,10 +455,15 @@ http_nodogsplash_decode_authtarget(reque + var = httpdGetVariableByName(r,"tok"); + if(var && var->value) { + token = var->value; ++ } else { ++ token = ""; + } ++ + var = httpdGetVariableByName(r,"redir"); + if(var && var->value) { + redir = var->value; ++ } else { ++ redir = ""; + } + + authtarget = http_nodogsplash_make_authtarget(token,redir); diff --git a/nodogsplash/patches/002-deprecated_iptables_syntax.patch b/nodogsplash/patches/002-deprecated_iptables_syntax.patch new file mode 100644 index 0000000..26a22af --- /dev/null +++ b/nodogsplash/patches/002-deprecated_iptables_syntax.patch @@ -0,0 +1,11 @@ +--- a/src/fw_iptables.c ++++ b/src/fw_iptables.c +@@ -449,7 +449,7 @@ iptables_fw_init(void) { + /* CHAIN_TO_ROUTER, related and established packets ACCEPT */ + rc |= iptables_do_command("-t filter -A " CHAIN_TO_ROUTER " -m state --state RELATED,ESTABLISHED -j ACCEPT"); + /* CHAIN_TO_ROUTER, bogus SYN packets DROP */ +- rc |= iptables_do_command("-t filter -A " CHAIN_TO_ROUTER " -p tcp --tcp-flags SYN SYN --tcp-option \\! 2 -j DROP"); ++ rc |= iptables_do_command("-t filter -A " CHAIN_TO_ROUTER " -p tcp --tcp-flags SYN SYN \\! --tcp-option 2 -j DROP"); + + /* CHAIN_TO_ROUTER, packets to HTTP listening on gw_port on router ACCEPT */ + rc |= iptables_do_command("-t filter -A " CHAIN_TO_ROUTER " -p tcp --dport %d -j ACCEPT", gw_port); |
