Blame SOURCES/0001-dnssec-trigger-script-port-to-libnm.patch

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