Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wpa_cli always return "command timed out" #126

Closed
ami4TECH opened this issue Oct 25, 2017 · 9 comments

Comments

@ami4TECH
Copy link

commented Oct 25, 2017

Hi..

In the "Configure Client" page all functions using wpa_cli are returning "command timed out".
see output of the var_dump below

exec( 'sudo wpa_cli scan', $MyRest );
sleep(3);
exec( 'sudo wpa_cli scan_results',$scan_return );
echo "
===========
";
var_dump($MyRest);
echo "
===========
";
var_dump($scan_return);
echo "
===========
";

output

===========
array(2) { [0]=> string(34) "Selected interface 'p2p-dev-wlan0'" [1]=> string(25) "'SCAN' command timed out." }

array(2) { [0]=> string(34) "Selected interface 'p2p-dev-wlan0'" [1]=> string(33) "'SCAN_RESULTS' command timed out." }


The commands working fine from terminal.
RPi3
PHP Version 7.0.19-1
Apache 2.0

rpi3-wpa_cli-error02

@billz

This comment has been minimized.

Copy link
Owner

commented Oct 25, 2017

Did you add the www-data user to the sudoers file?

@ami4TECH

This comment has been minimized.

Copy link
Author

commented Oct 25, 2017

Yes, I did.
BTW, I had to add the line below as well, it was required for the dashboard
www-data ALL=(ALL) NOPASSWD:/sbin/ip

Thank you,

@billz

This comment has been minimized.

Copy link
Owner

commented Oct 25, 2017

Did you also include the following?

www-data ALL=(ALL) NOPASSWD:/sbin/wpa_cli scan_results
www-data ALL=(ALL) NOPASSWD:/sbin/wpa_cli scan
www-data ALL=(ALL) NOPASSWD:/sbin/wpa_cli reconfigure

In most cases timeouts like these occur when permissions aren't set correctly. Since you're using Apache, rather than Lighttpd with the installer, I assume you followed the manual configuration steps?

@ami4TECH

This comment has been minimized.

Copy link
Author

commented Oct 26, 2017

Yes, I flowed the manual configuration steps
below is all that i have included in the sudoers

www-data ALL=(ALL) NOPASSWD:/sbin/ifdown wlan0
www-data ALL=(ALL) NOPASSWD:/sbin/ifup wlan0
www-data ALL=(ALL) NOPASSWD:/bin/cat /etc/wpa_supplicant/wpa_supplicant.conf
www-data ALL=(ALL) NOPASSWD:/bin/cp /tmp/wifidata /etc/wpa_supplicant/wpa_supplicant.conf
www-data ALL=(ALL) NOPASSWD:/sbin/wpa_cli scan_results
www-data ALL=(ALL) NOPASSWD:/sbin/wpa_cli scan
www-data ALL=(ALL) NOPASSWD:/sbin/wpa_cli reconfigure
www-data ALL=(ALL) NOPASSWD:/bin/cp /tmp/hostapddata /etc/hostapd/hostapd.conf
www-data ALL=(ALL) NOPASSWD:/etc/init.d/hostapd start
www-data ALL=(ALL) NOPASSWD:/etc/init.d/hostapd stop
www-data ALL=(ALL) NOPASSWD:/etc/init.d/dnsmasq start
www-data ALL=(ALL) NOPASSWD:/etc/init.d/dnsmasq stop
www-data ALL=(ALL) NOPASSWD:/bin/cp /tmp/dhcpddata /etc/dnsmasq.conf
www-data ALL=(ALL) NOPASSWD:/sbin/shutdown -h now
www-data ALL=(ALL) NOPASSWD:/sbin/reboot
www-data ALL=(ALL) NOPASSWD:/sbin/ip

@SirLagz

This comment has been minimized.

Copy link
Collaborator

commented Oct 26, 2017

You're missing some lines, that's why you had to add the /sbin/ip. I forgot to update the manual install instructions when I updated the install script. whoops!

Not sure why wpa_cli is timing out though. If you have the newest version, try it with the webconsole and see if the same thing happens.

@ami4TECH

This comment has been minimized.

Copy link
Author

commented Oct 26, 2017

Same thing using webconsole

sudo wp a_cli scan

Selected interface 'p2p-dev-w
lan0'
'SCAN' command timed out.

Thanks

@ami4TECH

This comment has been minimized.

Copy link
Author

commented Oct 29, 2017

The issue seems to be related to fastcgi-php.
I could not enable fastcgi in Apache.
I'm using lighttpd now and "Configure Client" is working fine.

I have added/update couple of lines in dashboard.php and I'll list the changes below in case it be of any use.
My SSID contains "-" in the name and dashboard was reporting "Not connected" in the network name, to fix this line 38 changed to
_preg_match( '/ESSID:"([a-zA-Z-9\s]+)"/i',$strWlan0,$result ) || $result[1] = 'Not connected';_*

Stop and start wlan0 button was not refreshing the page after it finished and was not reporting the current stats of the interface
The line
exec( 'sudo ip link set wlan0 down',$return );
Changed to
_exec( 'sudo ip link set wlan0 down',$return );
sleep(3);
header('Location: '.$SERVER['REQUEST_URI']);

And lines
exec( 'sudo ip link set wlan0 up',$return );
exec( 'sudo ip -s a f label wlan0',$return);

Changed to
_exec( 'sudo ip link set wlan0 up',$return );
exec( 'sudo ip -s a f label wlan0',$return);
sleep(3);
header('Location: '.$SERVER['REQUEST_URI']);

Sorry, i did not use github before and I'm not familiar with reporting code updates best practice.

Thank you for the great work

@SirLagz

This comment has been minimized.

Copy link
Collaborator

commented Oct 29, 2017

@ami4TECH Thanks for these.
If you want to make the updates yourself, you can fork our main branch to your own, make the changes, commit and push your changes to your own branch, then create a pull request.

Otherwise we can merge it in when time permits.

@billz

This comment has been minimized.

Copy link
Owner

commented Apr 13, 2019

Marking as resolved.

@billz billz closed this Apr 13, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.