Changeset 1373
- Timestamp:
- 09/30/08 05:27:40 (4 years ago)
- Location:
- trunk/wifidog
- Files:
-
- 16 modified
-
ChangeLog (modified) (1 diff)
-
src/auth.c (modified) (1 diff)
-
src/auth.h (modified) (1 diff)
-
src/centralserver.c (modified) (1 diff)
-
src/centralserver.h (modified) (1 diff)
-
src/client_list.c (modified) (5 diffs)
-
src/client_list.h (modified) (1 diff)
-
src/conf.c (modified) (8 diffs)
-
src/conf.h (modified) (2 diffs)
-
src/fw_iptables.c (modified) (9 diffs)
-
src/fw_iptables.h (modified) (1 diff)
-
src/http.c (modified) (2 diffs)
-
src/ping_thread.c (modified) (1 diff)
-
src/util.c (modified) (4 diffs)
-
src/util.h (modified) (1 diff)
-
src/wdctl.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wifidog/ChangeLog
r1372 r1373 2 2 3 3 2008-09-30 Wichert Akkerman <wichert@wiggy.net> 4 * Clean up compiler warnings (mostly signed/unsigned comparisons) 4 5 * Security: strncpy may not NUL-terminate strings, so enforce this 5 6 ourselves. -
trunk/wifidog/src/auth.c
r1346 r1373 61 61 */ 62 62 void 63 thread_client_timeout_check( void *arg)63 thread_client_timeout_check(const void *arg) 64 64 { 65 65 pthread_cond_t cond = PTHREAD_COND_INITIALIZER; -
trunk/wifidog/src/auth.h
r1305 r1373 57 57 58 58 /** @brief Periodically check if connections expired */ 59 void thread_client_timeout_check( void *arg);59 void thread_client_timeout_check(const void *arg); 60 60 61 61 #endif -
trunk/wifidog/src/centralserver.c
r1305 r1373 63 63 */ 64 64 t_authcode 65 auth_server_request(t_authresponse *authresponse, c har *request_type, char *ip, char *mac,char *token, unsigned long long int incoming, unsigned long long int outgoing)65 auth_server_request(t_authresponse *authresponse, const char *request_type, const char *ip, const char *mac, const char *token, unsigned long long int incoming, unsigned long long int outgoing) 66 66 { 67 67 int sockfd; 68 size_t numbytes, totalbytes; 68 ssize_t numbytes; 69 size_t totalbytes; 69 70 char buf[MAX_BUF]; 70 71 char *tmp; -
trunk/wifidog/src/centralserver.h
r1305 r1373 47 47 48 48 /** @brief Initiates a transaction with the auth server */ 49 t_authcode auth_server_request(t_authresponse *authresponse, char *request_type, char *ip, char *mac, char *token, unsigned long long int incoming, unsigned long long int outgoing); 49 t_authcode auth_server_request(t_authresponse *authresponse, 50 const char *request_type, 51 const char *ip, 52 const char *mac, 53 const char *token, 54 unsigned long long int incoming, 55 unsigned long long int outgoing); 50 56 51 57 /** @brief Tries really hard to connect to an auth server. Returns a connected file descriptor or -1 on error */ -
trunk/wifidog/src/client_list.c
r901 r1373 78 78 */ 79 79 t_client * 80 client_list_append(c har *ip, char *mac,char *token)80 client_list_append(const char *ip, const char *mac, const char *token) 81 81 { 82 82 t_client *curclient, *prevclient; … … 118 118 */ 119 119 t_client * 120 client_list_find(c har *ip,char *mac)120 client_list_find(const char *ip, const char *mac) 121 121 { 122 122 t_client *ptr; … … 139 139 */ 140 140 t_client * 141 client_list_find_by_ip(c har *ip)141 client_list_find_by_ip(const char *ip) 142 142 { 143 143 t_client *ptr; … … 160 160 */ 161 161 t_client * 162 client_list_find_by_mac(c har *mac)162 client_list_find_by_mac(const char *mac) 163 163 { 164 164 t_client *ptr; … … 179 179 */ 180 180 t_client * 181 client_list_find_by_token(c har *token)181 client_list_find_by_token(const char *token) 182 182 { 183 183 t_client *ptr; -
trunk/wifidog/src/client_list.h
r901 r1373 62 62 63 63 /** @brief Adds a new client to the connections list */ 64 t_client *client_list_append(c har *ip, char *mac,char *token);64 t_client *client_list_append(const char *ip, const char *mac, const char *token); 65 65 66 66 /** @brief Finds a client by its IP and MAC */ 67 t_client *client_list_find(c har *ip,char *mac);67 t_client *client_list_find(const char *ip, const char *mac); 68 68 69 69 /** @brief Finds a client only by its IP */ 70 t_client *client_list_find_by_ip(c har *ip); /* needed by fw_iptables.c, auth.c70 t_client *client_list_find_by_ip(const char *ip); /* needed by fw_iptables.c, auth.c 71 71 * and wdctl_thread.c */ 72 72 73 73 /** @brief Finds a client only by its Mac */ 74 t_client *client_list_find_by_mac(c har *mac); /* needed by wdctl_thread.c */74 t_client *client_list_find_by_mac(const char *mac); /* needed by wdctl_thread.c */ 75 75 76 76 /** @brief Finds a client by its token */ 77 t_client *client_list_find_by_token(c har *token);77 t_client *client_list_find_by_token(const char *token); 78 78 79 79 /** @brief Deletes a client from the connections list */ -
trunk/wifidog/src/conf.c
r1369 r1373 103 103 const char *name; 104 104 OpCodes opcode; 105 int required;106 105 } keywords[] = { 107 { "daemon", oDaemon },108 { "debuglevel", oDebugLevel },109 { "externalinterface", oExternalInterface },110 { "gatewayid", oGatewayID },111 { "gatewayinterface", oGatewayInterface },112 { "gatewayaddress", oGatewayAddress },113 { "gatewayport", oGatewayPort },114 { "authserver", oAuthServer },115 { "httpdmaxconn", oHTTPDMaxConn },116 { "httpdname", oHTTPDName },117 { "httpdrealm", oHTTPDRealm },118 { "httpdusername", oHTTPDUsername },119 { "httpdpassword", oHTTPDPassword },120 { "clienttimeout", oClientTimeout },121 { "checkinterval", oCheckInterval },122 { "syslogfacility", oSyslogFacility },123 { "wdctlsocket", oWdctlSocket },124 { "hostname", oAuthServHostname },125 { "sslavailable", oAuthServSSLAvailable },126 { "sslport", oAuthServSSLPort },127 { "httpport", oAuthServHTTPPort },128 { "path", oAuthServPath },106 { "daemon", oDaemon }, 107 { "debuglevel", oDebugLevel }, 108 { "externalinterface", oExternalInterface }, 109 { "gatewayid", oGatewayID }, 110 { "gatewayinterface", oGatewayInterface }, 111 { "gatewayaddress", oGatewayAddress }, 112 { "gatewayport", oGatewayPort }, 113 { "authserver", oAuthServer }, 114 { "httpdmaxconn", oHTTPDMaxConn }, 115 { "httpdname", oHTTPDName }, 116 { "httpdrealm", oHTTPDRealm }, 117 { "httpdusername", oHTTPDUsername }, 118 { "httpdpassword", oHTTPDPassword }, 119 { "clienttimeout", oClientTimeout }, 120 { "checkinterval", oCheckInterval }, 121 { "syslogfacility", oSyslogFacility }, 122 { "wdctlsocket", oWdctlSocket }, 123 { "hostname", oAuthServHostname }, 124 { "sslavailable", oAuthServSSLAvailable }, 125 { "sslport", oAuthServSSLPort }, 126 { "httpport", oAuthServHTTPPort }, 127 { "path", oAuthServPath }, 129 128 { "loginscriptpathfragment", oAuthServLoginScriptPathFragment }, 130 129 { "portalscriptpathfragment", oAuthServPortalScriptPathFragment }, 131 { "msgscriptpathfragment", oAuthServMsgScriptPathFragment },132 { "pingscriptpathfragment", oAuthServPingScriptPathFragment },133 { "authscriptpathfragment", oAuthServAuthScriptPathFragment },134 { "firewallruleset", oFirewallRuleSet },135 { "firewallrule", oFirewallRule },136 { "trustedmaclist", oTrustedMACList },137 { "htmlmessagefile", oHtmlMessageFile },138 { NULL, oBadOption },130 { "msgscriptpathfragment", oAuthServMsgScriptPathFragment }, 131 { "pingscriptpathfragment", oAuthServPingScriptPathFragment }, 132 { "authscriptpathfragment", oAuthServAuthScriptPathFragment }, 133 { "firewallruleset", oFirewallRuleSet }, 134 { "firewallrule", oFirewallRule }, 135 { "trustedmaclist", oTrustedMACList }, 136 { "htmlmessagefile", oHtmlMessageFile }, 137 { NULL, oBadOption }, 139 138 }; 140 139 141 static void config_notnull( void *parm,char *parmname);140 static void config_notnull(const void *parm, const char *parmname); 142 141 static int parse_boolean_value(char *); 143 static void parse_auth_server(FILE *, c har *, int *);144 static int _parse_firewall_rule(c har *ruleset, char *leftover);145 static void parse_firewall_ruleset(c har *, FILE *,char *, int *);142 static void parse_auth_server(FILE *, const char *, int *); 143 static int _parse_firewall_rule(const char *ruleset, char *leftover); 144 static void parse_firewall_ruleset(const char *, FILE *, const char *, int *); 146 145 147 146 static OpCodes config_parse_token(const char *cp, const char *filename, int linenum); … … 216 215 */ 217 216 static void 218 parse_auth_server(FILE *file, c har *filename, int *linenum)217 parse_auth_server(FILE *file, const char *filename, int *linenum) 219 218 { 220 219 char *host = NULL, … … 401 400 */ 402 401 static void 403 parse_firewall_ruleset(c har *ruleset, FILE *file,char *filename, int *linenum)402 parse_firewall_ruleset(const char *ruleset, FILE *file, const char *filename, int *linenum) 404 403 { 405 404 char line[MAX_BUF], … … 478 477 */ 479 478 static int 480 _parse_firewall_rule(c har *ruleset, char *leftover)479 _parse_firewall_rule(const char *ruleset, char *leftover) 481 480 { 482 481 int i; … … 614 613 615 614 t_firewall_rule * 616 get_ruleset(c har *ruleset)615 get_ruleset(const char *ruleset) 617 616 { 618 617 t_firewall_ruleset *tmp; … … 631 630 */ 632 631 void 633 config_read(c har *filename)632 config_read(const char *filename) 634 633 { 635 634 FILE *fd; … … 830 829 { 831 830 config_notnull(config.gw_interface, "GatewayInterface"); 832 config_notnull(config.auth_servers, "AuthServer");831 config_notnull(config.auth_servers, "AuthServer"); 833 832 834 833 if (missing_parms) { … … 842 841 */ 843 842 static void 844 config_notnull( void *parm,char *parmname)843 config_notnull(const void *parm, const char *parmname) 845 844 { 846 845 if (parm == NULL) { -
trunk/wifidog/src/conf.h
r1369 r1373 166 166 167 167 /** @brief Reads the configuration file */ 168 void config_read(c har *filename);168 void config_read(const char *filename); 169 169 170 170 /** @brief Check that the configuration is valid */ … … 178 178 179 179 /** @brief Fetch a firewall rule set. */ 180 t_firewall_rule *get_ruleset(c har *);180 t_firewall_rule *get_ruleset(const char *); 181 181 182 182 void parse_trusted_mac_list(char *); -
trunk/wifidog/src/fw_iptables.c
r1305 r1373 49 49 #include "client_list.h" 50 50 51 static int iptables_do_command(c har *format, ...);52 static char *iptables_compile(c har *, char *,t_firewall_rule *);53 static void iptables_load_ruleset(c har *, char *,char *);51 static int iptables_do_command(const char *format, ...); 52 static char *iptables_compile(const char *, const char *, const t_firewall_rule *); 53 static void iptables_load_ruleset(const char *, const char *, const char *); 54 54 55 55 extern pthread_mutex_t client_list_mutex; … … 63 63 * */ 64 64 static int 65 iptables_do_command(c har *format, ...)65 iptables_do_command(const char *format, ...) 66 66 { 67 67 va_list vlist; … … 81 81 82 82 rc = execute(cmd, fw_quiet); 83 84 if (rc!=0) 85 debug(LOG_ERR, "iptables comand tailed: %s", cmd); 83 86 84 87 free(cmd); … … 96 99 */ 97 100 static char * 98 iptables_compile(c har * table, char *chain,t_firewall_rule *rule)101 iptables_compile(const char * table, const char *chain, const t_firewall_rule *rule) 99 102 { 100 103 char command[MAX_BUF], … … 140 143 */ 141 144 static void 142 iptables_load_ruleset(c har * table, char *ruleset,char *chain)145 iptables_load_ruleset(const char * table, const char *ruleset, const char *chain) 143 146 { 144 147 t_firewall_rule *rule; … … 167 170 iptables_fw_set_authservers(void) 168 171 { 169 s_config *config;172 const s_config *config; 170 173 t_auth_serv *auth_server; 171 174 … … 186 189 iptables_fw_init(void) 187 190 { 188 s_config *config;189 char * gw_interface = NULL;190 char * gw_address = NULL;191 char * ext_interface = NULL;192 int gw_port = 0;193 t_trusted_mac *p;191 const s_config *config; 192 char * gw_interface = NULL; 193 char * gw_address = NULL; 194 char * ext_interface = NULL; 195 int gw_port = 0; 196 t_trusted_mac *p; 194 197 195 fw_quiet = 0;198 fw_quiet = 0; 196 199 197 200 LOCK_CONFIG(); … … 400 403 int 401 404 iptables_fw_destroy_mention( 402 c har * table,403 c har * chain,404 c har * mention405 const char * table, 406 const char * chain, 407 const char * mention 405 408 ) { 406 409 FILE *p = NULL; … … 451 454 /** Set if a specific client has access through the firewall */ 452 455 int 453 iptables_fw_access(fw_access_t type, c har *ip,char *mac, int tag)456 iptables_fw_access(fw_access_t type, const char *ip, const char *mac, int tag) 454 457 { 455 458 int rc; -
trunk/wifidog/src/fw_iptables.h
r901 r1373 64 64 65 65 /** @brief Helper function for iptables_fw_destroy */ 66 int iptables_fw_destroy_mention( c har * table, char * chain,char * mention);66 int iptables_fw_destroy_mention( const char * table, const char * chain, const char * mention); 67 67 68 68 /** @brief Define the access of a specific client */ 69 int iptables_fw_access(fw_access_t type, c har *ip,char *mac, int tag);69 int iptables_fw_access(fw_access_t type, const char *ip, const char *mac, int tag); 70 70 71 71 /** @brief All counters in the client list */ -
trunk/wifidog/src/http.c
r1370 r1373 290 290 { 291 291 s_config *config = config_get_config(); 292 unsignedchar *buffer;292 char *buffer; 293 293 struct stat stat_info; 294 294 int fd; … … 307 307 } 308 308 309 buffer=( unsignedchar*)safe_malloc(stat_info.st_size+1);309 buffer=(char*)safe_malloc(stat_info.st_size+1); 310 310 written=read(fd, buffer, stat_info.st_size); 311 311 if (written==-1) { -
trunk/wifidog/src/ping_thread.c
r1305 r1373 94 94 ping(void) 95 95 { 96 size_t numbytes, 97 totalbytes;96 ssize_t numbytes; 97 size_t totalbytes; 98 98 int sockfd, nfds, done; 99 99 char request[MAX_BUF]; -
trunk/wifidog/src/util.c
r1358 r1373 52 52 53 53 #ifdef __linux__ 54 #include <netinet/in.h> 54 55 #include <net/if.h> 55 56 #endif … … 155 156 156 157 char * 157 get_iface_ip(c har *ifname)158 get_iface_ip(const char *ifname) 158 159 { 159 160 #if defined(__linux__) … … 181 182 in.s_addr = ip; 182 183 183 ip_str = (char *)inet_ntoa(in);184 ip_str = inet_ntoa(in); 184 185 close(sockd); 185 186 return safe_strdup(ip_str); … … 213 214 214 215 char * 215 get_iface_mac(c har *ifname)216 get_iface_mac(const char *ifname) 216 217 { 217 218 #if defined(__linux__) -
trunk/wifidog/src/util.h
r969 r1373 36 36 37 37 /* @brief Get IP address of an interface */ 38 char *get_iface_ip(c har *ifname);38 char *get_iface_ip(const char *ifname); 39 39 40 40 /* @brief Get MAC address of an interface */ 41 char *get_iface_mac(c har *ifname);41 char *get_iface_mac(const char *ifname); 42 42 43 43 /* @brief Get interface name of default gateway */ -
trunk/wifidog/src/wdctl.c
r901 r1373 47 47 static void parse_commandline(int, char **); 48 48 static int connect_to_server(char *); 49 static int send_request(int, char *);49 static size_t send_request(int, char *); 50 50 static void wdctl_status(void); 51 51 static void wdctl_stop(void); … … 167 167 } 168 168 169 static int169 static size_t 170 170 send_request(int sock, char *request) 171 171 { 172 s size_t len,173 written;172 size_t len; 173 ssize_t written; 174 174 175 175 len = 0; … … 184 184 } 185 185 186 return ((int)len);186 return len; 187 187 } 188 188 … … 239 239 char buffer[4096]; 240 240 char request[64]; 241 int len,242 rlen;241 size_t len; 242 int rlen; 243 243 244 244 sock = connect_to_server(config.socket);
