Return to BSD News archive
Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!news.mira.net.au!vic.news.telstra.net!act.news.telstra.net!psgrain!news.uoregon.edu!newsfeed.internetmci.com!howland.reston.ans.net!Germany.EU.net!Dortmund.Germany.EU.net!interface-business.de!usenet
From: j@ida.interface-business.de (J Wunsch)
Newsgroups: comp.unix.bsd.freebsd.misc,comp.unix.bsd.misc
Subject: Re: Setting up a PPP server for FreeBSD
Date: 21 Jun 1996 12:03:01 GMT
Organization: interface business GmbH, Dresden
Lines: 105
Message-ID: <4qe31l$ha5@innocence.interface-business.de>
References: <4qd7bd$3m8@natasha.rmii.com>
Reply-To: joerg_wunsch@interface-business.de (Joerg Wunsch)
NNTP-Posting-Host: ida.interface-business.de
X-Newsreader: knews 0.9.6
X-Phone: +49-351-31809-14
X-Fax: +49-351-3361187
X-PGP-Fingerprint: DC 47 E6 E4 FF A6 E9 8F 93 21 E0 7D F9 12 D6 4E
Xref: euryale.cc.adfa.oz.au comp.unix.bsd.freebsd.misc:21845 comp.unix.bsd.misc:1148
tjacobs@vaultbbs.com (Thomas R. Jacobs, Jr.) wrote:
> I have found lots of documentation on getting user PPP set up, but not
> a whole lot on setting up a PPP server. The bit I did see that looked
> the most promising would require that I replace getty in ttys with
> ppp. I can't do this because, I still need to be able to use the
> dialin ports for shell logins and SLIP. The other method I saw used a
> ppplogin script. I have not been able to get that to work at all.
Here's mine. As you can see, it uses /etc/sliphome/slip.hosts in its
native format, so it can share its client database with SLIP. The
script is setuid root and runnable by group ppp only.
#!/usr/bin/suidperl
#
#
# login script for PPP logins
#
$ENV{'PATH'} = "/bin:/usr/bin:/sbin:/usr/sbin";
#
# Q: how to check if the fork succeeded?
# A: ask Larry Wall :-/
#
open(LOG, "|-") || exec "logger", "-p", "local0.debug";
if(open(SLHOST, "/etc/sliphome/slip.hosts") == 0) {
print LOG "Cannot open /etc/sliphome/slip.hosts\n";
close LOG;
exit 1;
}
if(!defined($ENV{'USER'})) {
print LOG "PPP login with unknown \${USER}\n";
close LOG;
exit 1;
}
$user = $ENV{'USER'};
$sluser = $user;
$sluser =~ s/^pp/sl/;
while(<SLHOST>) {
next if /^([ \t]*\#.*)?$/;
($login,$local,$remote,$mask,$optargs) = split;
last if $login eq $sluser;
}
close(SLHOST);
if($local eq "" || $remote eq "" || $mask eq "" || $login ne $sluser) {
print LOG "PPP login for user $user, required information not found\n";
close LOG;
exit 1;
}
print LOG "$user ($sluser/$login) attached, $local -> $remote, mask $mask\n";
$local = &convaddr($local);
$remote = &convaddr($remote);
$mask = &convaddr($mask);
print LOG "$user attached, $local -> $remote, mask $mask\n";
close LOG;
exec "pppd", "crtscts", "modem",
"$local:$remote", "netmask", "$mask";
# should not be reached at all
open(LOG, "|-") || exec "logger", "-p", "local0.debug";
print LOG "exec of pppd failed for user $user\n";
close(LOG);
exit 2;
#
# convert address to dotted quad
#
sub convaddr
{
local($input) = @_;
local($ip,$a,$b,$c,$d);
# return if already dotted quad
return $input if $input =~ /^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/;
if($input =~ /^0[xX]/) {
$ip = oct($input);
return sprintf("%d.%d.%d.%d", ($ip >> 24) & 0xff,
($ip >> 16) & 0xff, ($ip >> 8) & 0xff,
$ip & 0xff);
}
# neither dotted quad, nor hex number, ask the name server
($name,$aliases,$addrtype,$length,$addr) = gethostbyname($input);
($a,$b,$c,$d) = unpack("C4",$addr);
return "$a.$b.$c.$d";
}
--
J"org Wunsch Unix support engineer
joerg_wunsch@interface-business.de http://www.interface-business.de/~j