Changeset 935
- Timestamp:
- 01/31/06 22:22:04 (3 years ago)
- Files:
-
- trunk/wifidog/ChangeLog (modified) (1 diff)
- trunk/wifidog/Makefile.am (modified) (1 diff)
- trunk/wifidog/README (modified) (1 diff)
- trunk/wifidog/configure.in (modified) (1 diff)
- trunk/wifidog/libhttpd/protocol.c (modified) (2 diffs)
- trunk/wifidog/src/auth.c (modified) (1 diff)
- trunk/wifidog/src/centralserver.c (modified) (1 diff)
- trunk/wifidog/src/commandline.c (modified) (2 diffs)
- trunk/wifidog/src/conf.c (modified) (6 diffs)
- trunk/wifidog/src/conf.h (modified) (3 diffs)
- trunk/wifidog/src/firewall.c (modified) (5 diffs)
- trunk/wifidog/src/firewall.h (modified) (1 diff)
- trunk/wifidog/src/fw_iptables.c (modified) (7 diffs)
- trunk/wifidog/src/gateway.c (modified) (4 diffs)
- trunk/wifidog/src/http.c (modified) (1 diff)
- trunk/wifidog/src/util.c (modified) (2 diffs)
- trunk/wifidog/wifidog.conf (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/wifidog/ChangeLog
r923 r935 1 1 # $Id$ 2 2006-01-31 Benoit Gr�ire <bock@step.polymtl.ca> 3 * src/fw_iptables.c: Add the global ruleset to the nat table to fix #65. 4 Add the table parameter to iptables_load_ruleset() and iptables_compile 5 * libhttpd/protocol.c: Fix pointer type mismatch 6 * src/conf.c,h: Remove deprecated option AuthServMaxTries (which was already ignored anyway. 7 2 8 2006-01-23 Benoit Gr�ire <bock@step.polymtl.ca> 3 src/conf.h: Fix the value of DEFAULT_AUTHSERVPATH and completely wrong code comment. Not the default indicated in the config file and the define are in sync.9 * src/conf.h: Fix the value of DEFAULT_AUTHSERVPATH and completely wrong code comment. Not the default indicated in the config file and the define are in sync. 4 10 5 11 2006-01-17 Mina Naguib <mina@ilesansfil.org> trunk/wifidog/Makefile.am
r901 r935 39 39 rpmbuild -ta ${builddir}wifidog-@VERSION@.tar.gz 40 40 41 clean-local:42 echo "clean-local: " && pwd43 rm -f /usr/src/RPM/SPECS/wifidog.spec44 rm -f /usr/src/RPM/SOURCES/wifidog-@VERSION@.tar.gz41 #clean-local: 42 # echo "clean-local: " && pwd 43 # rm -f /usr/src/RPM/SPECS/wifidog.spec 44 # rm -f /usr/src/RPM/SOURCES/wifidog-@VERSION@.tar.gz trunk/wifidog/README
r901 r935 8 8 9 9 The project's homepage is: 10 http://www.ilesansfil.org/wiki/WiFiDog 11 12 SourceForge project page: 13 http://sourceforge.net/projects/wifidog/ 10 http://dev.wifidog.org/ 14 11 15 12 Mailing list interface: 16 13 http://listes.ilesansfil.org/cgi-bin/mailman/listinfo/wifidog 17 14 18 19 15 The project's software is released under the GPL license and is copyright it's respective owners. 20 16 trunk/wifidog/configure.in
r901 r935 21 21 WIFIDOG_MAJOR_VERSION=1 22 22 WIFIDOG_MINOR_VERSION=1 23 WIFIDOG_MICRO_VERSION=3_ beta123 WIFIDOG_MICRO_VERSION=3_pre1 24 24 WIFIDOG_VERSION=$WIFIDOG_MAJOR_VERSION.$WIFIDOG_MINOR_VERSION.$WIFIDOG_MICRO_VERSION 25 25 trunk/wifidog/libhttpd/protocol.c
r786 r935 221 221 int nbytesdecoded, j; 222 222 register char *bufin = bufcoded; 223 register unsignedchar *bufout = bufplain;223 register char *bufout = bufplain; 224 224 register int nprbytes; 225 225 … … 256 256 while (nprbytes > 0) 257 257 { 258 *(bufout++)=( unsigned char)(DEC(*bufin)<<2|DEC(bufin[1])>>4);259 *(bufout++)=( unsigned char)(DEC(bufin[1])<<4|DEC(bufin[2])>>2);260 *(bufout++)=( unsigned char)(DEC(bufin[2])<<6|DEC(bufin[3]));258 *(bufout++)=(DEC(*bufin)<<2|DEC(bufin[1])>>4); 259 *(bufout++)=(DEC(bufin[1])<<4|DEC(bufin[2])>>2); 260 *(bufout++)=(DEC(bufin[2])<<6|DEC(bufin[3])); 261 261 bufin += 4; 262 262 nprbytes -= 4; trunk/wifidog/src/auth.c
r901 r935 83 83 debug(LOG_DEBUG, "Running fw_counter()"); 84 84 85 fw_ counter();85 fw_sync_with_authserver(); 86 86 } 87 87 } trunk/wifidog/src/centralserver.c
r901 r935 333 333 } 334 334 } 335 336 /* config->authserv_maxtries */trunk/wifidog/src/commandline.c
r901 r935 48 48 * 0 means normally, otherwise it will be populated by the PID of the parent 49 49 */ 50 pid_t restart ed = 0;50 pid_t restart_orig_pid = 0; 51 51 52 52 /** @internal … … 134 134 skiponrestart = 1; 135 135 if (optarg) { 136 restart ed = atoi(optarg);136 restart_orig_pid = atoi(optarg); 137 137 } 138 138 else { trunk/wifidog/src/conf.c
r901 r935 77 77 oAuthServHTTPPort, 78 78 oAuthServPath, 79 oAuthServMaxTries,80 79 oHTTPDMaxConn, 81 80 oHTTPDName, … … 104 103 { "gatewayport", oGatewayPort }, 105 104 { "authserver", oAuthServer }, 106 { "authservmaxtries", oAuthServMaxTries },107 105 { "httpdmaxconn", oHTTPDMaxConn }, 108 106 { "httpdname", oHTTPDName }, … … 147 145 config.gw_port = DEFAULT_GATEWAYPORT; 148 146 config.auth_servers = NULL; 149 config.authserv_maxtries = DEFAULT_AUTHSERVMAXTRIES;150 147 config.httpdname = NULL; 151 148 config.clienttimeout = DEFAULT_CLIENTTIMEOUT; … … 390 387 switch (opcode) { 391 388 case oFirewallRule: 392 parse_firewall_rule(ruleset, p2);389 _parse_firewall_rule(ruleset, p2); 393 390 break; 394 391 … … 413 410 } 414 411 412 /** @internal 413 Helper for parse_firewall_ruleset. Parses a single rule in a ruleset 414 */ 415 415 static int 416 parse_firewall_rule(char *ruleset, char *leftover)416 _parse_firewall_rule(char *ruleset, char *leftover) 417 417 { 418 418 int i; … … 652 652 sscanf(p1, "%d", &config.httpdmaxconn); 653 653 break; 654 case oAuthServMaxTries:655 sscanf(p1, "%d", &config.authserv_maxtries);656 break;657 654 case oBadOption: 658 655 debug(LOG_ERR, "Bad option on line %d " trunk/wifidog/src/conf.h
r922 r935 49 49 /** Note: The path must be prefixed by /, and must be suffixed /. Put / for the server root.*/ 50 50 #define DEFAULT_AUTHSERVPATH "/wifidog/" 51 #define DEFAULT_AUTHSERVMAXTRIES 152 51 /*@}*/ 53 52 … … 113 112 int gw_port; /**< @brief Port the webserver will run on */ 114 113 115 int authserv_maxtries; /**< @brief Maximum number of auth server116 connection attempts before abandoning */117 114 t_auth_serv *auth_servers; /**< @brief Auth servers list */ 118 115 char *httpdname; /**< @brief Name the web server will return when … … 158 155 static int parse_boolean_value(char *); 159 156 static void parse_auth_server(FILE *, char *, int *); 160 static int parse_firewall_rule(char *ruleset, char *leftover);157 static int _parse_firewall_rule(char *ruleset, char *leftover); 161 158 static void parse_firewall_ruleset(char *, FILE *, char *, int *); 162 159 void parse_trusted_mac_list(char *); trunk/wifidog/src/firewall.c
r901 r935 70 70 71 71 /* from commandline.c */ 72 extern pid_t restart ed;72 extern pid_t restart_orig_pid; 73 73 74 74 int icmp_fd = 0; … … 162 162 result = iptables_fw_init(); 163 163 164 if (restart ed) {164 if (restart_orig_pid) { 165 165 debug(LOG_INFO, "Restoring firewall rules for clients inherited from parent"); 166 166 LOCK_CLIENT_LIST(); … … 176 176 } 177 177 178 /** Clear the authserverrules178 /** Remove all auth server firewall whitelist rules 179 179 */ 180 180 void … … 185 185 } 186 186 187 /** Set the authservers rules187 /** Add the necessary firewall rules to whitelist the authservers 188 188 */ 189 189 void … … 214 214 */ 215 215 void 216 fw_ counter(void)216 fw_sync_with_authserver(void) 217 217 { 218 218 t_authresponse authresponse; trunk/wifidog/src/firewall.h
r901 r935 55 55 56 56 /** @brief Refreshes the entire client list */ 57 void fw_ counter(void);57 void fw_sync_with_authserver(void); 58 58 59 59 /** @brief Get an IP's MAC address from the ARP cache.*/ trunk/wifidog/src/fw_iptables.c
r901 r935 50 50 51 51 static int iptables_do_command(char *format, ...); 52 static char *iptables_compile(char *, t_firewall_rule *);53 static void iptables_load_ruleset(char *, char * );52 static char *iptables_compile(char *, char *, t_firewall_rule *); 53 static void iptables_load_ruleset(char *, char *, char *); 54 54 55 55 extern pthread_mutex_t client_list_mutex; … … 90 90 * Compiles a struct definition of a firewall rule into a valid iptables 91 91 * command. 92 * @arg table Table containing the chain. 92 93 * @arg chain Chain that the command will be (-A)ppended to. 93 94 * @arg rule Definition of a rule into a struct, from conf.c. 94 95 */ 95 96 static char * 96 iptables_compile(char * chain, t_firewall_rule *rule)97 iptables_compile(char * table, char *chain, t_firewall_rule *rule) 97 98 { 98 99 char command[MAX_BUF], … … 107 108 } 108 109 109 snprintf(command, sizeof(command), "-t filter -A %s ", chain);110 snprintf(command, sizeof(command), "-t %s -A %s ",table, chain); 110 111 if (rule->mask != NULL) { 111 112 snprintf((command + strlen(command)), (sizeof(command) - … … 134 135 * Load all the rules in a rule set. 135 136 * @arg ruleset Name of the ruleset 137 * @arg table Table containing the chain. 136 138 * @arg chain IPTables chain the rules go into 137 139 */ 138 140 static void 139 iptables_load_ruleset(char * ruleset, char *chain)140 { 141 t_firewall_rule *rule s;141 iptables_load_ruleset(char * table, char *ruleset, char *chain) 142 { 143 t_firewall_rule *rule; 142 144 char *cmd; 143 145 144 debug(LOG_DEBUG, "Load ruleset %s into chain %s", ruleset, chain);146 debug(LOG_DEBUG, "Load ruleset %s into table %s, chain %s", ruleset, table, chain); 145 147 146 for (rule s = get_ruleset(ruleset); rules != NULL; rules = rules->next) {147 cmd = iptables_compile( chain, rules);148 debug(LOG_DEBUG, "Loading rule \"%s\" into %s", cmd, chain);148 for (rule = get_ruleset(ruleset); rule != NULL; rule = rule->next) { 149 cmd = iptables_compile(table, chain, rule); 150 debug(LOG_DEBUG, "Loading rule \"%s\" into table %s, chain %s", cmd, table, chain); 149 151 iptables_do_command(cmd); 150 152 free(cmd); 151 153 } 152 154 153 debug(LOG_DEBUG, "Ruleset %s loaded into %s", ruleset, chain);155 debug(LOG_DEBUG, "Ruleset %s loaded into table %s, chain %s", ruleset, table, chain); 154 156 } 155 157 … … 227 229 iptables_do_command("-t nat -N " TABLE_WIFIDOG_WIFI_TO_ROUTER); 228 230 iptables_do_command("-t nat -N " TABLE_WIFIDOG_WIFI_TO_INTERNET); 231 iptables_do_command("-t nat -N " TABLE_WIFIDOG_GLOBAL); 229 232 iptables_do_command("-t nat -N " TABLE_WIFIDOG_UNKNOWN); 230 233 iptables_do_command("-t nat -N " TABLE_WIFIDOG_AUTHSERVERS); … … 242 245 243 246 iptables_do_command("-t nat -A " TABLE_WIFIDOG_UNKNOWN " -j " TABLE_WIFIDOG_AUTHSERVERS); 247 iptables_do_command("-t nat -A " TABLE_WIFIDOG_UNKNOWN " -j " TABLE_WIFIDOG_GLOBAL); 244 248 iptables_do_command("-t nat -A " TABLE_WIFIDOG_UNKNOWN " -p tcp --dport 80 -j REDIRECT --to-ports %d", gw_port); 245 249 … … 266 270 267 271 iptables_do_command("-t filter -A " TABLE_WIFIDOG_WIFI_TO_INTERNET " -m mark --mark 0x%u -j " TABLE_WIFIDOG_LOCKED, FW_MARK_LOCKED); 268 iptables_load_ruleset(" locked-users", TABLE_WIFIDOG_LOCKED);272 iptables_load_ruleset("filter", "locked-users", TABLE_WIFIDOG_LOCKED); 269 273 270 274 iptables_do_command("-t filter -A " TABLE_WIFIDOG_WIFI_TO_INTERNET " -j " TABLE_WIFIDOG_GLOBAL); 271 iptables_load_ruleset("global", TABLE_WIFIDOG_GLOBAL); 275 iptables_load_ruleset("filter", "global", TABLE_WIFIDOG_GLOBAL); 276 iptables_load_ruleset("nat", "global", TABLE_WIFIDOG_GLOBAL); 272 277 273 278 iptables_do_command("-t filter -A " TABLE_WIFIDOG_WIFI_TO_INTERNET " -m mark --mark 0x%u -j " TABLE_WIFIDOG_VALIDATE, FW_MARK_PROBATION); 274 iptables_load_ruleset(" validating-users", TABLE_WIFIDOG_VALIDATE);279 iptables_load_ruleset("filter", "validating-users", TABLE_WIFIDOG_VALIDATE); 275 280 276 281 iptables_do_command("-t filter -A " TABLE_WIFIDOG_WIFI_TO_INTERNET " -m mark --mark 0x%u -j " TABLE_WIFIDOG_KNOWN, FW_MARK_KNOWN); 277 iptables_load_ruleset(" known-users", TABLE_WIFIDOG_KNOWN);282 iptables_load_ruleset("filter", "known-users", TABLE_WIFIDOG_KNOWN); 278 283 279 284 iptables_do_command("-t filter -A " TABLE_WIFIDOG_WIFI_TO_INTERNET " -j " TABLE_WIFIDOG_UNKNOWN); 280 iptables_load_ruleset(" unknown-users", TABLE_WIFIDOG_UNKNOWN);285 iptables_load_ruleset("filter", "unknown-users", TABLE_WIFIDOG_UNKNOWN); 281 286 iptables_do_command("-t filter -A " TABLE_WIFIDOG_UNKNOWN " -j REJECT --reject-with icmp-port-unreachable"); 282 287 trunk/wifidog/src/gateway.c
r901 r935 73 73 /* from commandline.c */ 74 74 extern char ** restartargv; 75 extern pid_t restart ed;75 extern pid_t restart_orig_pid; 76 76 t_client *firstclient; 77 77 … … 95 95 96 96 /* @internal 97 * @brief Connects to the parentvia the internal socket97 * @brief During gateway restart, connects to the parent process via the internal socket 98 98 * Downloads from it the active client list 99 99 */ … … 508 508 init_signals(); 509 509 510 if (restart ed) {510 if (restart_orig_pid) { 511 511 /* 512 512 * We were restarted and our parent is waiting for us to talk to it over the socket … … 517 517 * At this point the parent will start destroying itself and the firewall. Let it finish it's job before we continue 518 518 */ 519 while (kill(restart ed, 0) != -1) {520 debug(LOG_INFO, "Waiting for parent PID %d to die before continuing loading", restart ed);519 while (kill(restart_orig_pid, 0) != -1) { 520 debug(LOG_INFO, "Waiting for parent PID %d to die before continuing loading", restart_orig_pid); 521 521 sleep(1); 522 522 } trunk/wifidog/src/http.c
r901 r935 52 52 extern pthread_mutex_t client_list_mutex; 53 53 54 /** The 404 handler is also responsable for redirecting to the auth server */ 54 55 void 55 56 http_callback_404(httpd *webserver, request *r) trunk/wifidog/src/util.c
r901 r935 68 68 69 69 /* Defined in commandline.c */ 70 extern pid_t restart ed;70 extern pid_t restart_orig_pid; 71 71 72 72 /* XXX Do these need to be locked ? */ … … 340 340 snprintf((buffer + len), (sizeof(buffer) - len), "Has been restarted: "); 341 341 len = strlen(buffer); 342 if (restart ed) {343 snprintf((buffer + len), (sizeof(buffer) - len), "yes (from PID %d)\n", restart ed);342 if (restart_orig_pid) { 343 snprintf((buffer + len), (sizeof(buffer) - len), "yes (from PID %d)\n", restart_orig_pid); 344 344 len = strlen(buffer); 345 345 } trunk/wifidog/wifidog.conf
r901 r935 37 37 # GatewayAddress 192.168.1.1 38 38 39 # Parameter: AuthServMaxTries40 # Default: 141 # Optional42 #43 # Sets the number of auth servers the gateway will attempt to contact when a request fails.44 # this number should be equal to the number of AuthServer lines in this45 # configuration but it should probably not exceed 3.46 47 # AuthServMaxTries 348 49 39 # Parameter: AuthServer 50 40 # Default: NONE 51 # Mandatory 41 # Mandatory, repeatable 52 42 # 53 # Set this to the hostname or IP of your auth server, the path where54 # WiFiDog-auth resides and optionally as a second argument, the port it55 # listens on.43 # This allows you to configure your auth server(s). Each one will be tried in order, untill one responds. 44 # Set this to the hostname or IP of your auth server(s), the path where 45 # WiFiDog-auth resides in and the port it listens on. 56 46 #AuthServer { 57 47 # Hostname (Mandatory; Default: NONE)
