#!/usr/bin/suidperl -w # # Copyright (C) 1998, 1999 Raju Mathur (raju@sgi.com) # All right reserved under the terms of the GNU General Public License (GPL) # Version 2 or a later version. # # Version 2.0, 1999/04/07 # use POSIX 'getuid' , 'geteuid' , 'setuid' ; # # XXXXXX Edit these parameters! # # add VSNL phone numbers here ("3334000" , "3363500") etc. @phones = ( "VSNL-PHONE-1" , "VSNL-PHONE-2" ) ; # # Which port do you use: ttyS0 == COM1, ttyS1 == COM2, etc. $port = "ttyS0" ; # # Do you use [P]ulse or [T]one dialing? $dialtype = "T" ; # # Any special setup strings for your modem? Give just the string, # DO NOT give the AT prefix here! E.g. If you need to send AT+FOO, # just give "+FOO" here. $specialstring = "" ; # # Your userID and password as you have to enter it at the VSNL prompt $userID = "my-complete-user-id" ; $password = "my-password" ; $PPPcmd = "ppp" ; # # What does your ISP prompt you with for entering your username and password? # The last few characters are enough. Currently configured for VSNL Delhi's # prompts... your ISP may prompt with "ogin: " instead of "name: ". # Also select what your ISP prompts you with after you login successfully # and before you type in "PPP". # # (Hint for VSNL Delhi users: You might like to change the pppprompt to # a simple Control-M (Carriage Return) [type Control-V Control-M in place # of the > sign] so that your script works on both the old (> prompt) # and new (no prompt) numbers.) # $usernameprompt = "name: " ; $passwordprompt = "word: " ; $pppprompt = ">" ; # # XXXXXX End user-editable section! # # Intrepid users may edit these modem-specific options. YOU ARE ON YOUR # OWN IF YOU DO THIS! # $S7 = 60 ; # Wait n seconds for carrier after dialing $S10 = 100 ; # Wait n/10 seconds without carrier before dropping connect $S11 = 30 ; # Wait n/100 seconds between tones when DTMF dialing $MinusV = "-v" ; # Add one or more -v's to chat to make it verbose $ABORT1 = "BUSY" ; $ABORT2 = "'NO CARRIER'" ; $ABORT3 = "'NO DIALTONE'" ; $ABORT4 = "ERROR" ; $ABORT5 = "" ; $ABORT6 = "" ; # Huh? How many abort strings do you need anyway? # # END OF EDITABLE SECTION FOR INTREPID USERS! # # START PROGRAM. Don't look below this unless you're a Perl freak. # # Build up chat script # $ChatScript = " $MinusV " ; # # Add abort strings # $ChatScript .= "ABORT $ABORT1 " if defined $ABORT1 && $ABORT1 ne "" ; $ChatScript .= "ABORT $ABORT2 " if defined $ABORT2 && $ABORT2 ne "" ; $ChatScript .= "ABORT $ABORT3 " if defined $ABORT3 && $ABORT3 ne "" ; $ChatScript .= "ABORT $ABORT4 " if defined $ABORT4 && $ABORT4 ne "" ; $ChatScript .= "ABORT $ABORT5 " if defined $ABORT5 && $ABORT5 ne "" ; $ChatScript .= "ABORT $ABORT6 " if defined $ABORT6 && $ABORT6 ne "" ; # # Set speed and reset modem (first AT sets speed on most modems) # $ChatScript .= "'' AT OK ATZ OK " ; $ChatScript .= "AT" ; # # Setup S-registers # $ChatScript .= "S7=$S7" if defined $S7 && $S7 ne "" ; $ChatScript .= "S10=$S10" if defined $S10 && $S10 ne "" ; $ChatScript .= "S11=$S11" if defined $S11 && $S11 ne "" ; $ChatScript .= " OK " ; # # Setup any special string the user may have specified. # $ChatScript .= "'AT$specialstring' OK " if length $specialstring ; # # Add any special modem setup strings user may have given on cmdline # IMPORTANT: These HAVE to be escaped. # foreach $arg (@ARGV) { $ChatScript .= "'AT$arg' OK " ; } $ENV{'PATH'}="/usr/bin:/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin" ; unlink "/tmp/STOP.PPP" ; while ( ! -e "/tmp/STOP.PPP" ) { foreach $phone ( @phones ) { if ( -e "/tmp/STOP.PPP" ) { last ; } if ( fork () == 0 ) { setuid ( 0 ) ; exec "/usr/sbin/pppd" , "$port" , "115200" , "lock" , "-detach" , "crtscts" , "defaultroute" , "mru" , "1500" , "mtu" , "1500" , "ipcp-accept-local" , "ipcp-accept-remote" , "noipdefault" , # # Uncomment the following two lines if you want debugging output. # The output will probably be in /var/log/messages. Remove the initial "#" # to enable debugging. # "debug" , "debug" , "file" , "/etc/ppp/options" , "modem" , "connect" , "chat $ChatScript ATD$dialtype$phone CONNECT '' '\\q$usernameprompt' '$userID' '$passwordprompt' '$password' '$pppprompt' '$PPPcmd'" ; } else { wait ; } } sleep 3 ; }