# openrc problem with wpa_supplicant

## Bones McCracker

I am able to get online using wpa_supplicant just fine manually.  However, I am not able to use the openrc net.lo initscript to connect (i.e. '/etc/init.d/net.ra0 start').  I've done some diagnostics (below), but am stuck.

OpenRC has been working beautifully for me with a wired internet connection for many months, and this problem is specific to using the openrc initscripts to bring up the wireless interface using wpa_supplicant.

1. wpa_supplicant, my wireless driver, and dhcp are working fine:

For the moment, I'm using the following initscript to test wpa_supplicant and the driver, successfully connecting and disconnecting from the internet without any problems.

```
#!/sbin/runscript

depend() {

        need localmount

        use logger

        after net.lo

        provide net

}

start() {

        ebegin "Starting wireless network connection"

                start-stop-daemon --start \

                  --exec /usr/sbin/wpa_supplicant \

                  --pidfile /var/run/wpa_supplicant-ra0.pid \

                  -- -D wext -c /etc/wpa_supplicant/wpa_supplicant.conf \

                  -W -B -i ra0 -P /var/run/wpa_supplicant-ra0.pid

                # wpa action script to start/stop dhcp

                wpa_cli -i ra0 -a /etc/wpa_supplicant/wpa_action.sh -B

        eend $? "Failed to start wireless network connection"

}

stop() {

        ebegin "Stopping wireless network connection"

                start-stop-daemon --stop \

                        --pidfile /var/run/wpa_supplicant-ra0.pid \

                        --exec /usr/sbin/wpa_supplicant

        eend $? "Failed to stop wireless network connection"

}
```

As you can see in this initscript, I am using a wpa_supplicant action script, which follows:

```

#!/bin/sh

# Purpose: start and stop dhcp when wpa supplicant emits a

# CONNECTED or DISCONNECTED event.

iface="$1"

event="$2"

case ${event} in

        CONNECTED)

                action="/sbin/dhclient ${iface}"

                ;;

        DISCONNECTED)

                action="/sbin/dhclient -x ${iface}"

                ;;

        *)

                logger -t wpa_action "received bogus wpa_supplicant event: ${event}"

                exit 1

                ;;

esac

${action} || logger -t wpa_action "'${action}' failed"
```

So, since the above is working fine, this problem would not seem to be related to wpa_supplicant, dhclient, the wireless driver, or wireless extensions.

2. wpa_cli, as called from rc scripts, is failing:

```
# /etc/init.d/net.ra0 -vv start

 * Bringing up interface ra0

 *   Loaded modules: apipa arping bonding tuntap ccwgroup macchanger macnet wpa_supplicant ssidnet ifconfig system dhclient ip6to4

 *   Configuring ra0 for MAC address 00:1c:df:08:05:47 ...                [ ok ]

 *   Starting wpa_supplicant on ra0 ...

 *   Detaching to start `/usr/sbin/wpa_supplicant' ...                    [ ok ]

 *   Starting wpa_cli on ra0 ...

 *   Detaching to start `/usr/bin/wpa_cli' ...

Failed to connect to wpa_supplicant - wpa_ctrl_open: No such file or directory

 *     start-stop-daemon: failed to start `/usr/bin/wpa_cli'              [ !! ]

 * WARNING: net.ra0 not under our control, aborting
```

From the above, it seems like maybe the openrc scripts are calling the wpa action script ("/etc/wpa_supplicant/wpa_cli.sh") before the control interface (the unix socket /var/run/wpa_supplicant/ra0) is ready.  At least, that's how I interpret:

```
 *   Detaching to start `/usr/bin/wpa_cli' ...

Failed to connect to wpa_supplicant - wpa_ctrl_open: No such file or directory
```

What I don't understand is why that's happening in the openrc scripts and not my little work-around.

----------

## flash2k2

Hi!

I had the same problem.

But the solution was very easy for me.

Debugging wpa_supplicant script I've found that ctrl_interface variable in my wpa_supplicant config file was declared as:

```
ctrl_interface=/var/run/wpa_supplicant          #<comment> 
```

In wpa_supplicant init script this variable was read with this comment and after removing this comment the problem have gone.

I don't know the cause of this problem. May be it was wpa_supplicant upgrade.

I hope it will help you.

----------

