diff --git a/init/functions b/init/functions index 19a522e..4f099dd 100644 --- a/init/functions +++ b/init/functions @@ -128,6 +128,21 @@ umount_retry() { return 0 } +get_iface_from_mac() { + local mac="$1" + local iface + iface="$(ip -o link | grep -i "$mac" | awk '{print $2}' | cut -d ':' -f1)" + echo "$iface" +} + +get_qubes_managed_iface() { + local mac + local qubes_iface + mac="$(qubesdb-read /qubes-mac)" + qubes_iface="$(get_iface_from_mac "$mac")" + echo "$qubes_iface" +} + initialize_home() { local home_root local mode diff --git a/network/network-manager-prepare-conf-dir b/network/network-manager-prepare-conf-dir index 7eb09c1..e76ce01 100755 --- a/network/network-manager-prepare-conf-dir +++ b/network/network-manager-prepare-conf-dir @@ -1,5 +1,9 @@ #!/bin/sh +# Source Qubes library. +# shellcheck source=init/functions +. /usr/lib/qubes/init/functions + NM_CONFIG_DIR=/etc/NetworkManager/system-connections if [ -d $NM_CONFIG_DIR ] && [ ! -h $NM_CONFIG_DIR ]; then mkdir -p /rw/config/NM-system-connections @@ -20,7 +24,7 @@ sed -r -i -e "s/^#?plugins=.*/plugins=keyfile/" /etc/NetworkManager/NetworkManag # starting NetworkManager, otherwise it will try default DHCP configuration # first and only after a timeout fallback to static one - introducing delay in # network connectivity -export INTERFACE=eth0 +export INTERFACE="$(get_qubes_managed_iface)" if qubesdb-read /qubes-ip >/dev/null 2>/dev/null && [ -e /sys/class/net/$INTERFACE ] && [ ! -r /etc/NetworkManager/system-connections/qubes-uplink-$INTERFACE ]; then diff --git a/vm-init.d/qubes-firewall b/vm-init.d/qubes-firewall index 483debc..1db1c72 100755 --- a/vm-init.d/qubes-firewall +++ b/vm-init.d/qubes-firewall @@ -19,7 +19,7 @@ start() if qsvc qubes-firewall ; then echo -n $"Starting Qubes Firewall monitor:" - /sbin/ethtool -K eth0 sg off + /sbin/ethtool -K "$(get_qubes_managed_iface)" sg off /usr/sbin/qubes-firewall & success echo "" diff --git a/vm-systemd/misc-post.sh b/vm-systemd/misc-post.sh index 031e8a7..0533013 100755 --- a/vm-systemd/misc-post.sh +++ b/vm-systemd/misc-post.sh @@ -15,7 +15,10 @@ fi # DispVM (to override DispVM-template IP) and in case when qubes-ip was # called by udev before loading evtchn kernel module - in which case # qubesdb-read fails -INTERFACE=eth0 /usr/lib/qubes/setup-ip +QUBES_MANAGED_IFACE="$(get_qubes_managed_iface)" +if [ "x$QUBES_MANAGED_IFACE" != "x" ]; then +INTERFACE="$QUBES_MANAGED_IFACE" /usr/lib/qubes/setup-ip +fi if [ -x /rw/config/rc.local ] ; then /rw/config/rc.local diff --git a/vm-systemd/network-proxy-setup.sh b/vm-systemd/network-proxy-setup.sh index ec8504e..418db31 100755 --- a/vm-systemd/network-proxy-setup.sh +++ b/vm-systemd/network-proxy-setup.sh @@ -1,5 +1,9 @@ #!/bin/sh +# Source Qubes library. +# shellcheck source=init/functions +. /usr/lib/qubes/init/functions + # Setup gateway for all the VMs this netVM is serviceing... network=$(qubesdb-read /qubes-netvm-network 2>/dev/null) if [ "x$network" != "x" ]; then @@ -24,5 +28,5 @@ if [ "x$network" != "x" ]; then if [ -n "$gateway6" ]; then echo 1 > /proc/sys/net/ipv6/conf/all/forwarding fi - /sbin/ethtool -K eth0 sg off || true + /sbin/ethtool -K "$(get_qubes_managed_iface)" sg off || true fi