Bug 782614 - usb_modeswitch udev helper can't parse arguments and exits
Summary: usb_modeswitch udev helper can't parse arguments and exits
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: usb_modeswitch
Version: 16
Hardware: All
OS: Linux
unspecified
high
Target Milestone: ---
Assignee: romal
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-01-17 22:36 UTC by Dominic Cleal
Modified: 2012-02-15 11:31 UTC (History)
3 users (show)

Fixed In Version: usb_modeswitch-1.2.2-2.fc15
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-02-15 11:30:42 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
Proposed fix, adds usb_modeswitch.sh udev helper and Debian patch (3.19 KB, patch)
2012-01-18 23:19 UTC, Dominic Cleal
no flags Details | Diff

Description Dominic Cleal 2012-01-17 22:36:06 UTC
Description of problem:
The usb_modeswitch udev helper at /lib/udev/usb_modeswitch doesn't seem to parse the arguments from udev properly, or the expected arguments have changed in 1.2.1.  The 1.2.0 package works correctly.

This means the udev helper doesn't know anything about the device plugged in and so immediately exits without performing the mode switch on the device.  The device then doesn't show up in NetworkManager if it relies on usb_modeswitch to be loaded properly.

Version-Release number of selected component (if applicable):
usb_modeswitch-1.2.1-1.fc16

How reproducible:
Always.

Steps to Reproduce:
1. Set EnableLogging=1 in /etc/usb_modeswitch.conf
2. Plug in a modem (an Option icon 411 here)
3. Check for new /var/log/usb_modeswitch_* log files
  
Actual results:
/var/log/usb_modeswitch_noname is created with the following (note no args from udev are detected):

Raw args from udev: 
Using global config file: /etc/usb_modeswitch.conf
No data from udev. Exiting

Expected results:
/var/log/usb_modeswitch_1-1.1:1.0 (or similar) is created with huge amounts of logging, e.g...

Raw args from udev: /1-1.1:1.0
Using global config file: /etc/usb_modeswitch.conf
Bus ID for device not given by udev.
 Trying to determine it from kernel name (1-1.1:1.0) ...
----------------
USB values from sysfs:
  manufacturer  Option N.V.
  product   Globetrotter HSUPA Modem
  serial    Serial Number
----------------

Additional info:
The udev helper script seems to have changed how it parses arguments, but I can't understand much tcl to be able to work out how or why.  Unable to find an upstream SCM to find an explanation either.

Line 55 in the script from 1.2.1 contains this:
set argList [split [lindex $argv 1] /]

while in 1.2.0 it contains this:
set argList [split [lindex $argv 0] /]

Changing this back to 0 causes it to hit the --switch-mode conditional further down and it now exits with "No command given".

I can't work out if the arguments to the script are supposed to be different in 1.2.1, but if so I'd have expected a new upstream release of usb_modeswitch_data with a new udev rules file.

Comment 1 Dominic Cleal 2012-01-18 06:57:14 UTC
Reported in the upstream bug forum: http://web52.017.netroom.de/draisberghof_de/usb_modeswitch/bb/viewtopic.php?p=5621

Comment 2 Josua Dietze 2012-01-18 08:14:23 UTC
If you try with the upstream source package, probably after a forced uninstall of the Fedora package, does that fail as well?

Comment 3 Dominic Cleal 2012-01-18 22:55:49 UTC
Thanks for the tip, looking at the upstream source and installation partly explains the problem, which I think may be the packaging.

In the Fedora package, /lib/udev/usb_modeswitch is the Tcl script shipped as usb_modeswitch.tcl.  Compared to the upstream Makefile, it's actually the shell script "usb_modeswitch.sh" that should be installed at /lib/udev/usb_modeswitch and the Tcl script is installed to /usr/sbin/usb_modeswitch_dispatcher.  udev then calls the shell script, which calls the Tcl script, which then calls usb_modeswitch itself.

Does that description sound correct Josua?

I've also looked at the Debian package of 1.2.1 and it has the above layout, with the shell script in /lib/udev and the Tcl script compiled with jim at /usr/sbin/usb_modeswitch_dispatcher.  The Ubuntu package is different again, as they've rewritten the dispatcher in C!

Having moved files around for the above layout, I'm able to get further with the dispatcher log file now correctly showing arguments (which are set by the shell script).  I've now hit the issue where usb_modeswitch can't find the device:

Looking for default devices ...
 bus/device number matched
  searching devices, found USB ID 0af0:7501
   found matching vendor ID
   found matching product ID
   target class ff not matching
 No devices in default mode found. Nothing to do. Bye.

This reported in Debian with a patch: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=656248

Now having compiled upstream sources with the patch the usb_modeswitch log file shows it's made the change, the dispatcher confirms it and my modem now shows up in NetworkManager!

I'll create a patch to the spec tomorrow.

Comment 4 Josua Dietze 2012-01-18 23:10:08 UTC
Yes, the shell script is needed to keep the udev thread from blocking further processing while the mode switch is done - it can take up to 20 seconds. I don't know if there is a good reason to skip it ...

The bug in 1.2.1 will be fixed immediately, I'll release upstream 1.2.2 later today.

Comment 5 Dominic Cleal 2012-01-18 23:19:32 UTC
Created attachment 556130 [details]
Proposed fix, adds usb_modeswitch.sh udev helper and Debian patch

Comment 6 Dominic Cleal 2012-01-18 23:22:33 UTC
(In reply to comment #4)
> Yes, the shell script is needed to keep the udev thread from blocking further
> processing while the mode switch is done - it can take up to 20 seconds. I
> don't know if there is a good reason to skip it ...

Ah okay.  It looks like between 1.2.0 and 1.2.1 the arguments into the Tcl script from the shell script changed, so the absence of the shell script probably wouldn't have been noticed before.

> The bug in 1.2.1 will be fixed immediately, I'll release upstream 1.2.2 later
> today.

Great, in which case the maintainer can leave off the extra patch I added in my attachment for 1.2.1.

Comment 7 Josua Dietze 2012-01-19 13:27:08 UTC
Version 1.2.2 is available upstream. It fixes the bug reported at Debian (which would have affected all other distributions as well).

http://draisberghof.de/usb_modeswitch/usb-modeswitch-1.2.2.tar.bz2

Comment 8 Josua Dietze 2012-01-21 17:04:25 UTC
Version 1.2.2 is packaged for Fedora - but without the patch to "usb_modeswitch.spec" attached here. It will always fail if that is not fixed.

Comment 9 Huzaifa S. Sidhpurwala 2012-01-22 11:57:35 UTC
(In reply to comment #8)
> Version 1.2.2 is packaged for Fedora - but without the patch to
> "usb_modeswitch.spec" attached here. It will always fail if that is not fixed.

Right, i will respin the rpm to fix the issue

Comment 10 Fedora Update System 2012-01-25 07:43:10 UTC
usb_modeswitch-1.2.2-2.fc16 has been submitted as an update for Fedora 16.
https://admin.fedoraproject.org/updates/usb_modeswitch-1.2.2-2.fc16

Comment 11 Fedora Update System 2012-01-25 07:53:08 UTC
usb_modeswitch-1.2.2-2.fc15 has been submitted as an update for Fedora 15.
https://admin.fedoraproject.org/updates/usb_modeswitch-1.2.2-2.fc15

Comment 12 Fedora Update System 2012-01-25 22:25:39 UTC
Package usb_modeswitch-1.2.2-2.fc15:
* should fix your issue,
* was pushed to the Fedora 15 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing usb_modeswitch-1.2.2-2.fc15'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2012-0904/usb_modeswitch-1.2.2-2.fc15
then log in and leave karma (feedback).

Comment 13 Dominic Cleal 2012-01-30 09:29:35 UTC
Thanks, 1.2.2-2.fc16 seems to work perfectly (karma given).

Comment 14 Fedora Update System 2012-02-15 11:30:42 UTC
usb_modeswitch-1.2.2-2.fc16 has been pushed to the Fedora 16 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 15 Fedora Update System 2012-02-15 11:31:10 UTC
usb_modeswitch-1.2.2-2.fc15 has been pushed to the Fedora 15 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.