create_connection fails to create a valid connection

Bug #923836 reported by Daniel Manrique
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Checkbox
Fix Released
Medium
Unassigned

Bug Description

Tested on a Precise system, installed from alternate image dated 20120127.2, checkbox versions:

ii checkbox 0.13.1~ppa8.12.04 System testing application
ii checkbox-certification 0.13.1~ppa8.12.04 Checkbox Certification Tests
ii checkbox-certification 0.13.1~ppa8.12.04 Client Certification
ii checkbox-gtk 0.13.1~ppa8.12.04 GTK interface for checkbox

Steps to reproduce:

1- sudo -i
2- export $WPA_BG_SSID="some-valid-ssid"
3- export $WPA_BG_PSK="some-valid-passphrase"
4- /usr/share/checkbox/scripts/create_connection $WPA_BG_SSID --security=wpa --key=$WPA_BG_PSK
5- Confirm that a connection file was created in /etc/NetworkManager/system-connections
6- nmcli con list

Expected result:
- The connection I created should be on the list

Actual result:
It's not :(

NAME UUID TYPE TIMESTAMP-REAL
Wired connection 1 f7809f45-608a-4456-bbf0-e11989cf1b79 802-3-ethernet Fri 27 Jan 2012 09:33:44 PM EST

Note that the same procedure, run on an 11.10 system, works just fine and nmcli con list shows the created connection. I can even actually enable it with nmcli con up id !

My guess is that Precise requires some additional data in the created connection file, without which it doesn't even consider it as valid. So maybe comparing a networkmanager-created conn file with what we're producing can shed some light on this.

Related branches

Revision history for this message
Daniel Manrique (roadmr) wrote :

OK, I figured out the problem here.

This is the 802-11-wireless section for the NM-generated connection file:

[802-11-wireless]
ssid=ubuntu-cert-n-wpa
mode=infrastructure
mac-address=00:26:B6:DC:46:73
security=802-11-wireless-security

This is the same section for the connection file generated by create_connection:

[802-11-wireless]
ssid=ubuntu-cert-bg-wpa
mode=infrastructure
mac-address=

security=802-11-wireless-security

The extra blank line leads me to believe our script is inserting a \n (which is apparently part of an empty string) as the MAC address. Now, NetworkManager on Precise seems to dislike the empty mac-address attribute, and so the connection gets ignored. If I remove the mac-address line altogether, the connection becomes visible in nmcli con list and can be enabled with nmcli con up.

So we'd need to either fill in the mac address (if it can be obtained somehow), or skip that line altogether. Bottom line, Network Manager in Precise doesn't like empty attributes :)

Setting as Triaged with importance: Medium.

Changed in checkbox:
importance: Undecided → Medium
status: New → Triaged
Revision history for this message
Daniel Manrique (roadmr) wrote :

OK, so it looks like create-connection was doing the right thing by trying to fetch the HWADDR field using this command:

nmcli -f GENERAL dev list | grep 802-11-wireless -A 2 | awk '/HWADDR/ {print $2}'

on Oneiric (sans the awk bit) it responds:

GENERAL.TYPE: 802-11-wireless
GENERAL.DRIVER: brcmsmac
GENERAL.HWADDR: 00:1B:B1:4C:90:F4

Note the HWADDR field.

However, on Precise it says:

GENERAL.TYPE: 802-11-wireless
GENERAL.VENDOR: Atheros Communications Inc.
GENERAL.PRODUCT: AR928X Wireless Network Adapter (PCI-Express)

Thus no HWADDR and the invalid field is generated :( It looks like the HWADDR line is a bit further down in the output. So ways to fix this:

1- change -A 2 to -A 4. This feels a bit brittle and if the ordering of fields changes again, we will experience the same problem.

2- Specify a device for which to obtain data, thus eliminating the possibility of multiple HWADDR fields (which I guess is why -A is being used to control the grep context). However this requires knowing the interface name. Something like this works :

nmcli -f GENERAL dev list iface wlan0 | awk '/HWADDR/ {print $2}'

However one simple fix suggested by cyphermox is that the mac-address field can be blank and things appear to work well. So I'll propose a "failsafe" where, if the MAC address is blank, that line won't get output to the config file.

Changed in checkbox:
status: Triaged → Fix Committed
Marc Tardif (cr3)
Changed in checkbox:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.