/etc/init.d/adtxenlvm is in autopkgtest-xenlvm 2.0.1ubuntu4.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | #!/bin/bash
set -e
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
### BEGIN INIT INFO
# Provides: adtxenlvm
# Required-Start: $network $remote_fs
# Required-Stop: $network $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Prepare firewall tables for autopkgtest Xen guests
### END INIT INFO
lsbif=/lib/lsb/init-functions
if test -e $lsbif; then
. $lsbif
else
log_daemon_msg () { printf "%s: " "$1"; }
log_progress_msg () { printf "%s " "$1"; }
log_end_msg () { echo "done."; }
fi
if test -f /etc/default/rcS; then . /etc/default/rcS; fi
chains='AdtXenIn AdtXenFwd AdtXenIcmp'
if ! type iptables >/dev/null 2>&1 || ! type xm >/dev/null 2>&1; then
exit 0
fi
safety () {
log_progress_msg block
iptables -I INPUT -j DROP
iptables -I FORWARD -j DROP
trap '
for chain in $chains; do iptables -I $chain -j DROP; done
unsafety
exit 127
' 0
}
unsafety () {
log_progress_msg unblock
iptables -D INPUT -j DROP
iptables -D FORWARD -j DROP
trap '' 0
}
case "$1" in
stop)
log_daemon_msg "adtxenlvm: removing firewall rules"
safety
log_progress_msg clear
for chain in $chains; do
if iptables -L -n $chain >/dev/null 2>&1; then
log_progress_msg $chain
iptables -F $chain
iptables -X $chain
fi
done
unsafety
log_end_msg 0
exit 0
;;
start|restart|force-reload)
;;
'')
echo >&2 "usage: /etc/init.d/adt-xen stop|start|restart|force-reload"
exit 1
;;
*)
echo >&2 "init.d/adt-xen unsupported action $1"
exit 1
;;
esac
set --
exec 8>&1
case "$VERBOSE" in
no) exec >/dev/null ;;
esac
adt_readconfig_initscript=y
printf "adtxenlvm: reading configuration for firewall setup:\n"
. ${ADT_XENLVM_SHARE:=/usr/share/autopkgtest/xenlvm}/readconfig
exec >&8 8>&-
log_daemon_msg "adtxenlvm: installing firewall rules"
safety
log_progress_msg create
for chain in $chains; do
log_progress_msg $chain
iptables -N $chain >/dev/null 2>&1 || iptables -F $chain
iptables -I $chain -j DROP
done
unsafety
log_progress_msg rules
iptables -A AdtXenIcmp -j ACCEPT -p icmp --icmp-type echo-request
# per RFC1122, allow ICMP echo exchanges with anyone we can talk to at all
for oktype in \
echo-reply \
destination-unreachable source-quench \
time-exceeded parameter-problem \
;do
iptables -A AdtXenIcmp -j ACCEPT -m conntrack --ctstate ESTABLISHED \
-p icmp --icmp-type $oktype
done
main=AdtXenFwd
for i in $adt_fw_localmirrors; do
iptables -A $main -d $i -j ACCEPT -p tcp --dport 80
iptables -A $main -d $i -j AdtXenIcmp -p icmp
done
exec </etc/resolv.conf
while read command rest; do
if [ "x$command" = "xnameserver" ]; then
iptables -A $main -d $rest -j ACCEPT -p tcp --dport 53
iptables -A $main -d $rest -j ACCEPT -p udp --dport 53
iptables -A $main -d $rest -j AdtXenIcmp -p icmp
fi
done
for i in $adt_fw_testbedclients; do
iptables -A $main -d $i -j ACCEPT -p tcp ! --syn
iptables -A $main -d $i -j AdtXenIcmp -p icmp
done
for i in $adt_fw_prohibnets; do
iptables -A $main -d $i -j REJECT --reject-with icmp-net-prohibited
done
if [ x"$adt_fw_allowglobalports" != x ]; then
iptables -A $main -p icmp -j AdtXenIcmp
fi
for port in $adt_fw_allowglobalports; do
iptables -A $main -p tcp --dport $port -j ACCEPT
done
if [ "x$adt_fw_hook" != x ]; then
log_progress_msg hook
. $adt_fw_hook
fi
log_progress_msg confirm
iptables -A $main -j REJECT --reject-with icmp-admin-prohibited
iptables -D $main -j DROP
log_progress_msg engage
iptables -A AdtXenIn -j ACCEPT -p icmp --icmp-type echo-request
iptables -A AdtXenIn -j ACCEPT -m conntrack --ctstate ESTABLISHED
iptables -A AdtXenIn -j AdtXenFwd
iptables -D AdtXenIn -j DROP
iptables -D AdtXenIcmp -j DROP
log_progress_msg proxyarp
echo 1 >/proc/sys/net/ipv4/conf/eth0/proxy_arp
log_end_msg 0
|