|
|
d89b54 |
From ef18b39abdb5e8bf870ada3c108ab7f083405d2c Mon Sep 17 00:00:00 2001
|
|
|
d89b54 |
From: Lubomir Rintel <lkundrak@v3.sk>
|
|
|
d89b54 |
Date: Thu, 15 Feb 2018 17:57:52 +0100
|
|
|
d89b54 |
Subject: [PATCH] dnssec-trigger-script: port to libnm
|
|
|
d89b54 |
|
|
|
d89b54 |
The libnm-glib is depreacted for a long time already and is eventually
|
|
|
d89b54 |
going away.
|
|
|
d89b54 |
---
|
|
|
d89b54 |
dnssec-trigger-script.in | 51 ++++++++++++++----------------------------------
|
|
|
d89b54 |
1 file changed, 15 insertions(+), 36 deletions(-)
|
|
|
d89b54 |
|
|
|
d89b54 |
diff --git a/dnssec-trigger-script.in b/dnssec-trigger-script.in
|
|
|
d89b54 |
index 5f70580..14d9278 100644
|
|
|
d89b54 |
--- a/dnssec-trigger-script.in
|
|
|
d89b54 |
+++ b/dnssec-trigger-script.in
|
|
|
d89b54 |
@@ -13,14 +13,13 @@ import glob
|
|
|
d89b54 |
import subprocess
|
|
|
d89b54 |
import logging
|
|
|
d89b54 |
import logging.handlers
|
|
|
d89b54 |
-import socket
|
|
|
d89b54 |
import struct
|
|
|
d89b54 |
import signal
|
|
|
d89b54 |
|
|
|
d89b54 |
import gi
|
|
|
d89b54 |
-gi.require_version('NMClient', '1.0')
|
|
|
d89b54 |
+gi.require_version('NM', '1.0')
|
|
|
d89b54 |
|
|
|
d89b54 |
-from gi.repository import NMClient
|
|
|
d89b54 |
+from gi.repository import NM
|
|
|
d89b54 |
|
|
|
d89b54 |
# Python compatibility stuff
|
|
|
d89b54 |
if not hasattr(os, "O_CLOEXEC"):
|
|
|
d89b54 |
@@ -132,7 +131,7 @@ class ConnectionList:
|
|
|
d89b54 |
|
|
|
d89b54 |
def __init__(self, client, only_default=False, only_vpn=False, skip_wifi=False):
|
|
|
d89b54 |
# Cache the active connection list in the class
|
|
|
d89b54 |
- if not client.get_manager_running():
|
|
|
d89b54 |
+ if not client.get_nm_running():
|
|
|
d89b54 |
raise UserError("NetworkManager is not running.")
|
|
|
d89b54 |
if self.nm_connections is None:
|
|
|
d89b54 |
self.__class__.nm_connections = client.get_active_connections()
|
|
|
d89b54 |
@@ -208,40 +207,20 @@ class Connection:
|
|
|
d89b54 |
self.uuid = connection.get_uuid()
|
|
|
d89b54 |
|
|
|
d89b54 |
self.zones = []
|
|
|
d89b54 |
- try:
|
|
|
d89b54 |
- self.zones += connection.get_ip4_config().get_domains()
|
|
|
d89b54 |
- except AttributeError:
|
|
|
d89b54 |
- pass
|
|
|
d89b54 |
- try:
|
|
|
d89b54 |
- self.zones += connection.get_ip6_config().get_domains()
|
|
|
d89b54 |
- except AttributeError:
|
|
|
d89b54 |
- pass
|
|
|
d89b54 |
-
|
|
|
d89b54 |
self.servers = []
|
|
|
d89b54 |
- try:
|
|
|
d89b54 |
- self.servers += [self.ip4_to_str(server) for server in connection.get_ip4_config().get_nameservers()]
|
|
|
d89b54 |
- except AttributeError:
|
|
|
d89b54 |
- pass
|
|
|
d89b54 |
- try:
|
|
|
d89b54 |
- self.servers += [self.ip6_to_str(connection.get_ip6_config().get_nameserver(i))
|
|
|
d89b54 |
- for i in range(connection.get_ip6_config().get_num_nameservers())]
|
|
|
d89b54 |
- except AttributeError:
|
|
|
d89b54 |
- pass
|
|
|
d89b54 |
-
|
|
|
d89b54 |
- def __repr__(self):
|
|
|
d89b54 |
- return "<Connection(uuid={uuid}, type={type}, default={is_default}, zones={zones}, servers={servers})>".format(**vars(self))
|
|
|
d89b54 |
|
|
|
d89b54 |
- @staticmethod
|
|
|
d89b54 |
- def ip4_to_str(ip4):
|
|
|
d89b54 |
- """Converts IPv4 address from integer to string."""
|
|
|
d89b54 |
-
|
|
|
d89b54 |
- return socket.inet_ntop(socket.AF_INET, struct.pack("=I", ip4))
|
|
|
d89b54 |
+ ip4_config = connection.get_ip4_config()
|
|
|
d89b54 |
+ if ip4_config is not None:
|
|
|
d89b54 |
+ self.zones += ip4_config.get_domains()
|
|
|
d89b54 |
+ self.servers += ip4_config.get_nameservers()
|
|
|
d89b54 |
|
|
|
d89b54 |
- @staticmethod
|
|
|
d89b54 |
- def ip6_to_str(ip6):
|
|
|
d89b54 |
- """Converts IPv6 address from integer to string."""
|
|
|
d89b54 |
+ ip6_config = connection.get_ip6_config()
|
|
|
d89b54 |
+ if ip6_config is not None:
|
|
|
d89b54 |
+ self.zones += ip6_config.get_domains()
|
|
|
d89b54 |
+ self.servers += ip6_config.get_nameservers()
|
|
|
d89b54 |
|
|
|
d89b54 |
- return socket.inet_ntop(socket.AF_INET6, ip6)
|
|
|
d89b54 |
+ def __repr__(self):
|
|
|
d89b54 |
+ return "<Connection(uuid={uuid}, type={type}, default={is_default}, zones={zones}, servers={servers})>".format(**vars(self))
|
|
|
d89b54 |
|
|
|
d89b54 |
@property
|
|
|
d89b54 |
def ignore(self):
|
|
|
d89b54 |
@@ -466,10 +445,10 @@ class Application:
|
|
|
d89b54 |
except AttributeError:
|
|
|
d89b54 |
self.usage()
|
|
|
d89b54 |
|
|
|
d89b54 |
- self.client = NMClient.Client().new()
|
|
|
d89b54 |
+ self.client = NM.Client().new()
|
|
|
d89b54 |
|
|
|
d89b54 |
def nm_handles_resolv_conf(self):
|
|
|
d89b54 |
- if not self.client.get_manager_running():
|
|
|
d89b54 |
+ if not self.client.get_nm_running():
|
|
|
d89b54 |
log.debug("NetworkManager is not running")
|
|
|
d89b54 |
return False
|
|
|
d89b54 |
try:
|
|
|
d89b54 |
--
|
|
|
d89b54 |
2.13.6
|
|
|
d89b54 |
|