diff options
author | Marian Buschsieweke <marian.buschsieweke@ovgu.de> | 2017-06-20 09:54:59 +0200 |
---|---|---|
committer | Leonardo Arena <rnalrd@alpinelinux.org> | 2017-06-23 08:14:50 +0000 |
commit | 9d245a72c8fbcc66c992228736746cafdc3c5690 (patch) | |
tree | a5f011888762d9f46b5c0676145cfb2bfcf371d7 /testing/wpa_actiond/no_trampoline.patch | |
parent | b849b481a0446d7ef2458232a8819ce0b301e629 (diff) | |
download | aports-9d245a72c8fbcc66c992228736746cafdc3c5690.tar.bz2 aports-9d245a72c8fbcc66c992228736746cafdc3c5690.tar.xz |
testing/wpa_actiond: new aport
Daemon that connects to wpa_supplicant and handles connect and disconnect events
https://git.archlinux.org/wpa_actiond.git
Use case: A plain and simple way to automatically configure wireless networks
depending on SSID by invoking user supplied scripts.
I provided a patch to convert the nested function into a regular one, so that
GCC won't generate a trampoline. In addition, OpenRC integration was added.
Diffstat (limited to 'testing/wpa_actiond/no_trampoline.patch')
-rw-r--r-- | testing/wpa_actiond/no_trampoline.patch | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/testing/wpa_actiond/no_trampoline.patch b/testing/wpa_actiond/no_trampoline.patch new file mode 100644 index 0000000000..560f05aafb --- /dev/null +++ b/testing/wpa_actiond/no_trampoline.patch @@ -0,0 +1,95 @@ +--- wpa_actiond-1.4-old/wpa_actiond.c ++++ wpa_actiond-1.4-new/wpa_actiond.c +@@ -72,6 +72,23 @@ + WPA_ACTIOND_LOG_CUSTOM_ERROR + }; + ++/* wpa_supplicant control structure */ ++static struct wpa_ctrl *ctrl; ++ ++/* states and events */ ++static enum wpastate state = WPA_ACTIOND_STATE_UNDEFINED; ++static enum wpaevent ev; ++/* select stuff */ ++static int ctrl_fd; ++static fd_set ctrl_fds; ++/* save ssid */ ++static char ssid[SSIDLEN], old_ssid[SSIDLEN]; ++static char idstr[IDSTRLEN], old_idstr[IDSTRLEN]; ++/* for terminate handler*/ ++static const char *iface; ++static const char *script; ++static const char *pidfile; ++ + static void logevent(enum wpa_actiond_logevent l, const char *iface, const char *arg) { + static int isopen = 0, tostderr = 0; + +@@ -270,48 +287,43 @@ + } + } + +-static void loop(const char *iface, const char *ctrlpath, const int disconnect_timeout, const char *script, const char *pidfile) { +- /* wpa_supplicant control structure */ +- struct wpa_ctrl *ctrl; ++static void terminate(int s) { ++ if(state == WPA_ACTIOND_STATE_CONNECTED || state == WPA_ACTIOND_STATE_CONNECTION_LOST) { ++ logevent(WPA_ACTIOND_LOG_DISCONNECTED, iface, ssid); ++ action(WPA_ACTIOND_ACTION_DISCONNECT, iface, ssid, idstr, wpa_ctrl_get_fd(ctrl), script); ++ } ++ logevent(WPA_ACTIOND_LOG_TERMINATE, iface, ""); ++ ++ FD_ZERO(&ctrl_fds); ++ wpa_ctrl_detach(ctrl); ++ wpa_ctrl_close(ctrl); ++ unlink(pidfile); ++ exit(0); ++} ++ ++static void loop(const char *_iface, const char *ctrlpath, const int disconnect_timeout, const char *_script, const char *_pidfile) { + /* buffer for wpa_supplicant replies */ + char reply[BUFLEN]; + size_t reply_len; +- /* states and events */ +- enum wpastate state = WPA_ACTIOND_STATE_UNDEFINED; +- enum wpaevent ev; +- /* select stuff */ +- int ctrl_fd; +- fd_set ctrl_fds; + int r; + /* select timeout */ + struct timeval timeout; + struct timeval ping_timeout; +- /* save ssid */ +- char ssid[SSIDLEN], old_ssid[SSIDLEN]; +- char idstr[IDSTRLEN], old_idstr[IDSTRLEN]; + /* path to control socket */ + char *ctrlsock = NULL; + int ctrlsocklen; + ++ /* set up globals for terminate signal handler */ ++ iface = _iface; ++ script = _script; ++ pidfile = _pidfile; ++ + ssid[0] = '\0'; + old_ssid[0] = '\0'; + idstr[0] = '\0'; + old_idstr[0] = '\0'; + + /* set up signals */ +- void terminate(int s) { +- if(state == WPA_ACTIOND_STATE_CONNECTED || state == WPA_ACTIOND_STATE_CONNECTION_LOST) { +- logevent(WPA_ACTIOND_LOG_DISCONNECTED, iface, ssid); +- action(WPA_ACTIOND_ACTION_DISCONNECT, iface, ssid, idstr, wpa_ctrl_get_fd(ctrl), script); +- } +- logevent(WPA_ACTIOND_LOG_TERMINATE, iface, ""); +- +- FD_ZERO(&ctrl_fds); +- wpa_ctrl_detach(ctrl); +- wpa_ctrl_close(ctrl); +- unlink(pidfile); +- exit(0); +- } + signal(SIGTERM, terminate); + signal(SIGHUP, SIG_IGN); + |