5 votes

Démarrage manuel de wpa_supplicant

Je peux lancer wpa_supplicant sans problème via le shell adb. Le firmware et le matériel pour ma radio WiFi sont tous chargés avant cela.

Cependant, je veux le lancer via execv() dans un programme C. Lorsque j'exécute execv(), j'obtiens l'erreur suivante :

E/wpa_supplicant( 3008): Failed to initialize control interface 'wlan0'.
E/wpa_supplicant( 3008): You may have another wpa_supplicant process already running or the file was
E/wpa_supplicant( 3008): left by an unclean termination of wpa_supplicant in which case you will need
E/wpa_supplicant( 3008): to manually remove this file before starting wpa_supplicant again.
I/wpa_supplicant( 3008): ELOOP: remaining socket: sock=15 eloop_data=0xa5320 user_data=0x0 handler=0x6acd9

J'ai également ceci dans la console série :

mkdir[ctrl_interface]: Permission denied

La sortie complète de Strace est ici : http://pastebin.com/fuQnqjXK

Voici l'extrait de sortie de strace qui nous intéresse :

2380  mkdir("wlan0", 0770)              = -1 EACCES (Permission denied)
2380  write(2, "mkdir[ctrl_interface]", 21) = 21
2380  write(2, ": ", 2)                 = 2
2380  write(2, "Permission denied", 17) = 17
2380  write(2, "\n", 1)                 = 1

Voici également l'extrait de logcat. J'ai déjà vérifié qu'aucun wpa_supplicant ne s'exécute en arrière-plan et le fichier créé lorsque wpa_supplicant est exécuté avec succès (/data/misc/wifi/wlan0/wlan0) n'existe pas. Y a-t-il d'autres fichiers que wpa_supplicant crée ?

D/wpa_supplicant( 3627): wpa_supplicant v0.8.x
D/wpa_supplicant( 3627): random: Trying to read entropy from /dev/random
D/wpa_supplicant( 3627): Initializing interface 'wlan0' conf '/data/misc/wifi/wpa_supplicant.conf' driver 'nl80211' ctr
_interface 'N/A' bridge 'N/A'
D/wpa_supplicant( 3627): Configuration file '/data/misc/wifi/wpa_supplicant.conf' -> '/data/misc/wifi/wpa_supplicant.co
f'
D/wpa_supplicant( 3627): Reading configuration file '/data/misc/wifi/wpa_supplicant.conf'
D/wpa_supplicant( 3627): update_config=1
D/wpa_supplicant( 3627): ctrl_interface='wlan0'
D/wpa_supplicant( 3627): eapol_version=1
D/wpa_supplicant( 3627): ap_scan=1
D/wpa_supplicant( 3627): fast_reauth=1
D/wpa_supplicant( 3627): config_methods='push_button keypad display'
D/wpa_supplicant( 3627): device_name='U8500'
D/wpa_supplicant( 3627): default_bgscan='learn:60:-70:300:10:20:/data/misc/wifi/wpa_supplicant_bgscan.db'
D/wpa_supplicant( 3627): wmm_enabled=1
D/wpa_supplicant( 3627): uapsd_enabled=1
D/wpa_supplicant( 3627): nl80211: interface wlan0 in phy phy0
I/wpa_supplicant( 3627): rfkill: Cannot open RFKILL control device
D/wpa_supplicant( 3627): nl80211: RFKILL status not available
D/wpa_supplicant( 3627): nl80211: Set mode ifindex 5 iftype 2 (STATION)
D/wpa_supplicant( 3627): netlink: Operstate: linkmode=1, operstate=5
D/wpa_supplicant( 3627): nl80211: Using driver-based off-channel TX
D/wpa_supplicant( 3627): nl80211: driver param='(null)'
D/wpa_supplicant( 3627): wapi_initialization()
D/wpa_supplicant( 3627): wlan0: Own MAC address: 00:80:e1:c2:89:9a
D/wpa_supplicant( 3627): Country: 00
D/wpa_supplicant( 3627): wpa_driver_nl80211_set_key: ifindex=5 alg=0 addr=0x0 key_idx=0 set_tx=0 seq_len=0 key_len=0
D/wpa_supplicant( 3627): wpa_driver_nl80211_set_key: ifindex=5 alg=0 addr=0x0 key_idx=1 set_tx=0 seq_len=0 key_len=0
D/wpa_supplicant( 3627): wpa_driver_nl80211_set_key: ifindex=5 alg=0 addr=0x0 key_idx=2 set_tx=0 seq_len=0 key_len=0
D/wpa_supplicant( 3627): wpa_driver_nl80211_set_key: ifindex=5 alg=0 addr=0x0 key_idx=3 set_tx=0 seq_len=0 key_len=0
D/wpa_supplicant( 3627): wlan0: RSN: flushing PMKID list in the driver
D/wpa_supplicant( 3627): nl80211: Flush PMKIDs
D/wpa_supplicant( 3627): wlan0: State: DISCONNECTED -> INACTIVE
I/wpa_supplicant( 3627): WPS: Converting display to virtual_display for WPS 2.0 compliance
I/wpa_supplicant( 3627): WPS: Converting push_button to virtual_push_button for WPS 2.0 compliance
D/wpa_supplicant( 3627): nl80211: Regulatory information - country=00
D/wpa_supplicant( 3627): nl80211: 2402-2472 @ 40 MHz
D/wpa_supplicant( 3627): nl80211: 2457-2482 @ 20 MHz
D/wpa_supplicant( 3627): nl80211: 2474-2494 @ 20 MHz
D/wpa_supplicant( 3627): nl80211: 5170-5250 @ 40 MHz
D/wpa_supplicant( 3627): nl80211: 5735-5835 @ 40 MHz
D/wpa_supplicant( 3627): nl80211: Added 802.11b mode based on 802.11g information
D/wpa_supplicant( 3627): WPS: Set UUID for interface wlan0
E/wpa_supplicant( 3627): WPS: UUID based on MAC address - hexdump(len=16): b2 15 b7 6a cb d7 55 cf b9 d4 3e 8c 40 ae 2d
30
D/wpa_supplicant( 3627): EAPOL: SUPP_PAE entering state DISCONNECTED
D/wpa_supplicant( 3627): EAPOL: Supplicant port status: Unauthorized
D/wpa_supplicant( 3627): EAPOL: KEY_RX entering state NO_KEY_RECEIVE
D/wpa_supplicant( 3627): EAPOL: SUPP_BE entering state INITIALIZE
D/wpa_supplicant( 3627): EAP: EAP entering state DISABLED
D/wpa_supplicant( 3627): EAPOL: Supplicant port status: Unauthorized
D/wpa_supplicant( 3627): EAPOL: Supplicant port status: Unauthorized
E/wpa_supplicant( 3627): Failed to initialize control interface 'wlan0'.
E/wpa_supplicant( 3627): You may have another wpa_supplicant process already running or the file was
E/wpa_supplicant( 3627): left by an unclean termination of wpa_supplicant in which case you will need
E/wpa_supplicant( 3627): to manually remove this file before starting wpa_supplicant again.
D/wpa_supplicant( 3627): Failed to add interface wlan0
D/wpa_supplicant( 3627): wlan0: No keys have been configured - skip key clearing
D/wpa_supplicant( 3627): wlan0: State: INACTIVE -> DISCONNECTED
D/wpa_supplicant( 3627): wpa_driver_nl80211_set_operstate: operstate 0->0 (DORMANT)
D/wpa_supplicant( 3627): netlink: Operstate: linkmode=-1, operstate=5
D/wpa_supplicant( 3627): EAPOL: External notification - portEnabled=0
D/wpa_supplicant( 3627): EAPOL: Supplicant port status: Unauthorized
D/wpa_supplicant( 3627): EAPOL: External notification - portValid=0
D/wpa_supplicant( 3627): EAPOL: Supplicant port status: Unauthorized
D/wpa_supplicant( 3627): wlan0: No keys have been configured - skip key clearing
D/wpa_supplicant( 3627): wlan0: Cancelling scan request
D/wpa_supplicant( 3627): wlan0: Cancelling authentication timeout
D/wpa_supplicant( 3627): nl80211: Set TX rates failed: ret=-22 (Invalid argument)
D/wpa_supplicant( 3627): netlink: Operstate: linkmode=0, operstate=6
D/wpa_supplicant( 3627): nl80211: Set mode ifindex 5 iftype 2 (STATION)
I/wpa_supplicant( 3627): ELOOP: remaining socket: sock=15 eloop_data=0xa5320 user_data=0x0 handler=0x6acd9

Quelqu'un peut-il me donner un indice sur ce que je pourrais faire de mal ? Les autorisations ?

3voto

phantom42 Points 569

J'ai réussi à trouver la réponse, bien que je ne comprenne pas vraiment pourquoi ni comment. Si quelqu'un peut ajouter pourquoi le répertoire de travail est important, je l'apprécierai grandement.

Dans mon programme C, je dois faire un chdir() vers /data/misc/wifi, puis faire le execvp().

if (chdir("/data/misc/wifi") == -1) {
    perror("chdir");
    return;
}

pid = fork();
if (pid == -1) {
    perror("Error forking process");
}
else if (pid != 0) {
    return;
}
execvp("/system/bin/wpa_supplicant", wpaparmlist);

où wpaparmlist est l'argumentaire de wpa_supplicant.

Merci pour votre aide ce4 !

androidalle.com

AndroidAlle est une communauté de androiders où vous pouvez résoudre vos problèmes et vos doutes. Vous pouvez consulter les questions des autres sysadmins, poser vos propres questions ou résoudre celles des autres.

Powered by:

X