All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nicolas Cavallari <Nicolas.Cavallari@green-communications.fr>
To: Angelo Compagnucci <angelo@amarulasolutions.com>,
	buildroot@buildroot.org
Cc: jagan@amarulasolutions.com
Subject: Re: [Buildroot] [PATCH 2/4] package/wpa_supplicant: adding ifupdown support
Date: Mon, 6 Jun 2022 17:09:36 +0200	[thread overview]
Message-ID: <ce3dbd69-bb72-a8ff-2ce8-e52da3133d9a@green-communications.fr> (raw)
In-Reply-To: <20220527103335.1968203-3-angelo@amarulasolutions.com>

Hello,

On 27/05/2022 12:33, Angelo Compagnucci wrote:
> Actually, configuring a wifi interface as per "interfaces" man:
> 
> auto wlan0
> iface wlan0 inet dhcp
> wpa-conf /etc/wpa_supplicant.conf
> 
> doesn't work on buildroot because the line wpa-conf is ignored due to
> the lack of a proper ifupdown script to handle the wpa_supplicant
> initialization.
> 
> The provided file is a simplified version based on the one available
> on debian.
> 
> Signed-off-by: Angelo Compagnucci <angelo@amarulasolutions.com>
> ---
>   package/wpa_supplicant/ifupdown.sh       | 71 ++++++++++++++++++++++++
>   package/wpa_supplicant/wpa_supplicant.mk | 10 ++++
>   2 files changed, 81 insertions(+)
>   create mode 100755 package/wpa_supplicant/ifupdown.sh
> 
> diff --git a/package/wpa_supplicant/ifupdown.sh b/package/wpa_supplicant/ifupdown.sh
> new file mode 100755
> index 0000000000..8eecf73436
> --- /dev/null
> +++ b/package/wpa_supplicant/ifupdown.sh
> @@ -0,0 +1,71 @@
> +#!/bin/sh
> +
> +# This file is executed by ifupdown in pre-up, post-up, pre-down and
> +# post-down phases of network interface configuration.

It is also executed for every interface regardless of if wpa-* options are 
specified or not. ifupdown works by turning all options into IF_* environment 
variables and running all hooks with it.

Right now this hook starts wpa_supplicant on every non-lo interface.
It probably needs a if [ -z "$IF_WPA_CONF" ]; then exit 0; fi somewhere.
The earliest the better.

> +
> +WPA_SUP_BIN="/usr/sbin/wpa_supplicant"
> +
> +if [ -n "$IF_WPA_MAINT_DEBUG" ]; then
> +	set -x
> +fi

It is really necessary to support the "wpa-maint-debug yes" 
/etc/network/interfaces option ?  This script is simple enough, unlike Debian's.

> +
> +# quit if we're called for the loopback
> +if [ "$IFACE" = lo ]; then
> +	exit 0
> +fi

Special-casing lo can be removed by filtering on -z IF_WPA_CONF.  Nobody is 
going to specify a wpa-conf on the lo interface, and if they do, they should 
assume the consequences.

> +
> +# allow wpa_supplicant interface to be specified via wpa-iface
> +# useful for starting wpa_supplicant on one interface of a bridge
> +if [ -n "$IF_WPA_IFACE" ]; then
> +	WPA_IFACE="$IF_WPA_IFACE"
> +else
> +	WPA_IFACE="$IFACE"
> +fi
> +
> +WPA_SUP_PIDFILE="/run/wpa_supplicant.${WPA_IFACE}.pid"
> +
> +# quit if executables are not installed
> +if [ ! -x "$WPA_SUP_BIN" ]; then
> +	exit 0
> +fi
> +
> +do_start () {
> +	if [ -n "$IF_WPA_CONF" ] && [ "$IF_WPA_CONF" != "managed" ]; then
> +		if [ ! -s "$IF_WPA_CONF" ]; then
> +			echo "cannot read contents of $IF_WPA_CONF"
> +			exit 1
> +		fi
> +		WPA_SUP_CONF_CTRL_DIR=$(sed -n -e 's/[[:space:]]*#.*//g' -e 's/[[:space:]]\+.*$//g' \
> +			-e 's/^ctrl_interface=\(DIR=\)\?\(.*\)/\2/p' "$IF_WPA_CONF")
> +		if [ -n "$WPA_SUP_CONF_CTRL_DIR" ]; then
> +			WPA_SUP_CONF="-c $IF_WPA_CONF -C $WPA_SUP_CONF_CTRL_DI > +		else
> +			WPA_SUP_CONF="-c $IF_WPA_CONF"
> +		fi
> +	else
> +		# specify the default ctrl_interface
> +		WPA_SUP_CONF="-C $WPA_CTRL_DIR"
> +	fi
> +}

Debian's ifupdown script need wpa_supplicant to have a ctrl_interface because it 
want to use wpa_cli for all the other wpa-* options, and wpa_cli works by 
connecting to a ctrl_interface.

This script does not use wpa_cli so all the ctrl_interface handling can be 
removed, unless you want to implement the other options later.

By the way, "wpa-conf "managed" is mostly used with the other wpa-* options to 
configure the ssid/passphrase within /etc/network/interfaces, which is something 
your script does not support, so you can remove the first 'if'.
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

  parent reply	other threads:[~2022-06-06 15:14 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-27 10:33 [Buildroot] [PATCH 0/4] Better wifi handling Angelo Compagnucci
2022-05-27 10:33 ` [Buildroot] [PATCH 1/4] package/wpa_supplicant: fixing "Invalid configuration line" Angelo Compagnucci
2022-06-01 19:21   ` Thomas Petazzoni via buildroot
2022-06-01 21:55     ` Angelo Compagnucci
2022-06-06 12:42       ` Arnout Vandecappelle
2022-06-07 10:21         ` Angelo Compagnucci
2022-06-07 11:48           ` Thomas Petazzoni via buildroot
2022-06-07 12:16             ` Angelo Compagnucci
2022-06-07 13:12               ` Thomas Petazzoni via buildroot
2022-06-07 13:22                 ` Angelo Compagnucci
2022-05-27 10:33 ` [Buildroot] [PATCH 2/4] package/wpa_supplicant: adding ifupdown support Angelo Compagnucci
2022-06-01 19:25   ` Thomas Petazzoni via buildroot
2022-06-01 22:06     ` Angelo Compagnucci
2022-06-06 15:09   ` Nicolas Cavallari [this message]
2022-06-07 15:00     ` Angelo Compagnucci
2022-05-27 10:33 ` [Buildroot] [PATCH 3/4] package/busybox: make udhcp discover faster Angelo Compagnucci
2022-06-01 19:26   ` Thomas Petazzoni via buildroot
2022-05-27 10:33 ` [Buildroot] [PATCH 4/4] package/rtl8723ds: new package Angelo Compagnucci
2022-06-01 19:55   ` Thomas Petazzoni via buildroot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ce3dbd69-bb72-a8ff-2ce8-e52da3133d9a@green-communications.fr \
    --to=nicolas.cavallari@green-communications.fr \
    --cc=angelo@amarulasolutions.com \
    --cc=buildroot@buildroot.org \
    --cc=jagan@amarulasolutions.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.