Bug 191819

Summary: Seeing "list index out of range"
Product: [Fedora] Fedora Reporter: Philip Prindeville <philipp>
Component: firstbootAssignee: Chris Lumens <clumens>
Status: CLOSED RAWHIDE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 5   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2006-05-16 15:21:00 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Kickstart file from installer DVD
none
Modprobe.conf file from target machine none

Description Philip Prindeville 2006-05-15 22:42:34 UTC
Description of problem:

While booting an FC5 DVD on a Compaq nc6000, I'm seeing:

Traceback (most recent call last):
 File "/usr/share/firstboot/firstbootWindow.py", line 468, in loadModules
   vbox, pix, title = module.launch()
 File "/usr/share/firstboot/modules/networking.py", line 94, in launch
   self.updateLabels()
 File "/usr/share/firstboot/modules/networking.py", line 122, in  updateLabels
   if string.strip(tokens[0]) == "alias" and string.strip(tokens[1][:3]) ==   "eth":
 IndexError: list index out of range

Version-Release number of selected component (if applicable):


How reproducible:

I have an FC5 disk with a modified ks.cfg file on it (attached).

Steps to Reproduce:
1. boot with this DVD
2. when the system attempts to do "firstboot", there will be a warning about the
script failing (with a list index out of range error) and asks you if you want
to debug it.
3.
  
Actual results:

Firstboot fails and drops into debug dialog popup.

Expected results:

Firstboot should silently succeed.

Additional info:

see attached files.

Comment 1 Philip Prindeville 2006-05-15 22:42:34 UTC
Created attachment 129135 [details]
Kickstart file from installer DVD

Comment 2 Philip Prindeville 2006-05-15 22:45:21 UTC
Created attachment 129136 [details]
Modprobe.conf file from target machine

I'm not sure, but I suspect it might be bombing out on the second line, which
is blank, and hence contains no first or second tokens when parsed.

Comment 3 Chris Lumens 2006-05-16 15:21:00 UTC
Yes, this is exactly what's going on.  The file reading will be more robust in
the next build.

Comment 4 Philip Prindeville 2006-05-16 20:16:20 UTC
Dumb question, but... is the fix:

--- networking.py.bak   2006-03-03 16:28:01.000000000 -0700
+++ networking.py       2006-05-16 14:20:04.000000000 -0600
@@ -119,7 +119,7 @@
         lines = open("/etc/modprobe.conf").readlines()
         for line in lines:
             tokens = string.split(line)
-            if string.strip(tokens[0]) == "alias" and
string.strip(tokens[1][:3]) == "eth":
+            if len(tokens) == 3 and string.strip(tokens[0]) == "alias" and
string.strip(tokens[1][:3]) == "eth":
                 module_dict[tokens[1]] = tokens[2]

         self.deviceStore.clear()


Comment 5 Chris Lumens 2006-05-16 20:18:47 UTC
That'll work.  This is the exact fix:

RCS file: /usr/local/CVS/firstboot/src/modules/networking.py,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- networking.py       19 Jan 2006 19:22:41 -0000      1.27
+++ networking.py       16 May 2006 15:24:51 -0000      1.28
@@ -118,9 +118,19 @@
         module_dict = {}
         lines = open("/etc/modprobe.conf").readlines()
         for line in lines:
+            #  Skip empty lines and comments.
+            if line.isspace() or (line != "" and line.lstrip()[0] == '#'):
+                continue
+
             tokens = string.split(line)
-            if string.strip(tokens[0]) == "alias" and
string.strip(tokens[1][:3]) == "eth":
-                module_dict[tokens[1]] = tokens[2]
+
+            # If the line isn't formed just like we like it, don't explode.
+            try:
+                if string.strip(tokens[0]) == "alias" and \
+                   string.strip(tokens[1][:3]) == "eth":
+                    module_dict[tokens[1]] = tokens[2]
+            except IndexError:
+                pass

         self.deviceStore.clear()