/mandos/release

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/release

« back to all changes in this revision

Viewing changes to network-hooks.d/bridge

* Makefile (run-client): Add "--network-hook-dir" option.
* plugin-runner.c (main): Only try to work around Debian bug #633582
                          if started as root.
* plugins.d/mandos-client.c (run_network_hooks): Bug fix: Run all
                                                 network hooks, not
                                                 just the first one.
                                                 Also add debug output.
  (main): Only try to work around Debian bug #633582 or run network
          hooks as root if started as root.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
CONFIG="$MANDOSNETHOOKDIR/bridge.conf"
17
17
 
18
 
addrtoif(){
19
 
    grep -liFe "$1" /sys/class/net/*/address \
20
 
        | sed -e 's,.*/\([^/]*\)/[^/]*,\1,'
21
 
}
22
 
 
23
 
# Read config file, which must set "BRIDGE", "PORT_ADDRESSES", and
24
 
# optionally "IPADDRS" and "ROUTES".
 
18
# Read config file, which must set "BRIDGE", "PORTS", and optionally
 
19
# "IPADDRS" and "ROUTES".
25
20
if [ -e "$CONFIG" ]; then
26
21
    . "$CONFIG"
27
22
fi
28
23
 
29
 
if [ -z "$BRIDGE" -o -z "$PORT_ADDRESSES" ]; then
 
24
if [ -z "$BRIDGE" -o -z "$PORTS" ]; then
30
25
    exit
31
26
fi
32
27
 
34
29
    exit
35
30
fi
36
31
 
37
 
for b in /sbin/brctl /usr/sbin/brctl; do
38
 
    if [ -e "$b" ]; then
39
 
        brctl="$b"
40
 
        break
41
 
    fi
42
 
done
43
 
 
44
32
case "$1" in
45
33
    start)
46
 
        "$brctl" addbr "$BRIDGE"
47
 
        for address in $PORT_ADDRESSES; do
48
 
            interface=`addrtoif "$address"`
49
 
            "$brctl" addif "$BRIDGE" "$interface"
50
 
            ip link set dev "$interface" up
 
34
        brctl addbr "$BRIDGE"
 
35
        for port in $PORTS; do
 
36
            brctl addif "$BRIDGE" "$port"
51
37
        done
52
 
        ip link set dev "$BRIDGE" up
53
 
        sleep "$DELAY"
 
38
        ip link set up "$BRIDGE"
54
39
        if [ -n "$IPADDRS" ]; then
55
40
            for ipaddr in $IPADDRS; do
56
41
                ip addr add "$ipaddr" dev "$BRIDGE"
63
48
        fi
64
49
        ;;
65
50
    stop)
66
 
        ip link set dev "$BRIDGE" down
67
 
        for address in $PORT_ADDRESSES; do
68
 
            interface=`addrtoif "$address"`
69
 
            ip link set dev "$interface" down
70
 
            "$brctl" delif "$BRIDGE" "$interface"
 
51
        ip link set down "$BRIDGE"
 
52
        for port in $PORTS; do
 
53
            brctl delif "$BRIDGE" "$port"
71
54
        done
72
 
        "$brctl" delbr "$BRIDGE"
 
55
        brctl delbr "$BRIDGE"
73
56
        ;;
74
57
    files)
75
58
        echo /bin/ip
76
 
        echo "$brctl"
77
 
        ;;
78
 
    modules)
79
 
        echo bridge
 
59
        echo /usr/bin/brctl
80
60
        ;;
81
61
esac