summaryrefslogtreecommitdiffabout
path: root/vpn/svpnsh
blob: 35f4eb1ed4366be910503ab7fe44e97d816916aa (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, 2009 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 svpnsh -p auth.$prio $*
}

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

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

sdup=`who -q | sed '/^#/d' | tr -s ' ' '\n' | sort | uniq -d | grep "$USER"` 

if [ -n "$sdup" ]
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.