diff options
| author | Lennart Poettering <lennart@poettering.net> | 2003-12-11 18:28:55 +0000 |
|---|---|---|
| committer | Lennart Poettering <lennart@poettering.net> | 2003-12-11 18:28:55 +0000 |
| commit | 8421b14ba340b6615c2b12bad2a87c177fab5de5 (patch) | |
| tree | f3590da302c8f2fd5e9c4ef22edae81416c16d79 /src/waproamd.c | |
| parent | 86f7689a0cc7bd0509ac63f2b1d065ab45e312b6 (diff) | |
some changes
git-svn-id: file:///home/lennart/svn/public/waproamd/trunk@53 022f378f-78c4-0310-b860-d162c87e6274
Diffstat (limited to 'src/waproamd.c')
| -rw-r--r-- | src/waproamd.c | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/src/waproamd.c b/src/waproamd.c index 91dd26b..3dba456 100644 --- a/src/waproamd.c +++ b/src/waproamd.c @@ -20,6 +20,10 @@ #define _GNU_SOURCE +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + #include <assert.h> #include <string.h> #include <time.h> @@ -33,20 +37,16 @@ #include <libdaemon/dlog.h> #include <libdaemon/dfork.h> #include <libdaemon/dsignal.h> +#include <libdaemon/dexec.h> #include "iwapi.h" #include "interface.h" -#include "exec.h" #include "nlapi.h" #include "ifmonitor.h" #include "assocwatch.h" #include "waproamd.h" #include "iwhostroam.h" -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - char *interface_name = NULL; int interface_index = -1; @@ -63,9 +63,7 @@ int use_assocwatch = 1, use_ifmonitor = 0, daemonize = 1, wait_on_fork = 0, -#ifdef DAEMON_PID_FILE_KILL_WAIT_AVAILABLE wait_on_kill = 0, -#endif use_syslog = 1, use_userspace_roaming = 1; @@ -174,6 +172,7 @@ int read_scan(struct interface *i, struct ap_info **ap) { int run_script(struct ap_info *ai, const char *arg) { char t[32]; char path[PATH_MAX]; + int ret = 0; if (get_script_path(path, sizeof(path), ai) < 0) get_script_path(path, sizeof(path), NULL); @@ -184,7 +183,15 @@ int run_script(struct ap_info *ai, const char *arg) { setenv("ESSID", ai->essid, 1); setenv("ESSID_ESCAPED", escape_essid(ai->essid), 1); - return log_exec(SCRIPTDIR, path, arg); + if (daemon_exec(SCRIPTDIR, &ret, path, path, arg, (char*) 0) < 0) + daemon_log(LOG_WARNING, "Script execution failed abnormously."); + else if (ret != 0) + daemon_log(LOG_WARNING, "Script returned %i as return value.", ret); + else + daemon_log(LOG_INFO, "Script successfully executed."); + + return 0; + }; @@ -544,9 +551,7 @@ void usage(char *p) { " -s --no-syslog Do not use syslog, use stderr instead (for debugging) (%s)\n" " -i --iface=IFACE Specify network interface (%s)\n" " -w --wait-on-fork Wait until daemon fork finished (%s)\n" -#ifdef DAEMON_PID_FILE_KILL_WAIT_AVAILABLE " -W --wait-on-kill When run with -k, wait until the daemon died (%s)\n" -#endif " -M --monitor Use interface monitoring (%s)\n" " -e --no-event Don't use wireless event API (%s)\n" " -U --no-userspace-roaming Don't enable user space roaming via private ioctl (%s)\n" @@ -564,9 +569,7 @@ void usage(char *p) { !use_syslog ? "on" : "off", interface_name, wait_on_fork ? "on" : "off", -#ifdef DAEMON_PID_FILE_KILL_WAIT_AVAILABLE - wait_on_kill ? "on" : "off", -#endif + wait_on_kill ? "on" : "off", use_ifmonitor ? "on" : "off", use_assocwatch ? "off" : "on", use_userspace_roaming ? "off" : "on", @@ -580,9 +583,7 @@ void parse_args(int argc, char *argv[]) { {"no-syslog", no_argument, 0, 's'}, {"iface", required_argument, 0, 'i'}, {"wait-on-fork", no_argument, 0, 'w'}, -#ifdef DAEMON_PID_FILE_KILL_WAIT_AVAILABLE {"wait-on-kill", no_argument, 0, 'W'}, -#endif {"monitor", no_argument, 0, 'M'}, {"no-event", no_argument, 0, 'e'}, {"no-userspace-roaming", no_argument, 0, 'U'}, @@ -625,11 +626,9 @@ void parse_args(int argc, char *argv[]) { wait_on_fork = !wait_on_fork; break; -#ifdef DAEMON_PID_FILE_KILL_WAIT_AVAILABLE case 'W': wait_on_kill = !wait_on_kill; break; -#endif case 'S': _suspend = 1; break; @@ -659,12 +658,14 @@ void parse_args(int argc, char *argv[]) { daemon_log(LOG_ERR, "Scan interval must be a positive, nonzero integer."); exit(1); } - + break; + case 'p': if ((poll_interval = atoi(optarg)) < 0) { daemon_log(LOG_ERR, "Poll interval must be a positive, nonzero integer."); exit(1); } + break; case 'h': _help = 1; @@ -705,11 +706,9 @@ void parse_args(int argc, char *argv[]) { if (_kill || _resume || _suspend || _issuescan) { int rv; -#ifdef DAEMON_PID_FILE_KILL_WAIT_AVAILABLE if (_kill && wait_on_kill) rv = daemon_pid_file_kill_wait(SIGINT, 5); else -#endif rv = daemon_pid_file_kill(_kill ? SIGINT : (_resume ? SIGUSR2 : (_issuescan ? SIGHUP : SIGUSR1))); if (rv < 0) { |
