diff options
Diffstat (limited to 'src/waproamd.c')
-rw-r--r-- | src/waproamd.c | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/src/waproamd.c b/src/waproamd.c index 33df905..96bc0bd 100644 --- a/src/waproamd.c +++ b/src/waproamd.c @@ -64,16 +64,12 @@ char log_ident[32], pid_ident[32]; int issue_scan(struct interface *i) { - //daemon_log(LOG_ERR, "Scanning...\n"); - - if (iw_set_mode(i, IW_MODE_INFRA) < 0) - return -1; + /* daemon_log(LOG_ERR, "Scanning...\n"); */ -/* if (iw_set_ap(i, &null_ap) < 0) */ -/* return -1; */ - - if (iw_set_essid(i, NULL) < 0) - return -1; + /* Due to driver issues, the return codes of these function calls are no longer evaluated */ + iw_set_mode(i, IW_MODE_INFRA); + iw_set_ap(i, &null_ap); + iw_set_essid(i, NULL); if (iw_scan(i) < 0) return -1; @@ -81,7 +77,7 @@ int issue_scan(struct interface *i) { return 0; } -void get_script_path(char *path, int l, struct hw_addr *ap) { +void get_script_path(char *path, int l, struct hw_addr *ap, int uc) { assert(path && l); if (!ap) { @@ -89,7 +85,7 @@ void get_script_path(char *path, int l, struct hw_addr *ap) { return; } - snprintf(path, l, "%s/%02x:%02x:%02x:%02x:%02x:%02x", + snprintf(path, l, uc ? "%s/%02X:%02X:%02X:%02X:%02X:%02X": "%s/%02x:%02x:%02x:%02x:%02x:%02x", SCRIPTDIR, ap->addr[0], ap->addr[1], ap->addr[2], ap->addr[3], ap->addr[4], ap->addr[5]); @@ -104,8 +100,11 @@ static int scan_result_cb(struct ap_info*ap) { char path[PATH_MAX]; assert(ap); - get_script_path(path, sizeof(path), &ap->ap); - b = access(path, X_OK) == 0; + get_script_path(path, sizeof(path), &ap->ap, 0); + if (!(b = !access(path, X_OK))) { + get_script_path(path, sizeof(path), &ap->ap, 1); + b = !access(path, X_OK); + } if (selected_ap_valid) { @@ -138,10 +137,14 @@ int read_scan(struct interface *i, struct ap_info **ap) { int run_script(struct hw_addr *ap, const char *arg) { char path[PATH_MAX]; - get_script_path(path, sizeof(path), ap); + get_script_path(path, sizeof(path), ap, 0); - if (access(path, X_OK) < 0) - get_script_path(path, sizeof(path), NULL); + if (access(path, X_OK) < 0) { + get_script_path(path, sizeof(path), ap, 1); + + if (access(path, X_OK) < 0) + get_script_path(path, sizeof(path), NULL, 0); + } return log_exec(SCRIPTDIR, path, arg); }; @@ -218,7 +221,7 @@ int go(struct interface *i) { goto finish; } - if (daemon_signal_init(SIGINT, SIGTERM, SIGQUIT, SIGHUP, -1) < 0) { + if (daemon_signal_init(SIGINT, SIGTERM, SIGQUIT, SIGHUP, SIGCHLD, -1) < 0) { daemon_log(LOG_ERR, "Could not register signal handler: %s", strerror(errno)); goto finish; } @@ -411,6 +414,9 @@ int go(struct interface *i) { next_scan = 0; break; + case SIGCHLD: + break; + default: daemon_log(LOG_INFO, "Ignoring unknown signal %s", strsignal(sig)); break; |