From 85e67040378fe37bdbdef3425cf96c29956abe21 Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Mon, 30 Jan 2012 14:20:02 +0100 Subject: [PATCH] vm/network: symlink NetworkManager system-connection to /rw (#425) In FC15, NetworkManager by default uses global connections ("Available to all users"). Save them in /rw instead of /etc, to preserve them across reboots. --- network/network-manager-prepare-conf-dir | 10 ++++++++++ network/qubes_fix_nm_conf.sh | 3 +++ rpm_spec/core-vm.spec | 2 ++ vm-init.d/qubes_core_netvm | 1 + vm-systemd/NetworkManager.service | 5 +++++ 5 files changed, 21 insertions(+) create mode 100755 network/network-manager-prepare-conf-dir diff --git a/network/network-manager-prepare-conf-dir b/network/network-manager-prepare-conf-dir new file mode 100755 index 0000000..84a3635 --- /dev/null +++ b/network/network-manager-prepare-conf-dir @@ -0,0 +1,10 @@ +#!/bin/sh + +if [ -d /etc/NetworkManager/system-connections ]; then + mkdir -p /rw/config/NM-system-connections + mv /etc/NetworkManager/system-connections/* /rw/config/NM-system-connections/ 2> /dev/null || true + rmdir /etc/NetworkManager/system-connections + ln -s /rw/config/NM-system-connections /etc/NetworkManager/system-connections +fi + +exit 0 diff --git a/network/qubes_fix_nm_conf.sh b/network/qubes_fix_nm_conf.sh index 613fa15..9f1eca7 100755 --- a/network/qubes_fix_nm_conf.sh +++ b/network/qubes_fix_nm_conf.sh @@ -4,6 +4,9 @@ VIFMAC=mac:fe:ff:ff:ff:ff:ff if ! grep -q ^plugins.*keyfile $FILE ; then sed -i 's/^plugins.*$/&,keyfile/' $FILE fi +if grep -q ^plugins.*ifcfg-rh $FILE ; then + sed -i 's/^plugins=\(.*\)ifcfg-rh,\(.*\)$/plugins=\1\2/' $FILE +fi if ! grep -q '^\[keyfile\]$' $FILE ; then echo '[keyfile]' >> $FILE fi diff --git a/rpm_spec/core-vm.spec b/rpm_spec/core-vm.spec index 0b72387..d925572 100644 --- a/rpm_spec/core-vm.spec +++ b/rpm_spec/core-vm.spec @@ -119,6 +119,7 @@ install network/qubes_network.rules $RPM_BUILD_ROOT/etc/udev/rules.d/99-qubes_ne install network/qubes_setup_dnat_to_ns $RPM_BUILD_ROOT/usr/lib/qubes install network/qubes_fix_nm_conf.sh $RPM_BUILD_ROOT/usr/lib/qubes install network/setup_ip $RPM_BUILD_ROOT/usr/lib/qubes/ +install network/network-manager-prepare-conf-dir $RPM_BUILD_ROOT/usr/lib/qubes/ install -d $RPM_BUILD_ROOT/etc/dhclient.d ln -s /usr/lib/qubes/qubes_setup_dnat_to_ns $RPM_BUILD_ROOT/etc/dhclient.d/qubes_setup_dnat_to_ns.sh install -d $RPM_BUILD_ROOT/etc/NetworkManager/dispatcher.d/ @@ -342,6 +343,7 @@ rm -rf $RPM_BUILD_ROOT /usr/lib/qubes/block_cleanup /usr/lib/qubes/block_remove /usr/lib/qubes/meminfo-writer +/usr/lib/qubes/network-manager-prepare-conf-dir /usr/lib/qubes/qfile-agent /usr/lib/qubes/qfile-unpacker /usr/lib/qubes/qopen-in-vm diff --git a/vm-init.d/qubes_core_netvm b/vm-init.d/qubes_core_netvm index 053e4be..fa67dc4 100755 --- a/vm-init.d/qubes_core_netvm +++ b/vm-init.d/qubes_core_netvm @@ -15,6 +15,7 @@ start() type=$(/usr/bin/xenstore-read qubes_vm_type) if [ "$type" == "NetVM" ]; then + /usr/lib/qubes/network-manager-prepare-conf-dir /sbin/service NetworkManager start fi diff --git a/vm-systemd/NetworkManager.service b/vm-systemd/NetworkManager.service index bf1e486..1349161 100644 --- a/vm-systemd/NetworkManager.service +++ b/vm-systemd/NetworkManager.service @@ -1,3 +1,8 @@ .include /lib/systemd/system/NetworkManager.service [Unit] ConditionPathExists=/var/run/qubes-service/network-manager +# For /rw +After=qubes-misc-post.service + +[Service] +ExecStartPre=/usr/lib/qubes/network-manager-prepare-conf-dir