jcsayre1972
Posts: 17
Joined: Sun Jun 01, 2014 4:11 pm

lost wpa_supplicant

Sun Jul 19, 2015 8:06 pm

This may be better-suited for a Linux forum, but I thought that I would start here.

I deleted my wpa_supplicant files. (And feel really stupid, for numerous reasons). The bottom line is that at this point, I can't get my Pi onto my network via the WiFi. I thought that if I did

Code: Select all

sudo apt-get remove wpa_supplicant
and then

Code: Select all

sudo apt-get install wpa_supplicant
that it would fix everything.

Alas, files are still missing. So anyway, I am looking for some guidance. I've included a lot of outputs of various configs and commands to help with troubleshooting. I KNOW that I am missing some wpa_supplicant things, and I KNOW that some symlinks are broken, but I can't figure out how to get the files back much less how to re-establish the symlinks once I have those files back. I've been googling and browsing various forums for the last two days before posting a request for help. I'm almost to the point of re-installing the OS and building from the ground up, but I am VERY hesitant to do that for other reasons. I've masked/obfuscated some of the values for security purposes. Thanks for any suggestions that you can offer.

OS Version

Code: Select all

 $ uname -a
Linux <hostname> 3.18.7+ #755 PREEMPT Thu Feb 12 17:14:31 GMT 2015 armv6l GNU/Linux
Loaded Modules

Code: Select all

cat zjcs_lsmod.log
Module                  Size  Used by
iptable_filter          1706  0
ip_tables              12393  1 iptable_filter
x_tables               18646  2 ip_tables,iptable_filter
w1_therm                3325  0
i2c_dev                 6709  8
i2c_bcm2708             6200  0
8192cu                569633  0
w1_gpio                 4502  0
wire                   31280  2 w1_gpio,w1_therm
cn                      5756  1 wire
uio_pdrv_genirq         3666  0
uio                     9897  1 uio_pdrv_genirq
USB detect

Code: Select all

cat zjcs_lsusb.log
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 7392:7811 Edimax Technology Co., Ltd EW-7811Un 802.11n Wireless Adapter [Realtek RTL8188CUS]
Interfaces configuration

Code: Select all

cat zjcs_interfaces.log
auto lo
iface lo inet loopback

iface eth0 inet static
address 999.999.999.999
netmask 255.255.255.0
network 999.999.999.999
broadcast 999.999.999.999
gateway 999.999.999.999

allow-hotplug wlan0
auto wlan0
iface wlan0 inet dhcp
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

iface default inet dhcp
ifconfig output

Code: Select all

 cat zjcs_ifconfig.log
eth0      Link encap:Ethernet  HWaddr b8:27:eb:b4:26:90
          inet addr:999.999.999.999  Bcast:999.999.999.999  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4330 errors:0 dropped:782 overruns:0 frame:0
          TX packets:1548 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:282440 (275.8 KiB)  TX bytes:210789 (205.8 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

wlan0     Link encap:Ethernet  HWaddr 74:da:38:0e:1f:b4
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
iwconfig output

Code: Select all

cat zjcs_iwconfig.log
wlan0     unassociated  Nickname:"<WIFI@REALTEK>"
          Mode:Auto  Frequency=2.412 GHz  Access Point: Not-Associated
          Sensitivity:0/0
          Retry:off   RTS thr:off   Fragment thr:off
          Power Management:off
          Link Quality:0  Signal level:0  Noise level:0
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0
wpa_supplicant directory contents

Code: Select all

cd /etc/wpa_supplicant/ && ls -lt
total 8
-rw-r--r-- 1 root root 267 Jul 19 15:37 wpa_supplicant.conf
-rw-r--r-- 1 root root  51 Jul 18 18:45 example.conf
wpa_supplicant.conf

Code: Select all

network={
        ssid="<ssid>"
        #psk="pwd"
        psk=<maskedpwd>
        proto=RSN
        key_mgmt=WPA-PSK
        pairwise=CCMP TKIP
        group=CCMP TKIP
        ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
}

MrEngman
Posts: 4036
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

Re: lost wpa_supplicant

Sun Jul 19, 2015 8:21 pm

Add the following to the beginning of wpa_supplicant.conf

Code: Select all

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

before the network section.

Also in /etc/network/interfaces you need to use

Code: Select all

iface wlan0 inet manual
not

Code: Select all

iface wlan0 inet dhcp
if you use

Code: Select all

wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

MrEngman
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

jcsayre1972
Posts: 17
Joined: Sun Jun 01, 2014 4:11 pm

Re: lost wpa_supplicant

Mon Jul 20, 2015 1:29 pm

Thanks Mr. Engman.

I am further along. I have determined that I am missing three files from wpasupplicant.

ifupdown.sh
action_wpa.sh
functions.sh

are all missing from the ../wpa_supplicant/ directory. All symlinks to these files are (obviously) broken. Uninstalling wpa_supplicant (sudo apt-get remove wpasupplicant) and reinstalling (sudo apt-get install wpasupplicant) has not replaced/recovered the files or fixed the symlinks.

I am now trying to locate the original .sh files for the above named missing scripts/files. As always, recommendations are greatly appreciated.

jcsayre1972
Posts: 17
Joined: Sun Jun 01, 2014 4:11 pm

Re: lost wpa_supplicant

Mon Jul 20, 2015 3:11 pm

Well, I am a little further.

From the raspberrypi.org home page I followed the installation documentation for NOOBS to get to:
https://www.raspberrypi.org/documentati ... n/noobs.md

From there, I went to the raspbian homepage link (http://rasbian.org)

From the Raspbian home-page, I found the archives that held wpasupplicant here: http://archive.raspbian.org/raspbian/po ... upplicant/

I downloaded that file, and grabbed the shell scripts. My symlinks are no longer broken (after rebooting), but I am still not getting the WiFi to connect. I've read some things about challenges with eth0 and wlan0 being active simultaneously. Unplugging the LAN cable did not get an IP address for the WiFi, but at least I am a little further along.

MrEngman
Posts: 4036
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

Re: lost wpa_supplicant

Mon Jul 20, 2015 3:59 pm

jcsayre1972 wrote:Well, I am a little further.

From the raspberrypi.org home page I followed the installation documentation for NOOBS to get to:
https://www.raspberrypi.org/documentati ... n/noobs.md

From there, I went to the raspbian homepage link (http://rasbian.org)

From the Raspbian home-page, I found the archives that held wpasupplicant here: http://archive.raspbian.org/raspbian/po ... upplicant/

I downloaded that file, and grabbed the shell scripts. My symlinks are no longer broken (after rebooting), but I am still not getting the WiFi to connect. I've read some things about challenges with eth0 and wlan0 being active simultaneously. Unplugging the LAN cable did not get an IP address for the WiFi, but at least I am a little further along.
Seems some people have problems with getting the wifi IP when eth0 is connected. Not sure why because all my Pi's run OK with both eth0 and wlan0 connected both being allocated their own IP's. Could be due the router they are connected to and the way it works, I don't know.

I usually only use /etc/network/interfaces to configure my wifi but I have used /etc/wpa_supplicant/wpa_supplicant.conf occasionally. With the latest release of raspbian the network set up has changed and now it is generally expected that people should set up there wif using the X GUI and the wifi set up included and I've tried that and again had no problems.

If it's any help my wifi set up works using /etc/network/interfaces set as

Code: Select all

auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
and /etc/wpa_supplicant/wpa_supplicant.conf set up as

Code: Select all

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
        ssid="network-name"
        psk="network-password"
}
If I only use /etc/network/interfaces to configure my wifi connection which is my preferred way I use

Code: Select all

auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-ssid "network-name"
wpa-psk "network-password"

MrEngman
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

jcsayre1972
Posts: 17
Joined: Sun Jun 01, 2014 4:11 pm

Re: lost wpa_supplicant

Mon Jul 20, 2015 6:17 pm

As always, thanks again.

I am now able to consistently connect both eth0 and wlan0. eth0 is connecting each and every time on restart. wlan0 fails to start (much less connect) each and every time on restart. ifconfig shows wlan in an up state, but without an IP address. executing sudo dhclient wlan0 fails. If I first execute sudo wpa_supplicant -iwlan0 -c/etc/wpa_supplicant/wpa_supplicant.conf -B and then execute sudo dhclient wlan0, I am able to run both and get the desired IP addresses (my home router is assigning based on MAC address). Before my little catastrophe, I did not have to execute either sudo command - it just connected. This leads me to believe that I am missing a startup script somewhere or the privileges/ownership are messed up, since wpa_supplicant is not starting on its own, and when started, I am good.

I have completely removed wicd, as I tried that and it didn't work and I thought that it might be interfering.

Prior to starting wpa_supplicant, I have this:

Code: Select all

<maskedusername>@<maskedhost> ~ $ ifconfig
eth0      Link encap:Ethernet  HWaddr ff:ff:ff:ff:ff:ff
          inet addr:999.999.999.999  Bcast:999.999.999.999  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:273 errors:0 dropped:43 overruns:0 frame:0
          TX packets:170 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:17789 (17.3 KiB)  TX bytes:24679 (24.1 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

wlan0     Link encap:Ethernet  HWaddr ff:ff:ff:ff:ff:ff
          inet addr:999.999.999.999  Bcast:999.999.999.999  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:35 errors:0 dropped:12 overruns:0 frame:0
          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:4137 (4.0 KiB)  TX bytes:728 (728.0 B)

<maskedusername@maskedhost> ~ $ sudo ifdown wlan0
run-parts: failed to exec /etc/network/if-down.d/wpasupplicant: No such file or directory
run-parts: /etc/network/if-down.d/wpasupplicant exited with return code 1
run-parts: failed to exec /etc/network/if-post-down.d/wpasupplicant: No such file or directory
run-parts: /etc/network/if-post-down.d/wpasupplicant exited with return code 1
I know that the files/directories that are allegedly missing are actually there:

Code: Select all

<maskedusername@maskedhost> /run/network $ file /etc/network/if-down.d/wpasupplicant
/etc/network/if-down.d/wpasupplicant: symbolic link to `../../wpa_supplicant/ifupdown.sh'
<maskedusername@maskedhost> /run/network $ ls -l /etc/network/if-down.d/wpasupplicant
lrwxrwxrwx 1 root root 32 Apr 24 12:44 /etc/network/if-down.d/wpasupplicant -> ../../wpa_supplicant/ifupdown.sh
<maskedusername@maskedhost> /run/network $ ls -l /etc/wpa_supplicant/ifupdown.sh
-rwxr-xr-x 1 root root 4868 Jul 20 10:52 /etc/wpa_supplicant/ifupdown.sh
Perhaps the fact that the symlink is older than the file itself? (Remember, I just recovered the shell scripts today)?

Once I start the wpa_supplicant (wpa_supplicant -iwlan0 -c/etc/wpa_supplicant/wpa_supplicant.conf -B) and then execute "sudo ifdown wlan0" I get the following (masked for security purposes):

Code: Select all

<maskeduser>@<maskedhost>/run/network $ ifconfig wlan0
wlan0     Link encap:Ethernet  HWaddr ff:ff:ff:ff:ff:ff
          inet addr:999.999.999.999  Bcast:999.999.999.999  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1544 errors:0 dropped:19 overruns:0 frame:0
          TX packets:35 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:205162 (200.3 KiB)  TX bytes:2898 (2.8 KiB)

<maskeduser>@<maskedhost> /run/network $ sudo ifdown wlan0
ifdown: interface wlan0 not configured
Once I execute sudo dhclient wlan0, everything is all good.

MrEngman
Posts: 4036
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

Re: lost wpa_supplicant

Mon Jul 20, 2015 7:10 pm

Don't know if it will be any help

Code: Select all

pi@Pi-2B-b ~ $ ls -l /etc/wpa_supplicant
total 44
-rwxr-xr-x 1 root root   945 Oct 16  2014 action_wpa.sh
-rwxr-xr-x 1 root root 25907 Oct 16  2014 functions.sh
-rwxr-xr-x 1 root root  4696 Oct 16  2014 ifupdown.sh
-rw------- 1 root root   140 Jun 28 18:43 wpa_supplicant.conf

MrEngman
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

jcsayre1972
Posts: 17
Joined: Sun Jun 01, 2014 4:11 pm

Re: lost wpa_supplicant

Mon Jul 20, 2015 8:16 pm

I'm a little bit further now.

the three files in question (ifupdown.sh, functions.sh and wpa_action.sh) were all described by 'file' as: "POSIX shell script, ASCII text executable, with CRLF line terminators". A little research yielded this site: https://forums.freebsd.org/threads/scri ... und.47259/ which suggested:

Code: Select all

tr -d '\r' <testscript.sh.crlf >testscript.sh
Once I did that, then I quit receiving the following errors:

Code: Select all

run-parts: failed to exec /etc/network/if-down.d/wpasupplicant: No such file or directory
run-parts: /etc/network/if-down.d/wpasupplicant exited with return code 1
Which is good. Now if I can figure out why wpa_supplicant isn't automagically starting...

MrEngman
Posts: 4036
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

Re: lost wpa_supplicant

Mon Jul 20, 2015 9:04 pm

jcsayre1972 wrote:I'm a little bit further now.

the three files in question (ifupdown.sh, functions.sh and wpa_action.sh) were all described by 'file' as: "POSIX shell script, ASCII text executable, with CRLF line terminators". A little research yielded this site: https://forums.freebsd.org/threads/scri ... und.47259/ which suggested:

Code: Select all

tr -d '\r' <testscript.sh.crlf >testscript.sh
Once I did that, then I quit receiving the following errors:

Code: Select all

run-parts: failed to exec /etc/network/if-down.d/wpasupplicant: No such file or directory
run-parts: /etc/network/if-down.d/wpasupplicant exited with return code 1
Which is good. Now if I can figure out why wpa_supplicant isn't automagically starting...
My /etc/network/if-down.d shows

Code: Select all

pi@Pi-2B-b ~ $ ls -l /etc/network/if-down.d
total 4
-rwxr-xr-x 1 root root 332 Mar 14  2013 upstart
lrwxrwxrwx 1 root root  32 Apr 24 17:44 wpasupplicant -> ../../wpa_supplicant/ifupdown.sh
pi@Pi-2B-b ~ $

MrEngman
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

MrEngman
Posts: 4036
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

Re: lost wpa_supplicant

Mon Jul 20, 2015 9:09 pm

Thinking about it might it not be easier if you re-write your SD card with a new image?


MrEngman
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

MrEngman
Posts: 4036
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

Re: lost wpa_supplicant

Mon Jul 20, 2015 9:43 pm

Just tried an experiment on one of my Pi's as I was curious as to what might happen.

I ran command

Code: Select all

sudo apt-get purge wpasupplicant
and it uninstalled wpasupplicant and wpagui. I rebooted the Pi and of course the wifi failed to start although wlan0 appeared in ifconfig. I received a warning "dpkg: warning: while removing wpasupplicant, directory '/etc/wpa_supplicant' not empty so not removed". Checking the directory and it contained the file wpa_supplicant.conf. All other files had been deleted.

I then ran command

Code: Select all

sudo apt-get install wpasupplicant
and it installed wpasupplicant but also suggested installing packages wpagui and libengine-pkcs11-openssl. So I then ran command

Code: Select all

sudo apt-get install wpagui libengine-pkcs11-openssl
and it install the extra suggested packages but also automatically installed one extra package libp11-2.

I then rebooted the Pi and lo and behold the Pi booted with the wifi up and running and appears to be back to normal.

FYI just incase it may help here is the output from the commands I used above

Code: Select all

pi@Pi-2B-b ~ $ sudo apt-get purge wpasupplicant
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
  wpagui* wpasupplicant*
0 upgraded, 0 newly installed, 2 to remove and 4 not upgraded.
After this operation, 1,750 kB disk space will be freed.
Do you want to continue [Y/n]? y
(Reading database ... 77343 files and directories currently installed.)
Removing wpagui ...
Purging configuration files for wpagui ...
Removing wpasupplicant ...
Purging configuration files for wpasupplicant ...
dpkg: warning: while removing wpasupplicant, directory '/etc/wpa_supplicant' not empty so not removed
Processing triggers for menu ...
Processing triggers for man-db ...
Processing triggers for hicolor-icon-theme ...
Processing triggers for desktop-file-utils ...
and what was left

Code: Select all

pi@Pi-2B-b ~ $ ls -al /etc/wpa_supplicant
total 12
drwxr-xr-x   2 root root 4096 Jul 20 22:10 .
drwxr-xr-x 103 root root 4096 Jul 20 22:12 ..
-rw-------   1 root root  140 Jun 28 18:43 wpa_supplicant.conf
And the install files to re-install wpasupplicant etc.

Code: Select all

pi@Pi-2B-b ~ $ sudo apt-get install wpasupplicant
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
  libqt4-svg
Use 'apt-get autoremove' to remove it.
Suggested packages:
  wpagui libengine-pkcs11-openssl
The following NEW packages will be installed:
  wpasupplicant
0 upgraded, 1 newly installed, 0 to remove and 4 not upgraded.
Need to get 0 B/541 kB of archives.
After this operation, 1,053 kB of additional disk space will be used.
Selecting previously unselected package wpasupplicant.
(Reading database ... 77283 files and directories currently installed.)
Unpacking wpasupplicant (from .../wpasupplicant_1.0-3+deb7u2_armhf.deb) ...
Processing triggers for man-db ...
Setting up wpasupplicant (1.0-3+deb7u2) ...
pi@Pi-2B-b ~ $ sudo apt-get install wpagui libengine-pkcs11-openssl
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  libp11-2
The following NEW packages will be installed:
  libengine-pkcs11-openssl libp11-2 wpagui
0 upgraded, 3 newly installed, 0 to remove and 4 not upgraded.
Need to get 43.6 kB/404 kB of archives.
After this operation, 882 kB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libp11-2 armhf 0.2.8-2 [16.1 kB]
Get:2 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libengine-pkcs11-openssl armhf 0.1.8-2 [27.4 kB]
Fetched 43.6 kB in 0s (56.3 kB/s)
Selecting previously unselected package libp11-2:armhf.
(Reading database ... 77331 files and directories currently installed.)
Unpacking libp11-2:armhf (from .../libp11-2_0.2.8-2_armhf.deb) ...
Selecting previously unselected package libengine-pkcs11-openssl.
Unpacking libengine-pkcs11-openssl (from .../libengine-pkcs11-openssl_0.1.8-2_armhf.deb) ...
Selecting previously unselected package wpagui.
Unpacking wpagui (from .../wpagui_1.0-3+deb7u2_armhf.deb) ...
Processing triggers for desktop-file-utils ...
Processing triggers for hicolor-icon-theme ...
Processing triggers for man-db ...
Processing triggers for menu ...
Setting up libp11-2:armhf (0.2.8-2) ...
Setting up libengine-pkcs11-openssl (0.1.8-2) ...
Setting up wpagui (1.0-3+deb7u2) ...
Processing triggers for menu ...

MrEngman
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

jcsayre1972
Posts: 17
Joined: Sun Jun 01, 2014 4:11 pm

Re: lost wpa_supplicant

Fri Jul 24, 2015 10:00 pm

I gave up. I downloaded a new copy of Raspbian and started over. It was actually less time-consuming. The only things remaining to get it back to previous state are user name (not an issue) and getting 1-Wire working again. I remember it being very persnickity after the dtree upgrade. I'll get it though. Not sure how to close off a topic, but I'm done on this one. Thanks all.

Return to “Beginners”