Bug#951651: lsb_release does not check for existence of "apt-cache"
Daniel Bryant
daniel.bryant at linux.com
Wed Feb 19 15:55:03 GMT 2020
Package: lsb-release
Version: 11.1.0
There is a bug with lsb_release in that it does not check for the existence
of apt-cache before it tries to execute it. If apt-cache is not present on
the system this will result in the following error:
[ 111s] Traceback (most recent call last):
[ 111s] File "/usr/bin/lsb_release", line 95, in <module>
[ 111s] main()
[ 111s] File "/usr/bin/lsb_release", line 59, in main
[ 111s] distinfo = lsb_release.get_distro_information()
[ 111s] File "/usr/lib/python3/dist-packages/lsb_release.py", line 356,
in get_distro_information
[ 111s] distinfo = guess_debian_release()
[ 111s] File "/usr/lib/python3/dist-packages/lsb_release.py", line 290,
in guess_debian_release
[ 111s] rinfo = guess_release_from_apt()
[ 111s] File "/usr/lib/python3/dist-packages/lsb_release.py", line 195,
in guess_release_from_apt
[ 111s] releases = parse_apt_policy()
[ 111s] File "/usr/lib/python3/dist-packages/lsb_release.py", line 178,
in parse_apt_policy
[ 111s] close_fds=True).communicate()[0].decode('utf-8')
[ 111s] File "/usr/lib/python3.7/subprocess.py", line 800, in __init__
[ 111s] restore_signals, start_new_session)
[ 111s] File "/usr/lib/python3.7/subprocess.py", line 1551, in
_execute_child
[ 111s] raise child_exception_type(errno_num, err_msg, err_filename)
[ 111s] FileNotFoundError: [Errno 2] No such file or directory:
'apt-cache': 'apt-cache'
[ 112s] Traceback (most recent call last):
[ 112s] File "/usr/bin/lsb_release", line 95, in <module>
[ 112s] main()
[ 112s] File "/usr/bin/lsb_release", line 59, in main
[ 112s] distinfo = lsb_release.get_distro_information()
[ 112s] File "/usr/lib/python3/dist-packages/lsb_release.py", line 356,
in get_distro_information
[ 112s] distinfo = guess_debian_release()
[ 112s] File "/usr/lib/python3/dist-packages/lsb_release.py", line 290,
in guess_debian_release
[ 112s] rinfo = guess_release_from_apt()
[ 112s] File "/usr/lib/python3/dist-packages/lsb_release.py", line 195,
in guess_release_from_apt
[ 112s] releases = parse_apt_policy()
[ 112s] File "/usr/lib/python3/dist-packages/lsb_release.py", line 178,
in parse_apt_policy
[ 112s] close_fds=True).communicate()[0].decode('utf-8')
[ 112s] File "/usr/lib/python3.7/subprocess.py", line 800, in __init__
[ 112s] restore_signals, start_new_session)
[ 112s] File "/usr/lib/python3.7/subprocess.py", line 1551, in
_execute_child
[ 112s] raise child_exception_type(errno_num, err_msg, err_filename)
[ 112s] FileNotFoundError: [Errno 2] No such file or directory:
'apt-cache': 'apt-cache'
The line that attempts to run apt-cache is this one:
https://salsa.debian.org/debian/lsb/blob/debian/master/lsb_release.py#L174
I would suggest a check is added to see if apt-cache exists on the system,
and if not that check is bypassed. Possibly a check such as: if shutil.which
("apt-cache") != None:
This seems like a straightforward check, currently lsb_release does not
work at all on systems without apt-cache, such as those used by the Open
Build Service.
This appears to be present on all versions of lsb_release since at least
10.2019031300, I'm not sure if it is in older versions as well.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.chiark.greenend.org.uk/pipermail/debian-init-diversity/attachments/20200219/48196c8a/attachment.html>
More information about the Debian-init-diversity
mailing list