DistroRelease which contains slashes used in path

Bug #1684600 reported by Benjamin Drung
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Apport
New
Undecided
Unassigned

Bug Description

The DistroRelease contains GNU/Linux on Debian (example: "Debian GNU/Linux 8"). The containing slash is very confusing when using the DistroRelease as path. Thus please just strip GNU/Linux from the DistroRelease before using it as part of a path.

Related branches

Revision history for this message
Benjamin Drung (bdrung) wrote :
Revision history for this message
Brian Murray (brian-murray) wrote :

Is there any reason not to fix this in apport/packaging.py's get_os_version() which is used to get DistroRelease?

Revision history for this message
Benjamin Drung (bdrung) wrote :

Valid point. Repairing apport/packaging.py's get_os_version() is the way to go.

Revision history for this message
Benjamin Drung (bdrung) wrote :

Code like

name = l.split('=', 1)[1]
if name.startswith('"'):
    name = name[1:-2].strip()

converts l = 'NAME="Debian GNU/Linux"' into name = 'Debian GNU/Linu' (note the missing 'x'). If this quote-stripping would have gone right, following snippet would remove GNU/Linux:

# work around inconsistent "Debian GNU/Linux" in os-release
if name.endswith('GNU/Linux'):
    name = name.split()[0:-1]

but the resulting name variable would be a list of strings then.

Proposed solution: Use shlex to simplify the code to

with open('/etc/os-release') as f:
    for l in f:
        key, value = shlex.split(l)[0].split('=', 1)
        if key == 'NAME':
            name = value[:-9].strip() if value.endswith('GNU/Linux') else value
        if key == 'VERSION_ID':
            version = value

Revision history for this message
Benjamin Drung (bdrung) wrote :

The updated patch is attached.

I also converted the appport bzr repository to git, put my patches on top and pushed it to https://code.launchpad.net/~bdrung/apport/+git/retrace-debian/+ref/master

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.