Issue #5 open

Crash caused by invalid symlink under /lib/modules

Niko Böckerman avatarNiko Böckerman created an issue

eclean-kernel-0.3.3 crashed because I had two invalid symlinks under /lib/modules/:

# ls -l /lib/modules/
total 8
drwxr-xr-x 3 root root 4096 maali  9 02:09 3.4.34-gentoo
drwxr-xr-x 3 root root 4096 maali  7 22:15 3.4.35
lrwxrwxrwx 1 root root   21 tammi 14 23:45 build -> /usr/src/linux-3.4.25
lrwxrwxrwx 1 root root   21 tammi 14 23:45 source -> /usr/src/linux-3.4.25

I don't know how the symlinks have got there in the first place, but the important thing is that the /usr/src/linux-3.4.25 folder did not exist.

The list output of eclean-kernel showed this output:

# eclean-kernel -l
source [None]:
- modules: /usr/src/linux-3.4.25
3.4.34-gentoo [3.4.34-gentoo]:
- vmlinuz: /boot/vmlinuz-3.4.34-gentoo
- systemmap: /boot/System.map-3.4.34-gentoo
- config: /boot/config-3.4.34-gentoo
- modules: /lib64/modules/3.4.34-gentoo
- build: /usr/src/linux-3.4.34-gentoo
3.4.35 [None]:
- modules: /lib64/modules/3.4.35
- build: /usr/src/linux-3.4.35

The invalid symlinks caused the first entry of source [None].

Then when I tried to remove kernels eclean-kernel crashed with this traceback:

# eclean-kernel -dA
Traceback (most recent call last):
  File "/usr/bin/eclean-kernel-python3.2", line 26, in <module>
    sys.exit(main(sys.argv))
  File "/usr/lib64/python3.2/site-packages/ecleankernel/cli.py", line 156, in main
    k.check_writable()
  File "/usr/lib64/python3.2/site-packages/ecleankernel/kernel.py", line 125, in check_writable
    raise OSError('%s not writable, refusing to proceed' % path)
OSError: /usr/src/linux-3.4.25 not writable, refusing to proceed

I don't know how this case should be handled but a crash is always a bad thing to happen. At the least eclean-kernel could just ignore those symlinks and still be able to remove the other kernels.

Comments (7)

  1. Michał Górny

    Thinking about it more, there's probably some more danger to even ignoring broken symlinks. A broken symlink may mean that something is not mounted properly. Thinking about it, broken symlinks for kernels may make the program get the counts wrong… modules aren't probably a case here, just thinking loudly.

  2. Michał Górny

    I'm not sure if you'd consider it fixed but the best thing I can do has just went live in 0.4.

    Now the program tries to detect this particular case and give an explanatory error message, telling you to investigate the symlink.

  3. Niko Böckerman

    I now receive this output with the same broken symlinks:

    # eclean-kernel -l
    eclean-kernel has met the following issue:
    
    The following file is not readable:
      /usr/src/linux-3.4.25
    
    This usually indicates that you have insufficient permissions to run
    eclean-kernel. The program needs to be able to read all kernel-related
    files in order to properly associate them. Lack of access to some
    of the files may result in wrong kernels being removed and therefore
    the program will refuse to proceed.
    
    If you believe that the mentioned issue is a bug, please report it
    to https://bitbucket.org/mgorny/eclean-kernel/issues. If possible,
    please attach the output of 'eclean-kernel --list-kernels' and your
    regular eclean-kernel call with additional '--debug' argument.
    

    Looking at your commit history and especially this commit (0dd75ca) I would except the output to actually mention the symlink. Now the error message is just about the linked folder. If I would see the message written in that commit, I would consider this fixed, but currently it is not fixed.

  4. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.