# wpa_supplicant & init scripts

## Rumil

I am using wpa_supplicant to connect to my network, this are my config files:

 */etc/wpa_supplicant/wpa_supplicant.conf wrote:*   

> 
> 
> ctrl_interface=/var/run/wpa_supplicant
> 
> ctrl_interface_group=wheel
> ...

 

 */etc/conf.d/net wrote:*   

> 
> 
> config_eth0=( "null" )
> 
> modules_ath0=( "wpa_supplicant" )
> ...

 

The thing is, that when I run wpa-supplicant manually(wpa_supplicant -Dmadwifi -iath0 -c/etc/wpa_supplicant/wpa_supplicant.conf), everything works just fine, but when I want to do it the "gentoo way" by /etc/init.d/net.ath0 I get this error when running it:

 *Quote:*   

> * Service net.ath0 starting
> 
> Failed to connect to wpa_supplicant - wpa_ctrl_open: No such file or directory                                       [ !! ]
> 
>  * ERROR:  net.ath0 failed to start
> ...

 

Any suggestions?

----------

## mamac

Hi,

Did you read this?

----------

## Rumil

 *jean-marc.beaune wrote:*   

> Hi,
> 
> Did you read this?

 

Yes, I did read that and my conf files seem right to me  :Smile: 

As I have written when I run wpa_supplicant manually it connects to my network, it's just that when I want to run it at boot it produces errors as in my first post.

----------

## Rumil

Ok, so a bit more output:

```
* Starting ath0

 *   Loading networking modules for ath0

 *     modules: apipa arping ccwgroup macchanger macnet rename wpa_supplicant essidnet iptunnel iproute2 system dhcpcd ip6to4

 *       wpa_supplicant provides wireless

 *       iproute2 provides interface

 *       dhcpcd provides dhcp

 *   Configuring ath0 for MAC address 00:11:F5:86:18:6C ...               [ ok ]

 *   Starting wpa_supplicant on ath0 ...

bind(PF_UNIX): Address already in use                                     [ ok ]

 *   Starting wpa_cli on ath0 ...

Failed to connect to wpa_supplicant - wpa_ctrl_open: No such file or dir  [ !! ]

```

After running net.ath0 wpa_supplicant actually stays in the background, but ath0 interface is down so it can't scan (and connect). After I bring ath0 up, wpa_supplicant succesfully connects.

Ok, and now dirty hack that "solved" the problem for me: in /lib/rcscripts/net/wpa_supplicant.sh at line 328 when I change '-p"${ctrl_dir}" ' to '-p"/var/run/wpa_supplicant" ' it actually starts working and I don't get the error anymore. But, as I said, It's just a dirty hack.

----------

## UberLord

What version of baselayout?

What is the output of this command?

```
sed -n -e 's/[ \t]*#.*//g;s/[ \t]*$//g;s/^ctrl_interface=//p' /etc/wpa_supplicant/wpa_supplicant.conf
```

----------

## wynn

 *Quote:*   

> when I run wpa-supplicant manually(wpa_supplicant -Dmadwifi -iath0 -c/etc/wpa_supplicant/wpa_supplicant.conf), everything works just fine,

 

It seems that wpa_supplicant expects wpa_supplicant.conf to be /etc/wpa_supplicant.conf not /etc/wpa_supplicant/wpa_supplicant.conf.

----------

## UberLord

 *wynn wrote:*   

> It seems that wpa_supplicant expects wpa_supplicant.conf to be /etc/wpa_supplicant.conf not /etc/wpa_supplicant/wpa_supplicant.conf.

 

baselayout-1.11 expects /etc/wpa_supplicant.conf

baselayout-1.12 handles both

----------

## Rumil

It doesn't make any difference if wpa_supplicant.conf is in /etc or /etc/wpa_supplicant. The versions of baselayout that didn't work for me are: 1.12.1 and 1.12.2 . I didn't try any other. And here is that command output:

```
Laptop rumil # sed -n -e 's/[ \t]*#.*//g;s/[ \t]*$//g;s/^ctrl_interface=//p' /etc/wpa_supplicant.conf

/var/run/wpa_supplicant

Laptop rumil #

```

I can see that baselayout-1.12.4 is out, I'm gonna check it out right now.

EDIT:

Still the same error on 1.12.4.

Oh, one more thing, when I tried to "debug" and added "einfo ${ctrl_dir}" just before wpa_cli starts, it returns "/var/run/wpa_supplicant" (which is correct, of course).

----------

## UberLord

1.12.4 won't fix it

Whats the output of the same command, but using /etc/wpa_supplicant/wpa_supplicant.conf ?

----------

## Rumil

I guess it will be the same since it's the same file, I've just moved it at some point of trying to fix my problem  (I did it because wiki says about /etc/wpa_supplicant.conf not /etc/wpa_supplicant/wpa_supplicant.conf).

----------

## UberLord

Yeah, the file used to be there.

We changed to /etc/wpa_supplicant as the action script (wpa_cli.sh) is stored there. We also check for /etc/wpa_supplicant/wpa_supplicant-$iface.conf then /etc/wpa_supplicant/wpa_supplicant.conf then /etc/wpa_supplicant.conf.

We do this so you can have 802 authentication over a wired interface, which pretty much requires a seperate config file if you use wireless too.

----------

