From 219a6dab8995aad9ac4860cc1a84d6f3509a03a4 Mon Sep 17 00:00:00 2001 From: wbx Date: Sun, 17 May 2009 14:41:34 +0200 Subject: Initial import --- package/wifidog/Config.in | 13 ++ package/wifidog/Makefile | 37 ++++ package/wifidog/files/wifidog.conf | 177 ++++++++++++++++++ package/wifidog/files/wifidog.init | 26 +++ package/wifidog/ipkg/wifidog.conffiles | 1 + package/wifidog/ipkg/wifidog.control | 8 + package/wifidog/ipkg/wifidog.postinst | 3 + package/wifidog/patches/patch-libhttpd_api_c | 211 ++++++++++++++++++++++ package/wifidog/patches/patch-libhttpd_ip_acl_c | 30 +++ package/wifidog/patches/patch-libhttpd_protocol_c | 48 +++++ 10 files changed, 554 insertions(+) create mode 100644 package/wifidog/Config.in create mode 100644 package/wifidog/Makefile create mode 100644 package/wifidog/files/wifidog.conf create mode 100644 package/wifidog/files/wifidog.init create mode 100644 package/wifidog/ipkg/wifidog.conffiles create mode 100644 package/wifidog/ipkg/wifidog.control create mode 100644 package/wifidog/ipkg/wifidog.postinst create mode 100644 package/wifidog/patches/patch-libhttpd_api_c create mode 100644 package/wifidog/patches/patch-libhttpd_ip_acl_c create mode 100644 package/wifidog/patches/patch-libhttpd_protocol_c (limited to 'package/wifidog') diff --git a/package/wifidog/Config.in b/package/wifidog/Config.in new file mode 100644 index 000000000..0680cc16d --- /dev/null +++ b/package/wifidog/Config.in @@ -0,0 +1,13 @@ +config ADK_PACKAGE_WIFIDOG + prompt "wifidog........................... A wireless captive portal solution" + tristate + default n + select ADK_PACKAGE_IPTABLES + help + The Wifidog project is a complete and embeddable captive + portal solution for wireless community groups or individuals + who wish to open a free Hotspot while still preventing abuse + of their Internet connection. + + http://www.wifidog.org/ + diff --git a/package/wifidog/Makefile b/package/wifidog/Makefile new file mode 100644 index 000000000..b46e273f3 --- /dev/null +++ b/package/wifidog/Makefile @@ -0,0 +1,37 @@ +# $Id$ +#- +# This file is part of the OpenADK project. OpenADK is copyrighted +# material, please see the LICENCE file in the top-level directory. + +include ${TOPDIR}/rules.mk + +PKG_NAME:= wifidog +PKG_VERSION:= 1.1.5 +PKG_RELEASE:= 1 +PKG_MD5SUM:= abe5f7123179a0f08c493ce59fb3cb31 +MASTER_SITES:= ${MASTER_SITE_SOURCEFORGE:=${PKG_NAME}/} + +include ${TOPDIR}/mk/package.mk + +$(eval $(call PKG_template,WIFIDOG,wifidog,${PKG_VERSION}-${PKG_RELEASE},${ARCH})) + +CONFIGURE_STYLE:= gnu +CONFIGURE_ENV+= ac_cv_func_malloc_0_nonnull=yes \ + ac_cv_func_memcmp_working=yes \ + ac_cv_func_setvbuf_reversed=no +BUILD_STYLE+= auto +INSTALL_STYLE:= auto + +post-install: + ${INSTALL_DIR} ${IDIR_WIFIDOG}/etc/init.d/ + ${INSTALL_BIN} ./files/${PKG_NAME}.init \ + ${IDIR_WIFIDOG}/etc/init.d/wifidog + ${INSTALL_DATA} ./files/wifidog.conf ${IDIR_WIFIDOG}/etc/ + ${INSTALL_DIR} ${IDIR_WIFIDOG}/usr/bin + ${INSTALL_DIR} ${IDIR_WIFIDOG}/usr/lib + ${INSTALL_BIN} ${WRKBUILD}/scripts/init.d/wifidog ${IDIR_WIFIDOG}/usr/bin/wifidog-init + ${INSTALL_BIN} ${WRKINST}/usr/bin/wifidog \ + ${WRKINST}/usr/bin/wdctl ${IDIR_WIFIDOG}/usr/bin/ + ${CP} ${WRKINST}/usr/lib/libhttpd.so* ${IDIR_WIFIDOG}/usr/lib/ + +include ${TOPDIR}/mk/pkg-bottom.mk diff --git a/package/wifidog/files/wifidog.conf b/package/wifidog/files/wifidog.conf new file mode 100644 index 000000000..6d955a645 --- /dev/null +++ b/package/wifidog/files/wifidog.conf @@ -0,0 +1,177 @@ +# $Header$ +# WiFiDog Configuration file + +# Parameter: GatewayID +# Default: default +# Optional but essential for monitoring purposes +# +# Set this to the template ID on the auth server +# this is used to give a customized login page to the clients +# If none is supplied, the default login page will be used. + +GatewayID default + +# Parameter: ExternalInterface +# Default: NONE +# Optional +# +# Set this to the external interface. Typically vlan1 for OpenADK, and eth0 or ppp0 otherwise + +# ExternalInterface eth0 + +# Parameter: GatewayInterface +# Default: NONE +# Mandatory +# +# Set this to the internal interface. Typically br0 for OpenADK, and eth1 otherwise + +GatewayInterface br0 + +# Parameter: GatewayAddress +# Default: Find it from GatewayInterface +# Optional +# +# Set this to the internal IP address of the gateway + +# GatewayAddress 192.168.1.1 + +# Parameter: AuthServMaxTries +# Default: 1 +# Optional +# +# Sets the number of auth servers the gateway will attempt to contact when a request fails. +# this number should be equal to the number of AuthServer lines in this +# configuration but it should probably not exceed 3. + +# AuthServMaxTries 3 + +# Parameter: AuthServer +# Default: NONE +# Mandatory +# +# Set this to the hostname or IP of your auth server, the path where +# WiFiDog-auth resides and optionally as a second argument, the port it +# listens on. +#AuthServer { +# Hostname (Mandatory; Default: NONE) +# SSLAvailable (Optional; Default: no; Possible values: yes, no) +# SSLPort 443 (Optional; Default: 443) +# HTTPPort 80 (Optional; Default: 80) +# Path wifidog/ (Optional; Default: /wifidog/ Note: The path must be both prefixed and suffixed by /. Use a single / for server root.) +#} + +#AuthServer { +# Hostname auth.ilesansfil.org +# SSLAvailable yes +# Path / +#} + +#AuthServer { +# Hostname auth2.ilesansfil.org +# SSLAvailable yes +# Path / +#} + +#AuthServer { +# Hostname auth3.ilesansfil.org +# SSLAvailable yes +# Path / +#} + +# Parameter: Daemon +# Default: 1 +# Optional +# +# Set this to true if you want to run as a daemon +# Daemon 1 + +# Parameter: GatewayPort +# Default: 2060 +# Optional +# +# Listen on this port +# GatewayPort 2060 + +# Parameter: HTTPDName +# Default: WiFiDog +# Optional +# +# Define what name the HTTPD server will respond +# HTTPDName WiFiDog + +# Parameter: HTTPDMaxConn +# Default: 10 +# Optional +# +# How many sockets to listen to +# HTTPDMaxConn 10 + +# Parameter: CheckInterval +# Default: 60 +# Optional +# +# How many seconds should we wait between timeout checks +CheckInterval 60 + +# Parameter: ClientTimeout +# Default: 5 +# Optional +# +# Set this to the desired of number of CheckInterval of inactivity before a client is logged out +# The timeout will be INTERVAL * TIMEOUT +ClientTimeout 5 + +# Parameter: FirewallRuleSet +# Default: none +# Mandatory +# +# Groups a number of FirewallRule statements together. + +# Parameter: FirewallRule +# Default: none +# +# Define one firewall rule in a rule set. + +# Rule Set: global +# +# Used for rules to be applied to all other rulesets except locked. +# This is the default config for the Teliphone service. +FirewallRuleSet global { + FirewallRule allow udp to 69.90.89.192/27 + FirewallRule allow udp to 69.90.85.0/27 + FirewallRule allow tcp port 80 to 69.90.89.205 +} + +# Rule Set: validating-users +# +# Used for new users validating their account +FirewallRuleSet validating-users { + FirewallRule block tcp port 25 + FirewallRule allow to 0.0.0.0/0 +} + +# Rule Set: known-users +# +# Used for normal validated users. +FirewallRuleSet known-users { + FirewallRule allow to 0.0.0.0/0 +} + +# Rule Set: unknown-users +# +# Used for unvalidated users, this is the ruleset that gets redirected. +# +# XXX The redirect code adds the Default DROP clause. +FirewallRuleSet unknown-users { + FirewallRule allow udp port 53 + FirewallRule allow tcp port 53 + FirewallRule allow udp port 67 + FirewallRule allow tcp port 67 +} + +# Rule Set: locked-users +# +# Used for users that have been locked out. +FirewallRuleSet locked-users { + FirewallRule block to 0.0.0.0/0 +} diff --git a/package/wifidog/files/wifidog.init b/package/wifidog/files/wifidog.init new file mode 100644 index 000000000..4a23a8e34 --- /dev/null +++ b/package/wifidog/files/wifidog.init @@ -0,0 +1,26 @@ +#!/bin/sh +#FWINIT 65 +. /etc/rc.conf + +case $1 in +autostop) ;; +autostart) + test x"${wifidog:-NO}" = x"NO" && exit 0 + exec sh $0 start + ;; +start) + wifidog-init start + ;; +stop) + wifidog-init stop + ;; +restart) + sh $0 stop + sh $0 start + ;; +*) + echo "Usage: $0 {start | stop | restart}" + exit 1 + ;; +esac +exit $? diff --git a/package/wifidog/ipkg/wifidog.conffiles b/package/wifidog/ipkg/wifidog.conffiles new file mode 100644 index 000000000..aaa3dd140 --- /dev/null +++ b/package/wifidog/ipkg/wifidog.conffiles @@ -0,0 +1 @@ +/etc/wifidog.conf diff --git a/package/wifidog/ipkg/wifidog.control b/package/wifidog/ipkg/wifidog.control new file mode 100644 index 000000000..18d498552 --- /dev/null +++ b/package/wifidog/ipkg/wifidog.control @@ -0,0 +1,8 @@ +Package: wifidog +Priority: optional +Section: net +Depends: iptables, iptables-extra, kmod-iptables-extra +Description: WiFiDog is a complete and embeddable captive portal + solution for wireless community groups or individuals who + wish to open a free Hotspot while still preventing abuse + of their Internet connection. diff --git a/package/wifidog/ipkg/wifidog.postinst b/package/wifidog/ipkg/wifidog.postinst new file mode 100644 index 000000000..e778a2300 --- /dev/null +++ b/package/wifidog/ipkg/wifidog.postinst @@ -0,0 +1,3 @@ +#!/bin/sh +. $IPKG_INSTROOT/etc/functions.sh +add_rcconf wifidog wifidog NO diff --git a/package/wifidog/patches/patch-libhttpd_api_c b/package/wifidog/patches/patch-libhttpd_api_c new file mode 100644 index 000000000..db790195b --- /dev/null +++ b/package/wifidog/patches/patch-libhttpd_api_c @@ -0,0 +1,211 @@ +$Id: update-patches 24 2008-08-31 14:56:13Z wbx $ +--- wifidog-1.1.5.orig/libhttpd/api.c 2007-11-01 21:04:20.000000000 +0100 ++++ wifidog-1.1.5/libhttpd/api.c 2008-10-16 13:15:26.000000000 +0200 +@@ -166,7 +166,7 @@ int httpdAddVariable(request *r, char *n + while(*name == ' ' || *name == '\t') + name++; + newVar = malloc(sizeof(httpVar)); +- bzero(newVar, sizeof(httpVar)); ++ memset(newVar, 0, sizeof(httpVar)); + newVar->name = strdup(name); + newVar->value = strdup(value); + lastVar = NULL; +@@ -209,14 +209,14 @@ httpd *httpdCreate(host, port) + new = malloc(sizeof(httpd)); + if (new == NULL) + return(NULL); +- bzero(new, sizeof(httpd)); ++ memset(new, 0, sizeof(httpd)); + new->port = port; + if (host == HTTP_ANY_ADDR) + new->host = HTTP_ANY_ADDR; + else + new->host = strdup(host); + new->content = (httpDir*)malloc(sizeof(httpDir)); +- bzero(new->content,sizeof(httpDir)); ++ memset(new->content, 0, sizeof(httpDir)); + new->content->name = strdup(""); + + /* +@@ -270,7 +270,7 @@ httpd *httpdCreate(host, port) + setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char*)&opt,sizeof(int)); + # endif + new->serverSock = sock; +- bzero(&addr, sizeof(addr)); ++ memset(&addr, 0, sizeof(addr)); + addr.sin_family = AF_INET; + if (new->host == HTTP_ANY_ADDR) + { +@@ -344,7 +344,7 @@ request *httpdGetConnection(server, time + } + memset((void *)r, 0, sizeof(request)); + /* Get on with it */ +- bzero(&addr, sizeof(addr)); ++ memset(&addr, 0, sizeof(addr)); + addrLen = sizeof(addr); + r->clientSock = accept(server->serverSock,(struct sockaddr *)&addr, + &addrLen); +@@ -469,14 +469,14 @@ int httpdReadRequest(httpd *server, requ + *val, + *end; + +- var = index(buf,':'); ++ var = strchr(buf,':'); + while(var) + { + var++; +- val = index(var, '='); ++ val = strchr(var, '='); + *val = 0; + val++; +- end = index(val,';'); ++ end = strchr(val,';'); + if(end) + *end = 0; + httpdAddVariable(r, var, val); +@@ -488,7 +488,7 @@ int httpdReadRequest(httpd *server, requ + #if 0 + if (strncasecmp(buf,"Authorization: ",15) == 0) + { +- cp = index(buf,':') + 2; ++ cp = strchr(buf,':') + 2; + if (strncmp(cp,"Basic ", 6) != 0) + { + /* Unknown auth method */ +@@ -497,11 +497,11 @@ int httpdReadRequest(httpd *server, requ + { + char authBuf[100]; + +- cp = index(cp,' ') + 1; ++ cp = strchr(cp,' ') + 1; + _httpd_decode(cp, authBuf, 100); + r->request.authLength = + strlen(authBuf); +- cp = index(authBuf,':'); ++ cp = strchr(authBuf,':'); + if (cp) + { + *cp = 0; +@@ -517,7 +517,7 @@ int httpdReadRequest(httpd *server, requ + #if 0 + if (strncasecmp(buf,"Referer: ",9) == 0) + { +- cp = index(buf,':') + 2; ++ cp = strchr(buf,':') + 2; + if(cp) + { + strncpy(r->request.referer,cp, +@@ -529,7 +529,7 @@ int httpdReadRequest(httpd *server, requ + * present. */ + if (strncasecmp(buf,"Host: ",6) == 0) + { +- cp = index(buf,':') + 2; ++ cp = strchr(buf,':') + 2; + if(cp) + { + strncpy(r->request.host,cp, +@@ -540,12 +540,12 @@ int httpdReadRequest(httpd *server, requ + #if 0 + if (strncasecmp(buf,"If-Modified-Since: ",19) == 0) + { +- cp = index(buf,':') + 2; ++ cp = strchr(buf,':') + 2; + if(cp) + { + strncpy(r->request.ifModified,cp, + HTTP_MAX_URL); +- cp = index(r->request.ifModified, ++ cp = strchr(r->request.ifModified, + ';'); + if (cp) + *cp = 0; +@@ -553,7 +553,7 @@ int httpdReadRequest(httpd *server, requ + } + if (strncasecmp(buf,"Content-Type: ",14) == 0) + { +- cp = index(buf,':') + 2; ++ cp = strchr(buf,':') + 2; + if(cp) + { + strncpy(r->request.contentType,cp, +@@ -562,7 +562,7 @@ int httpdReadRequest(httpd *server, requ + } + if (strncasecmp(buf,"Content-Length: ",16) == 0) + { +- cp = index(buf,':') + 2; ++ cp = strchr(buf,':') + 2; + if(cp) + r->request.contentLength=atoi(cp); + } +@@ -581,7 +581,7 @@ int httpdReadRequest(httpd *server, requ + */ + if (r->request.contentLength > 0) + { +- bzero(buf, HTTP_MAX_LEN); ++ memset(buf, 0, HTTP_MAX_LEN); + _httpd_readBuf(r, buf, r->request.contentLength); + _httpd_storeData(r, buf); + +@@ -591,7 +591,7 @@ int httpdReadRequest(httpd *server, requ + /* + ** Process any URL data + */ +- cp = index(r->request.path,'?'); ++ cp = strchr(r->request.path,'?'); + if (cp != NULL) + { + *cp++ = 0; +@@ -661,7 +661,7 @@ int httpdAddFileContent(server, dir, nam + newEntry = malloc(sizeof(httpContent)); + if (newEntry == NULL) + return(-1); +- bzero(newEntry,sizeof(httpContent)); ++ memset(newEntry, 0, sizeof(httpContent)); + newEntry->name = strdup(name); + newEntry->type = HTTP_FILE; + newEntry->indexFlag = indexFlag; +@@ -699,7 +699,7 @@ int httpdAddWildcardContent(server, dir, + newEntry = malloc(sizeof(httpContent)); + if (newEntry == NULL) + return(-1); +- bzero(newEntry,sizeof(httpContent)); ++ memset(newEntry, 0, sizeof(httpContent)); + newEntry->name = NULL; + newEntry->type = HTTP_WILDCARD; + newEntry->indexFlag = HTTP_FALSE; +@@ -755,7 +755,7 @@ int httpdAddCContent(server, dir, name, + newEntry = malloc(sizeof(httpContent)); + if (newEntry == NULL) + return(-1); +- bzero(newEntry,sizeof(httpContent)); ++ memset(newEntry, 0, sizeof(httpContent)); + newEntry->name = strdup(name); + newEntry->type = HTTP_C_FUNCT; + newEntry->indexFlag = indexFlag; +@@ -780,7 +780,7 @@ int httpdAddCWildcardContent(server, dir + newEntry = malloc(sizeof(httpContent)); + if (newEntry == NULL) + return(-1); +- bzero(newEntry,sizeof(httpContent)); ++ memset(newEntry, 0, sizeof(httpContent)); + newEntry->name = NULL; + newEntry->type = HTTP_C_WILDCARD; + newEntry->indexFlag = HTTP_FALSE; +@@ -805,7 +805,7 @@ int httpdAddStaticContent(server, dir, n + newEntry = malloc(sizeof(httpContent)); + if (newEntry == NULL) + return(-1); +- bzero(newEntry,sizeof(httpContent)); ++ memset(newEntry, 0, sizeof(httpContent)); + newEntry->name = strdup(name); + newEntry->type = HTTP_STATIC; + newEntry->indexFlag = indexFlag; +@@ -946,7 +946,7 @@ void httpdProcessRequest(httpd *server, + + r->response.responseLength = 0; + strncpy(dirName, httpdRequestPath(r), HTTP_MAX_URL); +- cp = rindex(dirName, '/'); ++ cp = strrchr(dirName, '/'); + if (cp == NULL) + { + printf("Invalid request path '%s'\n",dirName); diff --git a/package/wifidog/patches/patch-libhttpd_ip_acl_c b/package/wifidog/patches/patch-libhttpd_ip_acl_c new file mode 100644 index 000000000..932855b5d --- /dev/null +++ b/package/wifidog/patches/patch-libhttpd_ip_acl_c @@ -0,0 +1,30 @@ +$Id: update-patches 24 2008-08-31 14:56:13Z wbx $ +--- wifidog-1.1.5.orig/libhttpd/ip_acl.c 2007-03-12 20:37:06.000000000 +0100 ++++ wifidog-1.1.5/libhttpd/ip_acl.c 2008-10-16 13:12:15.000000000 +0200 +@@ -52,22 +52,22 @@ static int scanCidr(val, result, length) + + cp = val; + res1 = atoi(cp); +- cp = index(cp,'.'); ++ cp = strchr(cp,'.'); + if (!cp) + return(-1); + cp++; + res2 = atoi(cp); +- cp = index(cp,'.'); ++ cp = strchr(cp,'.'); + if (!cp) + return(-1); + cp++; + res3 = atoi(cp); +- cp = index(cp,'.'); ++ cp = strchr(cp,'.'); + if (!cp) + return(-1); + cp++; + res4 = atoi(cp); +- cp = index(cp,'/'); ++ cp = strchr(cp,'/'); + if (!cp) + { + res5 = 32; diff --git a/package/wifidog/patches/patch-libhttpd_protocol_c b/package/wifidog/patches/patch-libhttpd_protocol_c new file mode 100644 index 000000000..767337dd6 --- /dev/null +++ b/package/wifidog/patches/patch-libhttpd_protocol_c @@ -0,0 +1,48 @@ +$Id: update-patches 24 2008-08-31 14:56:13Z wbx $ +--- wifidog-1.1.5.orig/libhttpd/protocol.c 2007-11-01 21:04:20.000000000 +0100 ++++ wifidog-1.1.5/libhttpd/protocol.c 2008-10-16 13:12:58.000000000 +0200 +@@ -83,7 +83,7 @@ int _httpd_readChar(request *r, char *cp + { + if (r->readBufRemain == 0) + { +- bzero(r->readBuf, HTTP_READ_BUF_LEN + 1); ++ memset(r->readBuf, 0, HTTP_READ_BUF_LEN + 1); + r->readBufRemain = _httpd_net_read(r->clientSock, + r->readBuf, HTTP_READ_BUF_LEN); + if (r->readBufRemain < 1) +@@ -352,7 +352,7 @@ void _httpd_storeData(request *r, char * + + cp = query; + cp2 = var; +- bzero(var, strlen(query)); ++ memset(var, 0, strlen(query)); + val = NULL; + while(*cp) + { +@@ -483,7 +483,7 @@ httpDir *_httpd_findContentDir(server, d + if (createFlag == HTTP_TRUE) + { + curChild = malloc(sizeof(httpDir)); +- bzero(curChild, sizeof(httpDir)); ++ memset(curChild, 0, sizeof(httpDir)); + curChild->name = strdup(curDir); + curChild->next = curItem->children; + curItem->children = curChild; +@@ -606,7 +606,7 @@ void _httpd_sendFile(httpd *server, requ + char *suffix; + struct stat sbuf; + +- suffix = rindex(path, '.'); ++ suffix = strrchr(path, '.'); + if (suffix != NULL) + { + if (strcasecmp(suffix,".gif") == 0) +@@ -699,7 +699,7 @@ char *_httpd_escape(str) + if (!ACCEPTABLE((unsigned char)*p)) + unacceptable +=2; + result = (char *) malloc(p-str + unacceptable + 1); +- bzero(result,(p-str + unacceptable + 1)); ++ memset(result, 0, (p-str + unacceptable + 1)); + + if (result == NULL) + { -- cgit v1.2.3