File 0004-fw_nm-New-function-to-get-all-interfaces-from-NM.patch of Package firewalld.8867
From c915eea51aa1f68e5b14fcca9325e36a0bb56e71 Mon Sep 17 00:00:00 2001
From: Eric Garver <e@erig.me>
Date: Wed, 18 Jul 2018 12:15:04 -0400
Subject: [PATCH 4/8] fw_nm: New function to get all interfaces from NM
(cherry picked from commit b82a6c69d98443d20a3c14d04aeef8f0fe616161)
---
src/firewall/core/fw_nm.py | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/src/firewall/core/fw_nm.py b/src/firewall/core/fw_nm.py
index 2cbb017e..686810a7 100644
--- a/src/firewall/core/fw_nm.py
+++ b/src/firewall/core/fw_nm.py
@@ -143,6 +143,36 @@ def nm_get_connections(connections, connections_name):
for dev in devices:
connections[dev.get_iface()] = uuid
+def nm_get_interfaces():
+ """Get active interfaces from NM
+ @returns list of interface names
+ """
+
+ check_nm_imported()
+
+ active_interfaces = []
+
+ for active_con in nm_get_client().get_active_connections():
+ # ignore vpn devices for now
+ if active_con.get_vpn():
+ continue
+
+ try:
+ con = active_con.get_connection()
+ if con.get_flags() & (NM.SettingsConnectionFlags.NM_GENERATED
+ | NM.SettingsConnectionFlags.NM_VOLATILE):
+ continue
+ except AttributeError:
+ # Prior to NetworkManager 1.12, we can only guess
+ # that a connection was generated/volatile.
+ if con.get_unsaved():
+ continue
+
+ for dev in active_con.get_devices():
+ active_interfaces.append(dev.get_iface())
+
+ return active_interfaces
+
def nm_get_connection_of_interface(interface):
"""Get connection from NM that is using the interface
@param interface name
--
2.19.0