wireless devices are not managed when installing from alternate

Bug #948217 reported by Mathieu Trudel-Lapierre
32
This bug affects 4 people
Affects Status Importance Assigned to Milestone
network-manager (Ubuntu)
Fix Released
High
Mathieu Trudel-Lapierre

Bug Description

When installing from the alternate image, wireless devices (if used as a network source for the install) are then not managed by NetworkManager.

This is because debian-installer writes /etc/network/interfaces with the settings configured from within the installer, and that file is copied onto the resulting system during the install. Unfortunately, ifblacklist_migrate.sh which is shipped by NetworkManager doesn't know enough about wireless to be able to handle such devices and ends up just ignoring them.

ifblacklist_migrate.sh needs to get a little more clever about the configurations in /etc/network/interfaces to comment them out so that NetworkManager can manage them.

ProblemType: Bug
DistroRelease: Ubuntu 12.04
Package: network-manager 0.9.2.0+git201202161854.8572ecf-0ubuntu6
ProcVersionSignature: Ubuntu 3.2.0-17.27-generic 3.2.6
Uname: Linux 3.2.0-17-generic x86_64
ApportVersion: 1.94-0ubuntu1
Architecture: amd64
Date: Tue Mar 6 09:27:44 2012
InstallationMedia: Ubuntu 12.04 LTS "Precise Pangolin" - Alpha amd64 (20120209.2)
IpRoute:
 default via 10.153.108.1 dev eth0 proto static
 10.153.108.0/24 dev eth0 proto kernel scope link src 10.153.108.115 metric 1
 10.153.108.0/24 dev wlan0 proto kernel scope link src 10.153.108.129 metric 2
 169.254.0.0/16 dev eth0 scope link metric 1000
NetworkManager.state:
 [main]
 NetworkingEnabled=true
 WirelessEnabled=true
 WWANEnabled=true
 WimaxEnabled=true
ProcEnviron:
 LANGUAGE=fr_CA:fr
 TERM=xterm
 PATH=(custom, user)
 LANG=fr_CA.UTF-8
 SHELL=/bin/zsh
SourcePackage: network-manager
UpgradeStatus: No upgrade log present (probably fresh install)
mtime.conffile..etc.NetworkManager.NetworkManager.conf: 2012-03-05T11:45:59.646530
nmcli-dev:
 DEVICE TYPE STATE DBUS-PATH
 64:A7:69:BC:E6:FE bluetooth disconnected /org/freedesktop/NetworkManager/Devices/2
 wlan0 802-11-wireless connected /org/freedesktop/NetworkManager/Devices/1
 eth0 802-3-ethernet connected /org/freedesktop/NetworkManager/Devices/0
nmcli-nm:
 RUNNING VERSION STATE NET-ENABLED WIFI-HARDWARE WIFI WWAN-HARDWARE WWAN
 running 0.9.3.0 connected enabled enabled enabled enabled disabled

Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :
Changed in network-manager (Ubuntu):
status: New → Confirmed
importance: Undecided → High
assignee: nobody → Mathieu Trudel-Lapierre (mathieu-tl)
status: Confirmed → In Progress
Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

I've tested this on a system running a few different types of configurations for network device and modifying /etc/network/interfaces manually to add a few other possible configurations; I think I got the script pretty much to where it should be now.

Revision history for this message
Steve Langasek (vorlon) wrote :

+ lines=`ifquery $i | grep -v metric | sed 's/://' | sed 's/ /[[:space:]]*/'`
+ sed -i -e "s/\(^iface.*$i.*dhcp\)/#NetworkManager#\1/" $NIF_FILE
+ for line in $lines; do
+ sed -i -e "s/^\([[:space:]]*$line\)/#NetworkManager#\1/" $NIF_FILE
+ done

This relies on two assumptions that may not hold true:

 - that the only occurrence of the line in the file is for the interface which is being disabled
 - that the contents of the line work in a sed command - i.e., they contain no special characters, including '/', '$', '*'...

I think it would be better to do a single sed command that detects the start and end of the stanza and applies the s/// to all lines in it. E.g.:

  sed -i -e"/^[[:space:]]*iface[[:space:]]\+$i[[:space:]]\+.*dhcp/,/^[[:space:]]*\(iface\|auto\|mapping\|source\|allow-\)/ { /^[[:space:]]*iface[[:space:]]\+$i[[:space:]]\+.*dhcp/ s/^/#NetworkManager#//; /^[[:space:]]*\(iface\|auto\|mapping\|source\|allow-\) ! s/^/#NetworkManager#//; }" /etc/network/interfaces

(Can probably be done more elegantly with awk than with sed)

Revision history for this message
Steve Langasek (vorlon) wrote :

> /^[[:space:]]*\(iface\|auto\|mapping\|source\|allow-\) ! s/^/#NetworkManager#//;

I mean

 /^[[:space:]]*\(iface\|auto\|mapping\|source\|allow-\)/ ! s/^/#NetworkManager#//;

of course ;)

Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

Indeed, that works with some tiny fixes:

sed -i -e"/^[[:space:]]*iface[[:space:]]\+$i[[:space:]]\+.*dhcp/,/^[[:space:]]*\(iface\|auto\|mapping\|source\|allow-\)/ { /^[[:space:]]*iface[[:space:]]\+$i[[:space:]]\+.*dhcp/ s/^/#NetworkManager#/; /^[[:space:]]*\(iface\|auto\|mapping\|source\|allow-\)/ ! s/^[^#]/#NetworkManager#/; }" /etc/network/interfaces

(just getting rid of the double #NetworkManager# comments for the iface line; and typos for the /'s.

tags: added: patch
Revision history for this message
Colin Watson (cjwatson) wrote :

Nitpick: 'grep -qc' could just be 'grep -q'. Also, please fix that regex to enforce whitespace on either side of $i, so that e.g. "eth1" doesn't match "eth10", and to match the sed regexes you're using: for example 'grep -q "^[[:space:]]*iface[[:space:]]\+$i[[:space:]].*dhcp"'.

In the sed regexes above, the \+ after the third [[:space:]] is superfluous, because it's followed by .* anyway.

Otherwise I have little to add to what Steve said. I can add another reason why the ifquery approach is problematic: you have to filter out "metric" variables that were automatically added by ifupdown, but the current ifquery interface doesn't allow you to distinguish between "metric" variables that it added itself and ones that were written explicitly in /etc/network/interfaces. The sed approach would fix that.

It seems unfortunate that this script has a .sh extension, as at this point it would really be more readable in some other language!

Changed in network-manager (Ubuntu):
status: In Progress → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package network-manager - 0.9.2.0+git201202161854.8572ecf-0ubuntu7

---------------
network-manager (0.9.2.0+git201202161854.8572ecf-0ubuntu7) precise; urgency=low

  * debian/ifblacklist_migrate.sh: simplify the script and fix the logic to
    comment out any configuration under devices that are configured
    automatically to use DHCP, since in those cases NetworkManager will pick
    things up. (LP: #948217)
 -- Mathieu Trudel-Lapierre <email address hidden> Thu, 08 Mar 2012 13:56:38 -0500

Changed in network-manager (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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