[Bug 1798872] [NEW] _pythonSymlinkCheck fails to account for use of update-alternitives

michael 1798872 at bugs.launchpad.net
Fri Oct 19 18:12:04 UTC 2018


Public bug reported:

In order to deal with the fact that users often modify /usr/bin/python DistUpdgradeControler.py attempts to verify it is set to the correct version:
...
 fs_default_version = os.readlink('/usr/bin/python')
 except OSError as e:
                logging.error("os.readlink failed (%s)" % e)
                return False
            if not fs_default_version in (expected_default, os.path.join('/usr/bin', expected_default)):
...

This check fails to account for setups using update-alternatives. In
this case /usr/bin/python always points to another symlink ( i.e
/etc/alternatives/python). This makes the above check always fail
regardless of the python version actually running.

sys.version_info should be used instead as it makes no assumptions about
how python was invoked.

"%s.%s.%s"
%(sys.version_info[0],sys.version_info[1],sys.version_info[2])"%s.%s.%s"
%(sys.version[0],sys.version_info[1],sys.version_info[2])

Yields the version string (i.e '2.7.15') for the running python
interpreter.

** Affects: ubuntu-release-upgrader (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: dist-upgrade

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to ubuntu-release-upgrader in
Ubuntu.
https://bugs.launchpad.net/bugs/1798872

Title:
  _pythonSymlinkCheck fails to account for use of update-alternitives

Status in ubuntu-release-upgrader package in Ubuntu:
  New

Bug description:
  In order to deal with the fact that users often modify /usr/bin/python DistUpdgradeControler.py attempts to verify it is set to the correct version:
  ...
   fs_default_version = os.readlink('/usr/bin/python')
   except OSError as e:
                  logging.error("os.readlink failed (%s)" % e)
                  return False
              if not fs_default_version in (expected_default, os.path.join('/usr/bin', expected_default)):
  ...

  This check fails to account for setups using update-alternatives. In
  this case /usr/bin/python always points to another symlink ( i.e
  /etc/alternatives/python). This makes the above check always fail
  regardless of the python version actually running.

  sys.version_info should be used instead as it makes no assumptions
  about how python was invoked.

  "%s.%s.%s"
  %(sys.version_info[0],sys.version_info[1],sys.version_info[2])"%s.%s.%s"
  %(sys.version[0],sys.version_info[1],sys.version_info[2])

  Yields the version string (i.e '2.7.15') for the running python
  interpreter.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/ubuntu-release-upgrader/+bug/1798872/+subscriptions



More information about the foundations-bugs mailing list