symlinks breaks lsb_release, but diff reports no changes?
Jeffrey Walton
noloader at gmail.com
Thu Dec 18 16:43:52 UTC 2025
On Wed, Dec 17, 2025 at 1:03 PM Jeffrey Walton <noloader at gmail.com> wrote:
>
> On Mon, Dec 15, 2025 at 12:21 PM Jeffrey Walton <noloader at gmail.com> wrote:
> >
> > I'm seeing an issue on Ubuntu 22.04.5 LTS that I can't explain.
> > Below, symlinks breaks lsb_release, but a diff of before/after reports
> > no changes. Any help would be appreciated.
> >
> > First, lsb_release works:
> >
> > $ lsb_release -a
> > LSB Version: core-11.1.0ubuntu4-noarch:security-11.1.0ubuntu4-noarch
> > Distributor ID: Ubuntu
> > Description: Ubuntu 22.04.5 LTS
> > Release: 22.04
> > Codename: jammy
> >
> > Second, run symlinks script (as root):
> >
> > #!/usr/bin/env bash
> >
> > symlinks -r / 1>symlinks.1.txt
> >
> > for dir in /bin /etc /home /lib /lib32 /lib64 /media /mnt /opt /root
> > /run /sbin /srv /tmp /usr /var;
> > do
> > # Ensure the directory exists
> > test -d "${dir}" || continue
> > # Skip directories that are tmpfs
> > df -hT "${dir}" | grep -q tmpfs && continue
> > # echo " dir: ${dir}"
> > symlinks -r -d "${dir}" 1>/dev/null
> > done
> >
> > symlinks -r / 1>symlinks.2.txt
> >
> > Third, try lsb_release again:
> >
> > $ lsb_release -a
> > Traceback (most recent call last):
> > File "/usr/bin/lsb_release", line 25, in <module>
> > import lsb_release
> > ModuleNotFoundError: No module named 'lsb_release'
> >
> > Fourth, diff the changes from symlinks:
> >
> > $ diff symlinks.1.txt symlinks.2.txt
> > $
> >
> > Fifth, reinstall lsb-release package:
> >
> > $ sudo apt install --reinstall lsb-release
> >
> > Sixth, recheck lsb_release:
> >
> > $ lsb_release -a
> > LSB Version: core-11.1.0ubuntu4-noarch:security-11.1.0ubuntu4-noarch
> > Distributor ID: Ubuntu
> > Description: Ubuntu 22.04.5 LTS
> > Release: 22.04
> > Codename: jammy
> >
> > One clue is from dpkg, but I don't know if it is a red herring:
> >
> > $ dpkg -L lsb-release
> > ...
> > /usr/share/pyshared
> > /usr/share/pyshared/lsb_release.py
> > /usr/lib/python2.7/dist-packages/lsb_release.py
> > /usr/lib/python3/dist-packages/lsb_release.py
> >
> > And:
> >
> > $ ls /usr/share/pyshared
> > lsb_release.py
> > $ ls /usr/share/pyshared/lsb_release.py
> > /usr/share/pyshared/lsb_release.py
> > $ ls /usr/lib/python2.7/dist-packages/lsb_release.py
> > ls: cannot access '/usr/lib/python2.7/dist-packages/lsb_release.py':
> > No such file or directory
> > $ ls /usr/lib/python3/dist-packages/lsb_release.py
> > ls: cannot access '/usr/lib/python3/dist-packages/lsb_release.py': No
> > such file or directory
> >
> > $ ls -d /usr/lib/python*
> > /usr/lib/python2.7 /usr/lib/python3 /usr/lib/python3.10 /usr/lib/python3.11
> >
> > And:
> >
> > $ sudo find /usr/lib -name lsb_release.py
> > $
> >
> > I am missing something. Does anyone know what is going on?
>
> I tracked it down to a symlink that goes missing. But I don't
> understand why symlinks does not report it as a dangling link, and
> then why symlinks deletes it.
>
> First, start with a working lsb_release:
>
> LSB Version: core-11.1.0ubuntu4-noarch:security-11.1.0ubuntu4-noarch
> Distributor ID: Ubuntu
> Description: Ubuntu 22.04.5 LTS
> Release: 22.04
> Codename: jammy
>
> Second, check the Python3 lsb_release (from dpkg -L symlinks):
>
> $ ls -Al /usr/lib/python3/dist-packages/lsb_release.py
> lrwxrwxrwx 1 root root 38 Mar 24 2022
> /usr/lib/python3/dist-packages/lsb_release.py ->
> ../../../share/pyshared/lsb_release.py
> $ ls /usr/share/pyshared/lsb_release.py
> /usr/share/pyshared/lsb_release.py
>
> Third, see what symlinks says about it:
>
> $ sudo symlinks -r / | grep lsb
> $ sudo symlinks -r /usr | grep lsb
> $ sudo symlinks -r /usr/lib | grep lsb
> $
>
> Fourth, clean symlinks:
>
> [See script above]
>
> Fifth, check lsb_release again:
>
> Traceback (most recent call last):
> File "/usr/bin/lsb_release", line 25, in <module>
> import lsb_release
> ModuleNotFoundError: No module named 'lsb_release'
>
> Sixth, check the lsb_release symlink again:
>
> $ ls -Al /usr/lib/python3/dist-packages/lsb_release.py
> ls: cannot access '/usr/lib/python3/dist-packages/lsb_release.py': No
> such file or directory
> $ ls /usr/share/pyshared/lsb_release.py
> /usr/share/pyshared/lsb_release.py
>
> So it looks like symlinks silently deleted the symlink
> /usr/lib/python3/dist-packages/lsb_release.py. symlinks never
> reported it as a symlink, and did not report it was deleted when
> symlinks was run with the -d option. Bad tool!
>
> I guess this should be reported to the Ubuntu folks.
The missing two pieces are: (1) symlinks needs to be run with `-v`
option to view relative links; and (2) symlinks is deleting relative
links that are _not_ reported as dangling.
So this will generate the proper diff file:
symlinks -v -r / 1>symlinks.1.txt
# Avoid special filesystems, like /boot, /dev, /proc and /sys
for dir in /bin /etc /home /lib /lib32 /lib64 /media /mnt /opt /root
/run /sbin /srv /tmp /usr /var;
do
# Ensure the directory exists
test -d "${dir}" || continue
# Skip directories that are tmpfs
df -hT "${dir}" | grep -q tmpfs && continue
# echo " dir: ${dir}"
symlinks -r -d "${dir}" 1>/dev/null
done
symlinks -v -r / 1>symlinks.2.txt
And then diff'ing the files:
$ diff symlinks.1.txt symlinks.2.txt
3637d3636
< relative: /usr/lib/python2.7/dist-packages/lsb_release.py ->
../../../share/pyshared/lsb_release.py
7345d7343
< relative: /usr/lib/python3/dist-packages/lsb_release.py ->
../../../share/pyshared/lsb_release.py
Notice symlinks deleted relative links, not dangling links. Bad tool!
Jeff
More information about the ubuntu-users
mailing list