/mandos/trunk

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

« back to all changes in this revision

Viewing changes to network-hooks.d/openvpn

  • Committer: Teddy Hogeborn
  • Date: 2012-06-13 22:06:57 UTC
  • mto: This revision was merged to the branch mainline in revision 596.
  • Revision ID: teddy@recompile.se-20120613220657-qvq7c7nrndl3t413
* plugins.d/mandos-client.c (get_flags): Don't clobber errno.
  (up_interface): Removed; replaced with "interface_is_up".
  (interface_is_up, interface_is_running,
   lower_privileges_permanently, take_down_interface): New.
  (bring_up_interface): Return "error_t".  Use new functions
                        "interface_is_up", "get_flags", and
                        "interface_is_running".
  (main): Save all interfaces either autodetected or specified with
          --interface in argz vector "interfaces".  Save interfaces to
          take down on exit in argz vector "interfaces_to_take_down".
          Save interface names for DEVICE variable to network hooks as
          argz_vector "interfaces_hooks".  Bug fix: Be privileged
          while stopping network hooks.
* plugins.d/mandos-client.xml (SYNOPSIS): Changed --interface synopsis.
  (DESCRIPTION): Updated to document use of all interfaces.
  (OPTIONS): Updated description of "--interface".
* network-hooks.d/bridge: Parse comma-separated DEVICE environment
                          variable.
* network-hooks.d/openvpn: - '' -
* network-hooks.d/wireless: - '' -

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
# configuration file(s) should be copied into the
7
7
# /etc/mandos/network-hooks.d directory.
8
8
 
9
# Copyright © 2012 Teddy Hogeborn
 
10
# Copyright © 2012 Björn Påhlsson
 
11
9
12
# Copying and distribution of this file, with or without modification,
10
13
# are permitted in any medium without royalty provided the copyright
11
14
# notice and this notice are preserved.  This file is offered as-is,
28
31
fi
29
32
 
30
33
# Exit if DEVICE is set and it doesn't match the VPN interface
31
 
if [ -n "$DEVICE" -a "$DEVICE" = "${DEVICE#$VPNDEVICE}" ]; then
32
 
    exit
 
34
if [ -n "$DEVICE" ]; then
 
35
    case "$DEVICE" in
 
36
        *,"$VPNDEVICE"*|"$VPNDEVICE"*) :;;
 
37
        *) exit;;
 
38
    esac
33
39
fi
34
40
 
35
41
openvpn=/usr/sbin/openvpn
36
42
 
37
 
case "$1" in
38
 
    start)
39
 
        "$openvpn" --cd "$MANDOSNETHOOKDIR" \
40
 
            --daemon 'openvpn(Mandos)' --writepid "$PIDFILE" \
41
 
            --config "$CONFIG"
42
 
        sleep "$DELAY"
43
 
        ;;
44
 
    stop)
45
 
        PID="`cat \"$PIDFILE\"`"
46
 
        if [ "$PID" -gt 0 ]; then
47
 
            kill "$PID"
48
 
        fi
 
43
do_start(){
 
44
    "$openvpn" --cd "$MANDOSNETHOOKDIR" --daemon 'openvpn(Mandos)' \
 
45
        --writepid "$PIDFILE" --config "$CONFIG"
 
46
     sleep "$DELAY"
 
47
}
 
48
 
 
49
do_stop(){
 
50
    PID="`cat \"$PIDFILE\"`"
 
51
    if [ "$PID" -gt 0 ]; then
 
52
        kill "$PID"
 
53
    fi
 
54
}
 
55
 
 
56
case "${MODE:-$1}" in
 
57
    start|stop)
 
58
        do_"${MODE:-$1}"
49
59
        ;;
50
60
    files)
51
61
        echo "$openvpn"