2011-03-11 19:39:52 +01:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
|
|
|
PIDFILE=/var/run/qubes/qubes_netwatcher.pid
|
|
|
|
CURR_NETCFG=""
|
|
|
|
|
|
|
|
# PIDfile handling
|
|
|
|
[[ -e $PIDFILE ]] && kill -s 0 $(<$PIDFILE) 2>/dev/null && exit 0
|
|
|
|
echo $$ >$PIDFILE
|
|
|
|
|
|
|
|
trap 'exit 0' SIGTERM
|
|
|
|
|
|
|
|
while true; do
|
|
|
|
NET_DOMID=$(/usr/bin/xenstore-read qubes_netvm_domid)
|
|
|
|
if [[ -n "$NET_DOMID" ]] && [[ $NET_DOMID -gt 0 ]]; then
|
2012-01-18 19:34:09 +01:00
|
|
|
UNTRUSTED_NETCFG=$(/usr/bin/xenstore-read /local/domain/$NET_DOMID/qubes_netvm_external_ip || :)
|
2011-05-09 16:23:52 +02:00
|
|
|
# UNTRUSTED_NETCFG is not parsed in any way
|
2011-05-09 16:26:48 +02:00
|
|
|
# thus, no sanitization ready
|
|
|
|
# but be careful when passing it to other shell scripts
|
2011-05-09 16:23:52 +02:00
|
|
|
if [[ "$UNTRUSTED_NETCFG" != "$CURR_NETCFG" ]]; then
|
2012-03-09 00:21:39 +01:00
|
|
|
/sbin/service qubes-firewall stop
|
|
|
|
/sbin/service qubes-firewall start
|
2011-05-09 16:23:52 +02:00
|
|
|
CURR_NETCFG="$UNTRUSTED_NETCFG"
|
2011-03-23 22:21:42 +01:00
|
|
|
/usr/bin/xenstore-write qubes_netvm_external_ip "$CURR_NETCFG"
|
2011-03-11 19:39:52 +01:00
|
|
|
fi
|
|
|
|
|
2011-06-06 02:37:55 +02:00
|
|
|
/usr/bin/xenstore-watch-qubes /local/domain/$NET_DOMID/qubes_netvm_external_ip
|
2011-03-11 19:39:52 +01:00
|
|
|
else
|
2011-06-06 02:37:55 +02:00
|
|
|
/usr/bin/xenstore-watch-qubes qubes_netvm_domid
|
2011-03-11 19:39:52 +01:00
|
|
|
fi
|
|
|
|
done
|