Blame SOURCES/0012-test-functions-new-macros-for-starting-stopping-Netw.patch

40251c
From 8a1ee3a46ca31d36e1b5702971d8f0b6240edc93 Mon Sep 17 00:00:00 2001
40251c
From: Eric Garver <eric@garver.life>
40251c
Date: Tue, 19 Nov 2019 15:31:28 -0500
40251c
Subject: [PATCH 12/37] test: functions: new macros for starting/stopping
40251c
 NetworkManager
40251c
40251c
(cherry picked from commit fd99d328cf9713445428d4b8c4317377ee494981)
40251c
(cherry picked from commit 689c833fc83e2f858792f7f5e979b413421a8e0d)
40251c
---
40251c
 src/tests/functions.at | 85 +++++++++++++++++++++++++++++++++++++++++-
40251c
 1 file changed, 84 insertions(+), 1 deletion(-)
40251c
40251c
diff --git a/src/tests/functions.at b/src/tests/functions.at
40251c
index 46bcd369864f..f59eef80c348 100644
40251c
--- a/src/tests/functions.at
40251c
+++ b/src/tests/functions.at
40251c
@@ -34,6 +34,48 @@ m4_define([FWD_START_FIREWALLD], [
40251c
     AT_FAIL_IF([test $up -ne 1])
40251c
 ])
40251c
 
40251c
+m4_define([START_NETWORKMANAGER], [
40251c
+    AT_SKIP_IF([! NS_CMD([which NetworkManager >/dev/null 2>&1])])
40251c
+    AT_SKIP_IF([! NS_CMD([which nmcli >/dev/null 2>&1])])
40251c
+
40251c
+    AT_DATA([./NetworkManager.conf], [dnl
40251c
+[[main]]
40251c
+plugins=
40251c
+
40251c
+[[logging]]
40251c
+#level=DEBUG
40251c
+#domains=ALL
40251c
+])
40251c
+
40251c
+    NM_ARGS="--no-daemon --config ./NetworkManager.conf"
40251c
+    NS_CMD([NetworkManager $NM_ARGS &])
40251c
+    if test $? -ne 0; then
40251c
+        AT_FAIL_IF([:])
40251c
+    fi
40251c
+    echo "$!" > networkmanager.pid
40251c
+
40251c
+    dnl Give it some time for the dbus interface to come up
40251c
+    up=0
40251c
+    for I in 1 2 3 4 5 6 7 8 9 0; do
40251c
+        if NS_CMD([nmcli general status >/dev/null 2>&1]); then
40251c
+            up=1
40251c
+            break
40251c
+        fi
40251c
+        sleep 1
40251c
+    done
40251c
+    AT_FAIL_IF([test $up -ne 1])
40251c
+])
40251c
+
40251c
+m4_define([STOP_NETWORKMANAGER], [
40251c
+    pid=$(< networkmanager.pid)
40251c
+    kill $pid
40251c
+    for I in 1 2 3 4 5 6 7 8 9 0; do
40251c
+        ps --pid $pid >/dev/null || { pid=0; break; }
40251c
+        sleep 1
40251c
+    done
40251c
+    test $pid -eq 0 || { kill -9 $pid; sleep 3; }
40251c
+])
40251c
+
40251c
 m4_define([FWD_RELOAD], [
40251c
     FWD_CHECK([-q --reload], [$1], [$2], [$3])
40251c
     FWD_CHECK([-q --state], [$4], [$5], [$6])
40251c
@@ -86,11 +128,16 @@ m4_define([FWD_START_TEST], [
40251c
         function kill_firewalld() {
40251c
             FWD_STOP_FIREWALLD
40251c
         }
40251c
+        function kill_networkmanager() {
40251c
+            if test -f networkmanager.pid; then
40251c
+                STOP_NETWORKMANAGER
40251c
+            fi
40251c
+        }
40251c
 
40251c
         dnl run cleanup commands on test exit
40251c
         echo "" > cleanup
40251c
         echo "" > cleanup_late
40251c
-        trap ". ./cleanup; kill_firewalld; . ./cleanup_late" EXIT
40251c
+        trap ". ./cleanup; kill_firewalld; kill_networkmanager; . ./cleanup_late" EXIT
40251c
 
40251c
         dnl create a namespace and dbus-daemon
40251c
         m4_define([CURRENT_DBUS_ADDRESS], [unix:abstract=firewalld-testsuite-dbus-system-socket-${at_group_normalized}])
40251c
@@ -130,6 +177,42 @@ m4_define([FWD_START_TEST], [
40251c
                        send_interface="org.freedesktop.DBus.Properties"/>
40251c
                 <allow send_destination="org.fedoraproject.FirewallD1.config"/>
40251c
             </policy>
40251c
+
40251c
+            
40251c
+            <policy user="root">
40251c
+                    <allow own="org.freedesktop.NetworkManager"/>
40251c
+                    <allow send_destination="org.freedesktop.NetworkManager"/>
40251c
+
40251c
+                    
40251c
+                           send_interface="org.freedesktop.NetworkManager.PPP"/>
40251c
+
40251c
+                    <allow send_interface="org.freedesktop.NetworkManager.SecretAgent"/>
40251c
+                    
40251c
+                         <deny send_interface="..." /> (see dbus-daemon(8) for details).
40251c
+                         This seems to override that for the known VPN plugins.
40251c
+                      -->
40251c
+                    <allow send_destination="org.freedesktop.NetworkManager.openconnect"/>
40251c
+                    <allow send_destination="org.freedesktop.NetworkManager.openswan"/>
40251c
+                    <allow send_destination="org.freedesktop.NetworkManager.openvpn"/>
40251c
+                    <allow send_destination="org.freedesktop.NetworkManager.pptp"/>
40251c
+                    <allow send_destination="org.freedesktop.NetworkManager.vpnc"/>
40251c
+                    <allow send_destination="org.freedesktop.NetworkManager.ssh"/>
40251c
+                    <allow send_destination="org.freedesktop.NetworkManager.iodine"/>
40251c
+                    <allow send_destination="org.freedesktop.NetworkManager.l2tp"/>
40251c
+                    <allow send_destination="org.freedesktop.NetworkManager.libreswan"/>
40251c
+                    <allow send_destination="org.freedesktop.NetworkManager.fortisslvpn"/>
40251c
+                    <allow send_destination="org.freedesktop.NetworkManager.strongswan"/>
40251c
+                    <allow send_interface="org.freedesktop.NetworkManager.VPN.Plugin"/>
40251c
+
40251c
+                    <allow send_destination="org.fedoraproject.FirewallD1"/>
40251c
+
40251c
+                    
40251c
+                         from the dns dnsmasq plugin to own it's dbus name, and for
40251c
+                         messages to be sent to it.
40251c
+                     -->
40251c
+                    <allow own="org.freedesktop.NetworkManager.dnsmasq"/>
40251c
+                    <allow send_destination="org.freedesktop.NetworkManager.dnsmasq"/>
40251c
+            </policy>
40251c
             </busconfig>
40251c
 ])
40251c
         DBUS_PID=`NS_CMD([dbus-daemon --address="CURRENT_DBUS_ADDRESS" --print-pid --config-file="./dbus.conf"])`
40251c
-- 
40251c
2.23.0
40251c