Bug 191819 - Seeing "list index out of range"
Seeing "list index out of range"
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: firstboot (Show other bugs)
5
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Chris Lumens
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2006-05-15 18:42 EDT by Philip Prindeville
Modified: 2007-11-30 17:11 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2006-05-16 11:21:00 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Kickstart file from installer DVD (3.64 KB, text/plain)
2006-05-15 18:42 EDT, Philip Prindeville
no flags Details
Modprobe.conf file from target machine (391 bytes, text/plain)
2006-05-15 18:45 EDT, Philip Prindeville
no flags Details

  None (edit)
Description Philip Prindeville 2006-05-15 18:42:34 EDT
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 18:42:34 EDT
Created attachment 129135 [details]
Kickstart file from installer DVD
Comment 2 Philip Prindeville 2006-05-15 18:45:21 EDT
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 11:21:00 EDT
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 16:16:20 EDT
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 16:18:47 EDT
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()

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