diff options
author | Gabor Kovesdan <gabor@FreeBSD.org> | 2007-02-26 18:57:31 +0000 |
---|---|---|
committer | Gabor Kovesdan <gabor@FreeBSD.org> | 2007-02-26 18:57:31 +0000 |
commit | 1f33792bee3e471cfc6cd140b6b83514adac1b45 (patch) | |
tree | d36bb5ac6351b5c713e6de9928920bd8a57ebb72 /security | |
parent | 0791e78a3641b8973ed5184132d1e5a53cad0080 (diff) | |
download | ports-1f33792bee3e471cfc6cd140b6b83514adac1b45.tar.gz ports-1f33792bee3e471cfc6cd140b6b83514adac1b45.zip |
Notes
Diffstat (limited to 'security')
-rw-r--r-- | security/vpnc/Makefile | 10 | ||||
-rw-r--r-- | security/vpnc/files/vpnc.in | 95 | ||||
-rw-r--r-- | security/vpnc/files/vpnc.sh | 29 |
3 files changed, 99 insertions, 35 deletions
diff --git a/security/vpnc/Makefile b/security/vpnc/Makefile index 5dda87bbd806..ad67b9d7c003 100644 --- a/security/vpnc/Makefile +++ b/security/vpnc/Makefile @@ -7,7 +7,7 @@ PORTNAME= vpnc PORTVERSION= 0.3.3 -PORTREVISION= 3 +PORTREVISION= 4 CATEGORIES= security MASTER_SITES= http://www.unix-ag.uni-kl.de/~massar/vpnc/ @@ -19,11 +19,12 @@ LIB_DEPENDS= gcrypt.13:${PORTSDIR}/security/libgcrypt USE_GMAKE= yes ALL_TARGET= vpnc +USE_RC_SUBR= vpnc + PLIST_FILES= sbin/vpnc \ sbin/vpnc-script \ sbin/vpnc-disconnect \ - etc/vpnc.conf.sample \ - etc/rc.d/vpnc.sh.sample + etc/vpnc.conf.sample PORTDOCS= README ChangeLog TODO MAN8= vpnc.8 @@ -41,9 +42,6 @@ do-install: @${INSTALL_PROGRAM} -m 751 ${WRKSRC}/vpnc ${PREFIX}/sbin/vpnc @${INSTALL_SCRIPT} -m 751 ${WRKSRC}/vpnc-script ${PREFIX}/sbin/vpnc-script @${INSTALL_SCRIPT} -m 751 ${WRKSRC}/vpnc-disconnect ${PREFIX}/sbin/vpnc-disconnect - @${INSTALL_SCRIPT} ${FILESDIR}/vpnc.sh ${WRKDIR} - @${REINPLACE_CMD} -e 's|%%PREFIX%%|${PREFIX}|' ${WRKDIR}/vpnc.sh - @${INSTALL_SCRIPT} -m 755 ${WRKDIR}/vpnc.sh ${PREFIX}/etc/rc.d/vpnc.sh.sample @${INSTALL_DATA} -m 600 ${WRKSRC}/vpnc.conf ${PREFIX}/etc/vpnc.conf.sample .if !defined(NO_INSTALL_MANPAGES) @${REINPLACE_CMD} -e 's|%%PREFIX%%|${PREFIX}|' ${WRKSRC}/vpnc.8 diff --git a/security/vpnc/files/vpnc.in b/security/vpnc/files/vpnc.in new file mode 100644 index 000000000000..edc19820a1a4 --- /dev/null +++ b/security/vpnc/files/vpnc.in @@ -0,0 +1,95 @@ +#!/bin/sh +# +# Author: kamikaze +# Contact: LoN_Kamikaze@gmx.de +# +# If vpnc_conf is defined, it will be treated as a list of configuration files +# in vpnc_conf_dir. This managed mode is useful where where vpnc tunnels have +# to be established through other vpnc tunnels. +# + +# PROVIDE: vpnc +# REQUIRE: NETWORKING +# KEYWORD: FreeBSD shutdown + +# Default settings - don't change this. +: ${vpnc_enable="NO"} +: ${vpnc_conf=""} +: ${vpnc_pid_dir="/var/run"} +: ${vpnc_conf_dir="%%PREFIX%%/etc"} +: ${vpnc_flags=""} +: ${vpnc_record="$vpnc_pid_dir/vpnc.record"} + +. /etc/rc.subr + +name="vpnc" +rcvar=`set_rcvar` + +command="%%PREFIX%%/sbin/$name" + +vpnc_start() { + if [ "$vpnc_conf" ]; then + # A list of configurations is present. Connect managing + # what is required for a clean shutdown later. + for config in $vpnc_conf; { + # The current configuration file. + current="$vpnc_conf_dir/$config" + # Start vpnc. + $command $current $vpnc_flags + + # Give up on errors. + status=$? + if [ $status -ne 0 ]; then + echo "Running 'vpnc $current $vpnc_flags' failed." + return $status + fi + + # Move files to allow a clean shutdown + # of multiple connections. + /bin/mv "$vpnc_pid_dir/vpnc.pid" "$vpnc_pid_dir/vpnc.$config.pid" + /bin/mv "$vpnc_pid_dir/vpnc.defaultroute" "$vpnc_pid_dir/vpnc.$config.defaultroute" 2> /dev/null + /bin/mv "$vpnc_pid_dir/vpnc.resolv.conf-backup" "$vpnc_pid_dir/vpnc.$config.resolv.conf-backup" 2> /dev/null + echo "$config" >> "$vpnc_record" + + # Wait for the system to catch up. + /bin/sleep 1 + } + else + # No configuration files given, run unmanaged. + $command $vpnc_flags + return $? + fi +} + +vpnc_stop() { + if [ -e "$vpnc_record" ]; then + # A record of vpnc connections is present. Attempt a + # managed shutdown. + for config in `/usr/bin/tail -r "$vpnc_record"`; { + # Wait to give the system a chance to catch up with + # recent changes. + /bin/sleep 1 + + # Move the vpnc files back into position. + /bin/mv "$vpnc_pid_dir/vpnc.$config.pid" "$vpnc_pid_dir/vpnc.pid" + /bin/mv "$vpnc_pid_dir/vpnc.$config.defaultroute" "$vpnc_pid_dir/vpnc.defaultroute" 2> /dev/null + /bin/mv "$vpnc_pid_dir/vpnc.$config.resolv.conf-backup" "$vpnc_pid_dir/vpnc.resolv.conf-backup" 2> /dev/null + + # Run the disconnect command. + $command-disconnect + } + # Remove the connection record. + /bin/rm "$vpnc_record" + else + /bin/sleep 1 + # There's no record of connections, asume unmanaged shutdown. + $command-disconnect + return $? + fi +} + +start_cmd=vpnc_start +stop_cmd=vpnc_stop + +load_rc_config $name +run_rc_command "$1" diff --git a/security/vpnc/files/vpnc.sh b/security/vpnc/files/vpnc.sh deleted file mode 100644 index 031d2ed3917d..000000000000 --- a/security/vpnc/files/vpnc.sh +++ /dev/null @@ -1,29 +0,0 @@ -#! /bin/sh - -PREFIX=%%PREFIX%% -PIDFILE=/var/run/vpnc.pid - -# change these variables and activate comments -# below to get a full tunnel -VPNGATEWAY=vpn.rwth-aachen.de -ROUTER=192.168.111.2 - -case "$1" in -start) - [ -x ${PREFIX}/sbin/vpnc ] && ${PREFIX}/sbin/vpnc --pid-file ${PIDFILE} && - # route add -host ${VPNGATEWAY} ${ROUTER} - # route delete default && - # route add default -interface tun0 && - echo -n ' vpnc' - ;; -stop) - kill `cat ${PIDFILE}` - # route delete default && - # route add default ${ROUTER} - ;; -*) - echo "Usage: `basename $0` {start|stop}" >&2 - ;; -esac - -exit 0 |