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

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