X-Original-To: alpine-aports@lists.alpinelinux.org Received: from mail.ovgu.de (mail.ovgu.de [141.44.1.66]) by lists.alpinelinux.org (Postfix) with ESMTP id 805E25C4C9B for ; Tue, 20 Jun 2017 07:55:53 +0000 (GMT) Received: from mail.ovgu.de (localhost [127.0.0.1]) by localhost (Postfix) with SMTP id 5A8EC40060 for ; Tue, 20 Jun 2017 09:55:51 +0200 (CEST) Received: from localhost.localdomain (euk-gateway.cs.uni-magdeburg.de [141.44.25.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.ovgu.de (Postfix) with ESMTPSA id C36E54005F; Tue, 20 Jun 2017 09:55:50 +0200 (CEST) From: Marian Buschsieweke To: alpine-aports@lists.alpinelinux.org Cc: Marian Buschsieweke Subject: [alpine-aports] [PATCH] testing/wpa_actiond: new aport Date: Tue, 20 Jun 2017 09:54:59 +0200 Message-Id: <20170620075459.8882-1-marian.buschsieweke@ovgu.de> X-Mailer: git-send-email 2.13.1 X-PMX-Version: 6.3.3.2656215, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2017.6.20.74816, AntiVirus-Engine: 5.38.0, AntiVirus-Data: 2017.6.19.5380002 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' HTML_00_01 0.05, HTML_00_10 0.05, LEGITIMATE_SIGNS 0, MULTIPLE_REAL_RCPTS 0, URI_WITH_PATH_ONLY 0, __ANY_URI 0, __C230066_P5 0, __CC_NAME 0, __CC_NAME_DIFF_FROM_ACC 0, __CC_REAL_NAMES 0, __CP_URI_IN_BODY 0, __FRAUD_MONEY_CURRENCY 0, __FRAUD_MONEY_CURRENCY_DOLLAR 0, __FROM_DOMAIN_IN_ANY_CC1 0, __FROM_DOMAIN_IN_RCPT 0, __HAS_CC_HDR 0, __HAS_FROM 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HTTPS_URI 0, __MIME_TEXT_ONLY 0, __MIME_TEXT_P 0, __MIME_TEXT_P1 0, __MULTIPLE_URI_TEXT 0, __NO_HTML_TAG_RAW 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_IN_BODY 0, __URI_NOT_IMG 0, __URI_NO_WWW 0, __URI_NS , __URI_WITH_PATH 0' X-Spam-Score: Gauge=IIIIIIII X-PMX-consideredAsSpam: no X-Mailinglist: alpine-aports Precedence: list List-Id: Alpine Development List-Unsubscribe: List-Post: List-Help: List-Subscribe: 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. --- testing/wpa_actiond/APKBUILD | 46 ++++++++++++++++ testing/wpa_actiond/no_trampoline.patch | 95 +++++++++++++++++++++++++++++++++ testing/wpa_actiond/wpa_actiond.confd | 16 ++++++ testing/wpa_actiond/wpa_actiond.initd | 22 ++++++++ 4 files changed, 179 insertions(+) create mode 100644 testing/wpa_actiond/APKBUILD create mode 100644 testing/wpa_actiond/no_trampoline.patch create mode 100644 testing/wpa_actiond/wpa_actiond.confd create mode 100644 testing/wpa_actiond/wpa_actiond.initd diff --git a/testing/wpa_actiond/APKBUILD b/testing/wpa_actiond/APKBUILD new file mode 100644 index 0000000000..e0b14f5232 --- /dev/null +++ b/testing/wpa_actiond/APKBUILD @@ -0,0 +1,46 @@ +# Contributor: Marian +# Maintainer: Marian +pkgname=wpa_actiond +pkgver=1.4 +pkgrel=1 +pkgdesc="Daemon that connects to wpa_supplicant and handles connect and disconnect events" +url="https://git.archlinux.org/wpa_actiond.git/" +arch="all" +license="GPL2" +depends="" +makedepends="" +subpackages="" +source="https://git.archlinux.org/${pkgname}.git/snapshot/${pkgname}-${pkgver}.tar.xz + no_trampoline.patch + wpa_actiond.confd + wpa_actiond.initd" +options="!check" + +_builddir="$srcdir/$pkgname-$pkgver" + +prepare() { + local i + cd "$_builddir" + for i in $source; do + case $i in + *.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;; + esac + done +} + +build() { + cd "$_builddir" + make +} + +package() { + cd "$_builddir" + install -Dm755 -t "${pkgdir}/usr/sbin/" wpa_actiond + install -Dm755 ../wpa_actiond.initd "${pkgdir}/etc/init.d/wpa_actiond" + install -Dm755 ../wpa_actiond.confd "${pkgdir}/etc/conf.d/wpa_actiond" +} + +sha512sums="1ac38cdb6ce534cb14cfada4def31c17feff61408868ffd63cd1a516cdbade992719b575a96f5ab4046a1d451bfae526ccdf8eb68cfc7bdc022df3506ae07296 wpa_actiond-1.4.tar.xz +ebd49ffe1a83e08cd51d99677ce8c3f84ecdd4f3ec4a2c81a336bd87af56db0d36534003f9d7c3b34de129a3a4ef4ee4e9683f2a54729af86c946206c11cd20d no_trampoline.patch +104ffd6e04d8f69fb238428256e2bc4a8e6acd5e333fc411a72b5ae2d82f4efff6e8d4e08a282ca1a8c2ffe0b2a7fd8cd3ac222e19d6c177c721b957ef4fa5e9 wpa_actiond.confd +8e902f2bd6bad2983e1048d18a150176b65608bd74971a72fe66cd03dba3f80893240294ffac83820fc5c46e5cb10c9267d53f60c4d2d55f7a3e45005e12fbbe wpa_actiond.initd" 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); + diff --git a/testing/wpa_actiond/wpa_actiond.confd b/testing/wpa_actiond/wpa_actiond.confd new file mode 100644 index 0000000000..86fcb6a6e8 --- /dev/null +++ b/testing/wpa_actiond/wpa_actiond.confd @@ -0,0 +1,16 @@ +# /etc/conf.d/wpa_actiond: config file for /etc/init.d/wpa_actiond + +# Interface to listen at +WPA_ACTIOND_INTERFACE="wlan0" + +# Replace with custom script: +WPA_ACTIOND_SCRIPT="/usr/bin/logger" +# > The action script takes four parameters: +# > 1) The interface name +# > 2) The SSID of the wireless network or empty string if using wired driver +# > 3) The id_str parameter of the wpa_supplicant network section +# > 4) One of the strings CONNECT, LOST, REESTABLISHED, FAILED and DISCONNECT + +# Add custom arguments +WPA_ACTIOND_OPTS="" +# see `wpa_actiond -h` for mor information diff --git a/testing/wpa_actiond/wpa_actiond.initd b/testing/wpa_actiond/wpa_actiond.initd new file mode 100644 index 0000000000..9861168871 --- /dev/null +++ b/testing/wpa_actiond/wpa_actiond.initd @@ -0,0 +1,22 @@ +#!/sbin/openrc-run + +depend() +{ + need net wpa_supplicant +} + +start() +{ + ebegin "Starting wpa_actiond" + start-stop-daemon --start --quiet --exec /usr/sbin/wpa_actiond -p /var/run/wpa_actiond.pid -- \ + -i ${WPA_ACTIOND_INTERFACE} -a ${WPA_ACTIOND_SCRIPT} ${WPA_ACTIOND_OPTS} + eend $? +} + +stop() +{ + ebegin "Stopping wpa_actiond" + start-stop-daemon --stop --quiet --exec /usr/sbin/wpa_actiond -p /var/run/wpa_actiond.pid + eend $? +} + -- 2.13.1 --- Unsubscribe: alpine-aports+unsubscribe@lists.alpinelinux.org Help: alpine-aports+help@lists.alpinelinux.org ---