3
# Copyright 2010 Canonical Ltd.
5
# This program is free software: you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License version 3,
7
# as published by the Free Software Foundation.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with this program. If not, see <http://www.gnu.org/licenses/>.
17
source "$TESTPATH/../testlib.sh"
21
echo "show listening" >> $TESTTMP/result
22
echo "(update util.py to use our cached output)" >> $TESTTMP/result
23
sed -i "s#rc, report = cmd.* '-enlp'.*#rc, report = cmd(['cat', '$TESTPATH/../good/reports/netstat.enlp'])#" $TESTPATH/lib/python/ufw/util.py
24
sed -i "s#item\['exe'\] = get_exe.*#item['exe'] = 'REMOVED_FOR_UFW_TEST'#" $TESTPATH/lib/python/ufw/util.py
25
sed -i "s#proc = '/proc/net/if_inet6'#proc = '$TESTPATH/../good/reports/proc_net_if_inet6'#" $TESTPATH/lib/python/ufw/util.py
26
sed -i "s#proc = '/proc/net/dev'#proc = '$TESTPATH/../good/reports/proc_net_dev'#" $TESTPATH/lib/python/ufw/util.py
27
sed -i "s#\(.*\)\(addr = .* 0x8915,.*\)#\\1if ifname == 'eth0':\n\\1\\1addr = '10.0.2.9'\n\\1elif ifname == 'eth1':\n\\1\\1addr = '10.0.2.101'\n\\1else:\n\\1\\1raise IOError\n return normalize_address(addr, v6)[0]\n \\2#" $TESTPATH/lib/python/ufw/util.py
29
do_cmd "0" show listening
31
echo "show listening with rules" >> $TESTTMP/result
32
sed -i "s/IPV6=.*/IPV6=yes/" $TESTPATH/etc/default/ufw
34
for i in "" "in on eth0" ; do
36
do_cmd "0" null allow in 123
37
do_cmd "0" null allow in OpenNTPD
38
do_cmd "0" null allow in 123/tcp
40
do_cmd "0" null allow out 123
41
do_cmd "0" null allow out 123/udp
42
do_cmd "0" null allow out 123/tcp
45
do_cmd "0" null allow $i to any
46
do_cmd "0" null allow $i to any proto udp
47
do_cmd "0" null allow $i to any proto tcp
49
do_cmd "0" null allow $i to 10.0.2.101
50
do_cmd "0" null allow $i to 10.0.2.9
51
do_cmd "0" null allow $i to 10.0.0.0/16
52
do_cmd "0" null allow $i to 10.0.2.0/24
53
do_cmd "0" null allow $i to 10.0.3.0/24
54
do_cmd "0" null allow $i to fe80::211:aaaa:bbbb:d54c
56
do_cmd "0" null allow $i to 10.0.2.101 port 123
57
do_cmd "0" null allow $i to 10.0.0.0/16 port 123
58
do_cmd "0" null allow $i to 10.0.2.0/24 port 123
59
do_cmd "0" null allow $i to 10.0.3.0/24 port 123
60
do_cmd "0" null allow $i to fe80::211:aaaa:bbbb:d54c port 123
62
do_cmd "0" null allow $i to 10.0.2.101 port 123 proto udp
63
do_cmd "0" null allow $i to 10.0.0.0/16 app OpenNTPD
64
do_cmd "0" null allow $i to 10.0.2.0/24 port 123 proto udp
65
do_cmd "0" null allow $i to 10.0.3.0/24 port 123 proto udp
66
do_cmd "0" null allow $i to fe80::211:aaaa:bbbb:d54c port 123 proto udp
68
do_cmd "0" null allow $i to 10.0.2.101 port 123 proto tcp
69
do_cmd "0" null allow $i to 10.0.0.0/16 port 123 proto tcp
70
do_cmd "0" null allow $i to 10.0.2.0/24 port 123 proto tcp
71
do_cmd "0" null allow $i to 10.0.3.0/24 port 123 proto tcp
72
do_cmd "0" null allow $i to fe80::211:aaaa:bbbb:d54c port 123 proto tcp
75
do_cmd "0" show listening