Skip to content
This repository was archived by the owner on Jan 27, 2023. It is now read-only.
This repository was archived by the owner on Jan 27, 2023. It is now read-only.

NetworkManager >= 1.34 causes GetConnectionByUuid to fail with KeyError: 'dns' #93

Description

@michael-schaller

NetworkManager >= 1.34 only provides the dns field as part of the org.freedesktop.NetworkManager.Settings.Connection.GetSettings reply if a custom DNS server is set in the connection config. This in turn causes python-networkmanager to fail as it always expects the dns field:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 9, in GetConnectionByUuid
  File "/usr/lib/python3/dist-packages/NetworkManager.py", line 583, in to_python
    val = fixups.base_to_python(val)
  File "/usr/lib/python3/dist-packages/NetworkManager.py", line 653, in base_to_python
    return globals()[classname](val)
  File "/usr/lib/python3/dist-packages/NetworkManager.py", line 309, in __init__
    self.uuid = self.GetSettings()['connection']['uuid']
  File "<string>", line 8, in GetSettings
  File "/usr/lib/python3/dist-packages/NetworkManager.py", line 624, in to_python
    val['ipv4']['dns'] = [fixups.addr_to_python(addr,socket.AF_INET) for addr in val['ipv4']['dns']]
KeyError: 'dns'

This can be reproduced easily by adding/removing a custom DNS server to a connection config and then using dbus-send.

This in turn means that this code part shouldn't assume that the dns field is available:
https://github.com/seveas/python-networkmanager/blob/main/NetworkManager.py#L616-L623

The code part probably also shouldn't assume that the other fields are available either. ;-)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions