From patchwork Thu Feb 7 14:49:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov via arch-projects X-Patchwork-Id: 994 Return-Path: Delivered-To: patchwork@archlinux.org Received: from apollo.archlinux.org (localhost [127.0.0.1]) by apollo.archlinux.org (Postfix) with ESMTP id B20CDB4FE9A0 for ; Thu, 7 Feb 2019 14:50:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on apollo X-Spam-Level: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00=-1, DKIMWL_WL_HIGH=-0.001,DKIM_SIGNED=0.1,DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3, T_DMARC_POLICY_NONE=0.01 autolearn=ham autolearn_force=no version=3.4.2 X-Spam-BL-Results: [127.0.0.11] [127.0.9.2] Received: from orion.archlinux.org (orion.archlinux.org [88.198.91.70]) by apollo.archlinux.org (Postfix) with ESMTPS for ; Thu, 7 Feb 2019 14:50:02 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id 77DCA1077A85AF; Thu, 7 Feb 2019 14:50:00 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [5.9.250.164]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits)) (No client certificate requested) by orion.archlinux.org (Postfix) with ESMTPS; Thu, 7 Feb 2019 14:50:00 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 57F7A207A5; Thu, 7 Feb 2019 14:50:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=luna2; t=1549551000; bh=IYUaWaG6XePFrwcPo2aS7dsO4r2daB/E+cOGbUP2HAY=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc; b=leCX+6Q5VJU2U4D6D25cvRVGjRrrvf7iGdkL8RxmepfKvnghx9DJaeFk0MGm5XPFt N4HXO93Hyxz9QvJ4DbYUCjYqim4DEBpZQ0fevReegFey7zhE04MPEXd4GSK7Cb7tBI sPqzt9XfqfGxP8MN6oXFq0qx2UnU9eQXhUoFK+i0XMbxFuKXYnuUx0dPdb0Vf69ozD ekX5vq0MuJiUDctIAkEx/IR4cMFGmKOxMp7eRE8O7gtutncPVTie49wOlOzO1PfvZG q/xVkJYRGHYco8auYwiegCrW8I7iIeITj0XAQ3l0wzmzc0wHsilJHaX8PvOKhyQsJF dcD6ObaiEmoJ/aAq37KD6ULryAOoa3fnKtQhF6qGXUFtQsITxItoMum3RI48tFhWU+ hwMfoj6T2oUL1Fc+eK5HpNDjCOMMParRIAHTdEZdNQdj/FTXYrIdR0E6WzltwwUaQj xYeF4z2QOYgj1PmhI2PbJbGXF5HDY3/DU09FgMDqOv+Jd7d2ju22A+cuL+MAokeGle 9CtitTqgm9kyQ4rOHwY+O1AreqjN2LYKAs7mI7lrWSsd+hwD03StmyKik7ShK6WKCr TYshxoe6YDmWURyFZbc3IJPMvTW2DjPGuPgMIm0xods6jWvPiIZikZXmVTUgp7SOTV 9prf6D+OdoQC8BzY1QUXWUHo= Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 9B65B20781 for ; Thu, 7 Feb 2019 14:49:56 +0000 (UTC) Received: from orion.archlinux.org (orion.archlinux.org [88.198.91.70]) by luna.archlinux.org (Postfix) with ESMTPS for ; Thu, 7 Feb 2019 14:49:56 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id A3CA51077A83ED for ; Thu, 7 Feb 2019 14:49:50 +0000 (UTC) Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by orion.archlinux.org (Postfix) with ESMTPS for ; Thu, 7 Feb 2019 14:49:50 +0000 (UTC) Received: by mail-ed1-x535.google.com with SMTP id b17so100334eds.2 for ; Thu, 07 Feb 2019 06:49:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=jLMlVsaVCBEUWtFcR4MAjAzecrEhqvwGB/1QOaWFGFc=; b=iawqc5C6eHoES7qofkoGORpXQWdWWMUN1sbw8Sn22UJYzjafuRV0eSqIbDsSCHL+/l RogbsGevau0LTa4XHOU1nw7rteXVAFgkPKb5arCScbwaHwqcRMsqOK/4WIhM+eXSTudB pTju6g0re/qIdGh9p8z0JsVS9b9mK3R560ebN8CS8YE6xgyX+P5UjdLTZWyBUdHBxKbg r6+xnPLS+niQAaa9vMDmlsipPg/K2xas5SrxAvMN+Cs9R9R8hojDs99VwsGFl7QvUSAF RAgu3mZaMMhiOWJnOCJ1ryfnZvt5jZ04HpEWVKbq6FFBLG/MK/4DNFJhW6wquQ+DRxM2 9Mew== X-Gm-Message-State: AHQUAuadzNIKym15ZW04h75bH7vIAwIxIMb2wr0TfzVEnls9P6VGKpcp 0Ovvmr3KqJytxtInquMyekZW4NQ5 X-Google-Smtp-Source: AHgI3Ialt20eTosC3hhdUF1AGK1hZUYHP32eobsiwm7dQxEAXLzVXcCsWGQ0TUJLjOfZQPVTj7+DNg== X-Received: by 2002:a17:906:d288:: with SMTP id ay8mr12204092ejb.59.1549550989886; Thu, 07 Feb 2019 06:49:49 -0800 (PST) Received: from Mindship-03 (ip5653397a.direct-adsl.nl. [86.83.57.122]) by smtp.gmail.com with ESMTPSA id h47sm7078927eda.8.2019.02.07.06.49.49 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 07 Feb 2019 06:49:49 -0800 (PST) Date: Thu, 7 Feb 2019 15:49:45 +0100 To: arch-projects@archlinux.org Message-ID: <20190207144945.GA19874@Mindship-03> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.11.3 (2019-02-01) Subject: [arch-projects] [netctl][PATCH] Move away from using wpa_actiond X-BeenThere: arch-projects@archlinux.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Arch Linux projects development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Jouke Witteveen via arch-projects Reply-To: Arch Linux projects development discussion Cc: Jouke Witteveen Errors-To: arch-projects-bounces@archlinux.org Sender: "arch-projects" The same functionality is provided by wpa_supplicant, so we do not need an extra and Arch Linux specific dependency. --- README | 4 ++-- contrib/PKGBUILD.in | 1 - src/lib/auto.action | 31 ++++++++++++++----------------- src/netctl-auto | 30 +++++++++++++----------------- 4 files changed, 29 insertions(+), 37 deletions(-) diff --git a/README b/README index 95df087..f3ca634 100644 --- a/README +++ b/README @@ -9,8 +9,8 @@ Optional: - dhcpcd or dhclient: for DHCP support - wpa_supplicant: for WPA support - dialog: for the interactive assistant -- ifplugd: for automatic connection -- wpa_actiond: for automatic connection +- ifplugd: for automatic wired connections +- ppp: for PPP support For documentation generation: - asciidoc diff --git a/contrib/PKGBUILD.in b/contrib/PKGBUILD.in index b5ce44c..f3359c6 100644 --- a/contrib/PKGBUILD.in +++ b/contrib/PKGBUILD.in @@ -15,7 +15,6 @@ optdepends=('dialog: for the menu based wifi assistant' 'dhcpcd: for DHCP support (or dhclient)' 'wpa_supplicant: for wireless networking support' 'ifplugd: for automatic wired connections through netctl-ifplugd' - 'wpa_actiond: for automatic wireless connections through netctl-auto' 'ppp: for PPP connections' 'openvswitch: for Open vSwitch connections' ) diff --git a/src/lib/auto.action b/src/lib/auto.action index f81d4e3..999f66f 100755 --- a/src/lib/auto.action +++ b/src/lib/auto.action @@ -5,16 +5,17 @@ . "$SUBR_DIR/ip" export INTERFACE="$1" -export SSID="$2" -export ACTION="$4" +export ACTION="$2" +PROFILE_STATE="$STATE_DIR/netctl-auto-$INTERFACE.profile" -load_profile "$3" load_interface_config "$INTERFACE" case $ACTION in - CONNECT) + CONNECTED) + load_profile "$WPA_ID_STR" DhcpcdOptions+=" -K -L" ip_set || exit 1 + echo "$Profile" > "$PROFILE_STATE" # Sandbox the eval if ! ( do_debug eval "$ExecUpPost" ); then # Failing ExecUpPost will take the connection down @@ -22,20 +23,16 @@ case $ACTION in exit 1 fi ;; - DISCONNECT) - # Sandbox the eval - if ! ( do_debug eval "$ExecDownPre" ); then - exit 1 + DISCONNECTED) + if [[ -s "$PROFILE_STATE" ]]; then + load_profile "$(< "$PROFILE_STATE")" + rm -f "$PROFILE_STATE" + # Sandbox the eval + if ! ( do_debug eval "$ExecDownPre" ); then + exit 1 + fi + ip_unset fi - ip_unset - ;; - LOST|REESTABLISHED) - # Not handled. - exit 0 - ;; - *) - # ??? - exit 1 ;; esac diff --git a/src/netctl-auto b/src/netctl-auto index 18d2e10..7e4062e 100755 --- a/src/netctl-auto +++ b/src/netctl-auto @@ -6,7 +6,6 @@ . "$SUBR_DIR/rfkill" . "$SUBR_DIR/wpa" -: ${ACTIOND:=wpa_actiond -p /run/wpa_supplicant} : ${ACTION_SCRIPT:=$SUBR_DIR/auto.action} @@ -193,11 +192,10 @@ list() { done } -## Start and generate config file for the WPA supplicant, start wpa_actiond +## Start and generate config file for the WPA supplicant, monitor for changes # $1: interface start() { local interface="$1" - local pidfile="$STATE_DIR/wpa_actiond-$interface.pid" if interface_is_up "$interface"; then exit_error "The interface '$interface' is already up" @@ -206,12 +204,11 @@ start() { rf_enable "$interface" "$RFKill" || return 1 fi - local wpa_conf - if ! wpa_conf=$(wpa_make_config_file "$interface"); then + if ! WPAConfigFile=$(wpa_make_config_file "$interface"); then exit_error "Could not create the configuration file for interface '$interface'" fi - # Disable p2p to prevent wpa_supplicant from creating another control interface. - echo "p2p_disabled=1" >> "$wpa_conf" + # Disable p2p to prevent wpa_supplicant from creating another control interface + echo "p2p_disabled=1" >> "$WPAConfigFile" local profile list_profiles | while IFS= read -r profile; do @@ -222,16 +219,16 @@ start() { is_yes "${ExcludeAuto:-no}" && exit # Set default and exclude wpa-config as it does not fit this scheme [[ ${Security:=none} != "wpa-config" ]] || exit - printf '%s\n' "network={" "$(wpa_make_config_block)" "id_str=\"$profile\"" "}" >> "$wpa_conf" + printf '%s\n' "network={" "$(wpa_make_config_block)" "id_str=\"$profile\"" "}" >> "$WPAConfigFile" report_notice "Included profile '$profile'" ) done - # Start the WPA supplicant and wpa_actiond + # Start the WPA supplicant and wpa_cli : ${WPADriver:=nl80211,wext} WPAOptions+=" -W" - if wpa_start "$interface" "$WPADriver" "$wpa_conf"; then - if $ACTIOND -i "$interface" -P "$pidfile" -a "$ACTION_SCRIPT"; then + if wpa_start "$interface" "$WPADriver" "$WPAConfigFile"; then + if wpa_call "$interface" -B -a "$ACTION_SCRIPT"; then return 0 fi wpa_stop "$interface" @@ -241,17 +238,16 @@ start() { return 1 } -## Stop the WPA supplicant and wpa_actiond +## Stop the WPA supplicant, which automatically stops wpa_cli # $1: interface stop() { local interface="$1" - local pidfile="$STATE_DIR/wpa_actiond-$interface.pid" - [[ -e "$pidfile" ]] && kill "$(< "$pidfile")" - timeout_wait 1 '! wpa_is_active "$interface"' || wpa_stop "$interface" + wpa_stop "$interface" bring_interface_down "$interface" - [[ $RFKill ]] && rf_disable "$interface" "$RFKill" - return 0 + if [[ $RFKill ]]; then + rf_disable "$interface" "$RFKill" + fi } ## Remove WPA supplicant configuration files