Skip to content

Error parsing kernel release number in ifcfg module #5087

@mariospr

Description

@mariospr

Summary

When I install ka-lite in my ARM device, I can't get it to start without crashing, due to a parsin problem in the ifcfg module, which is printing this error instead:

Running 'kalite start' as daemon (system service)

Stand by while the server loads its data...

[WARNING] [2016-04-15 15:45:35,777] kalite: Channel khan does not exist.
Traceback (most recent call last):
  File "/usr/share/kalite/kalitectl.py", line 925, in <module>
    port=arguments["--port"]
  File "/usr/share/kalite/kalitectl.py", line 527, in start
    addresses = get_ip_addresses(include_loopback=False)
  File "/usr/share/kalite/python-packages/fle_utils/internet/functions.py", line 94, in get_ip_addresses
    ips = [iface.get("inet") for iface in ifcfg.interfaces().values()]
  File "/usr/share/kalite/python-packages/ifcfg/__init__.py", line 62, in interfaces
    parser = get_parser()
  File "/usr/share/kalite/python-packages/ifcfg/__init__.py", line 42, in get_parser
    if float(kernel) < 3.3:
ValueError: invalid literal for float(): 3.10-trunk-meson8

Looking at the relevant code it seems to me that there are two issues:

  • The code assumes that the kernel's release number contains the minor revision, which is true in all the other environments I tried (e.g. it's '4.3.3-301.fc23.x86_64' on my Intel laptop), but not necessarily true everywhere (it's '3.10-trunk-meson8' in my ARM device).
  • The comparison to determine whether the kernel is old is broken, since for instance float('3.10') will evaluate to the 3.1 number, resulting in the wrong conclusion.

Branch or installer method

The crash is happening both in the stable version installable with pip install ka-lite-static and the one from the master branch on Linux machines, as long as the output of uname -r returns a release number string where the major revision number part is not a valid number (e.g. containing non-digits).

The wrong comparison against the 3.3 version seems to be wrong regardless of the underlying system.

How to reproduce

  1. Run kalite start on Linux where uname -r reports a non-integer major revision number string
  2. See how it crashes with the backtrace mentioned above

Alternatively replace this line with something full_kernel = "3.10-trunk-meson8" to replicate my environment and you should get the crash too.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions