Return to BSD News archive
Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!nntp.coast.net!howland.reston.ans.net!EU.net!main.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: 26 Jun 1996 09:39:06 GMT Organization: interface business GmbH, Dresden Lines: 102 Message-ID: <4qr0fq$c51@innocence.interface-business.de> References: <4qd7bd$3m8@natasha.rmii.com> <4qe31l$ha5@innocence.interface-business.de> <4qnjmn$rku@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:22157 comp.unix.bsd.misc:1165 tjacobs@vaultbbs.com (Thomas R. Jacobs, Jr.) wrote: > I saw in another message that you also have a script for dynamic ppp > that makes use of the minor number of the device for the IP address. I don't have this one handy, but here's one that picks the users out of /etc/sliphome/slip.hosts. It should be easy to modify it to use the minor tty # instead. (As a side-effect, it will become much simpler.) #!/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