summaryrefslogtreecommitdiffabout
path: root/vpn/svpnsh
blob: 0185fc28b64d3e94478160a94e77e5cce2b10c48 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#! /bin/sh
# svpnsh -- a simple vpn-only shell
# Copyright (C) 2007 Sergey Poznyakoff
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

PAIR=`sed -n "s/^${USER%%+vpn}=\([0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}:[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\).*/\1/p" /usr/local/etc/vpn.conf`

logmsg() {
  prio=$1
  shift
  /usr/bin/logger -t vpnsh -p auth.$prio $*
}

logmsg debug "USER=$USER, PAIR=$PAIR"

if [ -z "$PAIR" ]; then
   logmsg notice "$USER: access denied"
   exit 1
fi

NLOGINS=`who -q | sed '2,$d' | tr ' ' '\n' | sort | sed '1d' | uniq -c |
          awk "\\$2==\"$USER\" { print \\$1 }"` 
if [ ${NLOGINS:-0} -gt 1 ]
then 
   logmsg notice "$USER: too many concurrent logins"
   exit 1
fi

logmsg notice "$USER: starting ppp"
sudo /usr/sbin/pppd nodetach notty noauth $PAIR

# End of svpnsh

Return to:

Send suggestions and report system problems to the System administrator.