Open zerfani opened 4 years ago
Hi, I'm getting Error: Failed to add/activate new connection: Not authorized to control networking. when testing your sample code.
Here is my php file:
<?php error_reporting(E_ALL); ini_set('display_errors', 1); include __DIR__ . '/phpwifi/vendor/autoload.php'; use Sanchescom\WiFi\WiFi; class Example { public $device; /** * @throws Exception */ public function getAllNetworks() { $networks = WiFi::scan()->getAll(); foreach ($networks as $network) { echo $network . "<br>"; } } /** * @param $ssid * @param $password */ public function connect($ssid, $password) { try { WiFi::scan()->getBySsid($ssid)->connect($password, $this->device); } catch (Exception $exception) { echo $exception->getMessage(); } } /** * @throws Exception */ public function disconnect() { $networks = WiFi::scan()->getConnected(); foreach ($networks as $network) { $network->disconnect($this->device); } } } $example = new Example(); try { $example->device = 'wlan0'; $example->getAllNetworks(); $example->connect('MY-SSID-NAME', 'MY-SSID-PASSWORD'); // $example->disconnect(); } catch (Exception $e) { // } ?>
Here is the output of the when running the php file:
F4:09:D8:AA:BD:7F|MY-SSID-1|358|79|WPA2|(none) pair_ccmp group_ccmp psk|2412|true E4:CA:12:DB:0D:94|MY-SSID-2|268|34|WPA1 WPA2|pair_tkip pair_ccmp group_tkip psk pair_tkip pair_ccmp group_tkip psk|2462|false Command "LANG=C nmcli -w 10 device wifi connect "MY-SSID-2" password "MY-SSID-PASSWORD" ifname "wlan0" 2>&1" exited with code 4: Error: Failed to add/activate new connection: Not authorized to control networking.
Any idea what went wrong? Running the wifi list and the connect command via console went well, no error.
Additional INFO
$ uname -a Linux myserver 5.4.45-sunxi #20.05.3 SMP Wed Jun 10 12:09:20 CEST 2020 armv7l GNU/Linux
Hi, I think this issue is related to access rights. Try to give access rights to network manager.
Hi, I'm getting Error: Failed to add/activate new connection: Not authorized to control networking. when testing your sample code.
Here is my php file:
Here is the output of the when running the php file:
Any idea what went wrong? Running the wifi list and the connect command via console went well, no error.
Additional INFO