OSError: [Errno 9] Bad file descriptor

Bug #1362920 reported by Jamin W. Collins
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ubiquity (Ubuntu)
Fix Released
High
Colin Watson

Bug Description

After working around https://bugs.launchpad.net/ubuntu/+source/oem-config/+bug/1361595, oem-config still does not properly run on server based installs.

Code that had previously worked under python 2.x (used in 12.04 LTS, AFAICT) is now too aggressive under python 3.x (used in 14.04 LTS). This is resulting the the file descriptor for /dev/urandom being closed prematurely in open_terminal(), due to the following section:

        for i in range(tty):
            if i != 2:
                os.close(i)

However, as reported here: http://bugs.python.org/issue21207, once the urandom persistent fd is closed it wasn't being reopend. Given this report is from April of 2014, I'm pretty sure the version of python shipped with 14.04 LTS has the same behavior.

Sure enough, if I prevent oem-config from closing the fd for /dev/urandom, oem-config is finally able to at least run.

The following is how I've solved the problem so far.

        # need to avoid closing the FD for /dev/urandom
        # http://bugs.python.org/issue21207
        urand_inode = os.stat('/dev/urandom').st_ino
        for i in range(tty):
            if i != 2:
                inode = os.fstat(i).st_ino
                if inode != urand_inode:
                    os.close(i)

Related branches

Colin Watson (cjwatson)
affects: oem-config (Ubuntu) → ubiquity (Ubuntu)
Colin Watson (cjwatson)
Changed in ubiquity (Ubuntu):
status: New → Fix Committed
assignee: nobody → Colin Watson (cjwatson)
importance: Undecided → High
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package ubiquity - 2.19.8

---------------
ubiquity (2.19.8) utopic; urgency=medium

  [ Colin Watson ]
  * Avoid closing /dev/urandom persistent FD on oem-config startup (thanks,
    Jamin W. Collins; LP: #1362920).

  [ Chris Bainbridge ]
  * Fix Windows UEFI detection. (LP: #1265192)
 -- Stephane Graber <email address hidden> Fri, 12 Sep 2014 14:35:57 -0400

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

Other bug subscribers

Remote bug watches

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