~ubuntu-branches/ubuntu/trusty/ufw/trusty-proposed

« back to all changes in this revision

Viewing changes to tests/check-requirements

  • Committer: Package Import Robot
  • Author(s): Jamie Strandboge
  • Date: 2012-08-17 14:32:01 UTC
  • mfrom: (30.1.15)
  • Revision ID: package-import@ubuntu.com-20120817143201-xj33z2za9mvzpw2k
Tags: 0.33-0ubuntu1
* New upstream release. Fixes the following bugs:
  - also use correct ports for DHCPv6. Thanks to Marco Davids (LP: #1007326)
  - add IPv6 limit support (LP: #951462)
  - add zh_TW translation (LP: #868195)
  - add 'show added' report (LP: #987784)
  - remove ACCEPT_NO_TRACK option since it never worked (LP: #787955)
* debian/(after|before)6.rules.md5sum: adjust for recently missed shipped
  configurations

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
# check-requirements: verify all the required iptables functionality is
4
4
# available
5
5
#
6
 
# Copyright 2008-2011 Canonical Ltd.
 
6
# Copyright 2008-2012 Canonical Ltd.
7
7
#
8
8
#    This program is free software: you can redistribute it and/or modify
9
9
#    it under the terms of the GNU General Public License version 3,
21
21
 
22
22
chain="ufw-check-requirements"
23
23
error=""
 
24
error_runtime=""
24
25
 
25
26
runcmd() {
 
27
    runtime="no"
 
28
    if [ "$1" = "runtime" ]; then
 
29
        runtime="yes"
 
30
        shift 1
 
31
    fi
26
32
    if $@ >/dev/null 2>&1 ; then
27
33
        echo pass
28
34
    else
29
 
        echo FAIL
30
 
        error="yes"
 
35
        if [ "$runtime" = "yes" ]; then
 
36
            echo "FAIL (no runtime support)"
 
37
            error_runtime="yes"
 
38
        else
 
39
            echo FAIL
 
40
            error="yes"
 
41
        fi
31
42
    fi
32
43
}
33
44
 
34
45
# check python
35
46
found_python="no"
36
47
echo -n "Has python: "
37
 
for exe in python2.7 python2.6 python2.5 python; do
 
48
for exe in python2.7 python2.6 python2.5 python3.2 python; do
38
49
    if ! which $exe >/dev/null 2>&1; then
39
50
        continue
40
51
    fi
41
52
    v=`$exe --version 2>&1 | cut -f 2 -d ' '`
42
53
    if echo "$v" | grep -q "^2.[567]"; then
43
 
        echo "pass (binary: $exe, version: $v)"
 
54
        echo "pass (binary: $exe, version: $v, py2)"
 
55
        found_python="yes"
 
56
        break
 
57
    elif echo "$v" | grep -q "^3.[2]"; then
 
58
        echo "pass (binary: $exe, version: $v, py3)"
44
59
        found_python="yes"
45
60
        break
46
61
    fi
163
178
    done
164
179
 
165
180
    echo -n "state (new, recent set): "
166
 
    if [ "$i" = "6" ]; then
167
 
        echo "skipped -- IPv6 'limit' not supported by ufw yet"
168
 
    else
169
 
        runcmd $exe -A $c -m state --state NEW -m recent --set
170
 
    fi
 
181
    runcmd runtime $exe -A $c -m state --state NEW -m recent --set
171
182
 
172
183
    echo -n "state (new, recent update): "
173
 
    if [ "$i" = "6" ]; then
174
 
        echo "skipped -- IPv6 'limit' not supported by ufw yet"
175
 
    else
176
 
        runcmd $exe -A $c -m state --state NEW -m recent --update --seconds 30 --hitcount 6 -j ACCEPT
177
 
    fi
 
184
    runcmd runtime $exe -A $c -m state --state NEW -m recent --update --seconds 30 --hitcount 6 -j ACCEPT
178
185
 
179
186
    echo -n "state (new, limit): "
180
187
    runcmd $exe -A $c -m state --state NEW -m limit --limit 3/min --limit-burst 10 -j ACCEPT
238
245
    }
239
246
done
240
247
 
241
 
if [ -n "$error" ]; then
242
 
    echo "FAIL: check your kernel and that you have iptables >= 1.4.0"
 
248
if [ -n "$error" ] || [ -n "$error_runtime" ]; then
 
249
    if [ -n "$error" ]; then
 
250
        echo "FAIL: check your kernel and that you have iptables >= 1.4.0"
 
251
    fi
 
252
    if [ -n "$error_runtime" ]; then
 
253
        echo "FAIL: check your kernel and iptables for additional runtime support"
 
254
    fi
243
255
    exit 1
244
256
fi
245
257
echo "All tests passed"