Bug 152071 - /etc/NetworkManager/dispatcher.d/netcontrol_services regex too greedy
Summary: /etc/NetworkManager/dispatcher.d/netcontrol_services regex too greedy
Status: RESOLVED FIXED
Alias: None
Product: openSUSE 10.3
Classification: openSUSE
Component: Network (show other bugs)
Version: Final
Hardware: Other Other
: P5 - None : Normal (vote)
Target Milestone: ---
Assignee: Marius Tomaschewski
QA Contact: E-mail List
URL:
Whiteboard: OU 10.3
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-19 05:15 UTC by Jon Nelson
Modified: 2008-04-11 09:58 UTC (History)
2 users (show)

See Also:
Found By: Other
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jon Nelson 2006-02-19 05:15:18 UTC
Where it says 'eth0' it should read ${1}

Also, the sed command is slightly wrong in that if iwconfig output has anything /after/ the ESSID:"value here" text (on the same line) it will be mistakenly included in the essid. This was also problem for me.
Comment 1 JP Rosevear 2006-02-21 14:00:30 UTC
This is a sysconfig script.
Comment 2 JP Rosevear 2006-02-21 14:01:27 UTC
To clarify, the script is part of sysconfig, so it should not be assigned to gnome-maintainers.
Comment 3 Michael Gross 2006-02-21 15:03:14 UTC
Christian: Something for you?
Comment 4 Christian Zoz 2006-02-21 15:28:46 UTC
Yes. I'll check that.

Jon, would you please show me your output of iwconfig?
Comment 5 Jon Nelson 2006-02-21 16:26:36 UTC
I want to make sure that I'm not misunderstood: there are two issues here, one is that the script assumes eth0 when that is not likely to be true for most people (it should use ${1} which is the name of the wireless interface).  The other issue is the sed command is invalid for some outputs of iwconfig.  I don't have the example in front of me, unfortunately, because I reinstalled and don't have access to that machine for a while. However, the iwconfig source clearly can output more information on the same line as the ESSID output.  See lines 177-202 of iwconfig.c wherein it prints the interface name, the ESSID (if any), and the Nickname (if any).  What I would see resembles:

wifi0    ESSID:"essid value here"  Nickname:"Nickname here"

Also take note that the ESSID *can* have single quotes or even double quotes in it, but that's a third issue (and IIRC already a bug ;-)


Comment 6 Christian Zoz 2006-02-23 11:43:53 UTC
This should fix two problems:

--- scripts/netcontrol_services (Revision 1421)
+++ scripts/netcontrol_services (Arbeitskopie)
@@ -32,6 +32,6 @@
 test -r ./config && . ./config
 test -r scripts/functions && . scripts/functions

-E="`iwconfig eth0 2>/dev/null | sed -n 's/^.*ESSID:\"\(.*\)\"/\1/p'`"
+E="`iwconfig ${1} 2>/dev/null | sed -n 's/^.*ESSID:\"\(.*\)\".*$/\1/p'`"
 info_mesg "calling 'if${2}-services ${1}${E:+-$E}'"
 scripts/if${2}-services "${1}${E:+-$E}"

Joe, how can it get ESSID of an interface in an reliable way?
Comment 7 Joachim Gleissner 2006-02-23 11:58:41 UTC
I'm afraid parsing iwconfig output can not be considered as reliable. What does it is intended to detect here? The configured ESSID? Or associated ESSID?
Comment 8 Christian Zoz 2006-02-23 12:55:26 UTC
The associated ESSID.
Comment 9 Christian Zoz 2006-02-23 14:48:40 UTC
Joe told me there is currently no other easy way to get ESSID.

Fix from comment 6 will work as long as essid does not contain double quotes. And if it does you are lost. I can live with that, since YaST does not allow such crazy essids anyway. 
Comment 10 Christian Zoz 2006-02-23 14:55:00 UTC
Fixed in svn. Will go to next beta (probably beta6)
Comment 11 Jon Nelson 2007-10-05 03:54:10 UTC
Regression in openSUSE 10.3?

Same file, slightly different problem?

In any case, I just upgraded to 10.3 and now my ifservices stuff doesn't work again. :-(

The cause:

the script /etc/NetworkManager/dispatcher.d/netcontrol_services uses this:

E="`iwconfig ${1} 2>/dev/null | sed -n 's/^.*ESSID:\"\(.*\)\".*$/\1/p'`"

When it should be using this (match ESSID:" then anything until the next double-quote):

E="`iwconfig ${1} 2>/dev/null | sed -n 's/^.*ESSID:\"\([^\"]*\)\".*$/\1/p'`"


Please fix.
Otherwise, openSUSE 10.3 is looking and feeling GREAT so far (only a few hours as yet....)
Comment 12 Christian Zoz 2007-10-05 07:32:18 UTC
Oh well, parsing output is always @$*%)!$# ...

Your patch is absolutely right. And it fits better to comment 9.
Thanks a lot, Jon.

Fixed in svn:

--- scripts/netcontrol_services (Revision 1594)
+++ scripts/netcontrol_services (Arbeitskopie)
@@ -32,6 +32,6 @@
 test -r ./config && . ./config
 test -r scripts/functions && . scripts/functions

-E="`iwconfig ${1} 2>/dev/null | sed -n 's/^.*ESSID:\"\(.*\)\".*$/\1/p'`"
+E="`iwconfig ${1} 2>/dev/null | sed -n 's/^.*ESSID:\"\([^\"]*\)\".*$/\1/p'`"
 info_mesg "calling 'if${2}-services ${1}${E:+-$E}'"
 scripts/if${2}-services "${1}${E:+-$E}"
Comment 13 Jon Nelson 2007-11-14 03:39:15 UTC
Curious - can this be made into an update for 10.3?

Obviously this remains broken otherwise. :-(
Comment 14 Christian Zoz 2007-11-27 09:26:11 UTC
This will go to the next online update for 10.3
Comment 15 Jon Nelson 2008-02-09 13:32:38 UTC
When will the next online update happen for sysconfig?
Comment 16 Anja Stock 2008-04-11 09:58:55 UTC
released