summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ppp/chat.c
Commit message (Collapse)AuthorAgeFilesLines
* Set the close-on-exec flag for all unused descriptors whenbrian1999-08-171-9/+10
| | | | exec()ing other programs.
* Don't bother read()ing if we ``expect'' nothing in our chat script.brian1999-06-261-2/+2
|
* If we run out of chat script immediately after a successfully executedbrian1999-06-261-2/+6
| | | | | | | expect-send-expect sequence, finish gracefully, don't core dump. This bug has been there for over a year - I could never reproduce it ! Straw provided by: Andre Albsmeier <andre.albsmeier@mchp.siemens.de>
* Use the correct pid when substituting PROCESSID.brian1999-06-091-2/+2
| | | | Problem reported by: Amedeo Beck Peccoz <gea@gressoney.it>
* Add some comments, optimise out a few strlen()s andbrian1999-05-271-16/+23
| | | | remove a few extraneous assignments.
* o Redesign the layering mechanism and make the aliasing code part ofbrian1999-05-081-60/+5
| | | | | | | | | | | | | | | | | | | | | the layering. We now ``stack'' layers as soon as we open the device (when we figure out what we're dealing with). A static set of `dispatch' routines are also declared for dealing with incoming packets after they've been `pulled' up through the stacked layers. Physical devices are now assigned handlers based on the device type when they're opened. For the moment there are three device types; ttys, execs and tcps. o Increment version number to 2.2 o Make an entry in [uw]tmp for non-tty -direct invocations (after pap/chap authentication). o Make throughput counters quad_t's o Account for the absolute number of mbuf malloc()s and free()s in ``show mem''. o ``show modem'' becomes ``show physical''.
* When executing a command as part of a dial/login/hangupbrian1999-02-121-6/+9
| | | | script, expand words in the same way as !bg does.
* Initial RADIUS support (using libradius). See the man page forbrian1999-01-281-2/+5
| | | | | | | | | | | | | | | | | | | details. Compiling with -DNORADIUS (the default for `release') removes support. TODO: The functionality in libradius::rad_send_request() needs to be supplied as a set of routines so that ppp doesn't have to wait indefinitely for the radius server(s). Instead, we need to get a descriptor back, select() on the descriptor, and ask libradius to service it when necessary. For now, ppp blocks SIGALRM while in rad_send_request(), so it misses PAP/CHAP retries & timeouts if they occur. Only PAP is functional. When CHAP is attempted, libradius complains that no User-Password has been specified... rfc2138 says that it *mustn't* be used for CHAP :-( Sponsored by: Internet Business Solutions Ltd., Switzerland
* Untimeout the chat expect timer as soon as we get abrian1998-10-271-1/+2
| | | | | | match - otherwise, with a delayed (\\d) ``send'', the timeout may happen during the send and cause a failure. Problem reported by: David L. Vondrasek <dallas.tx@airmail.net>
* o Support callback types NONE, E.164, AUTH and CBCP.brian1998-08-071-4/+7
| | | | | | | | | | | | | | (see the new ``set callback'' and ``set cbcp'' commands) o Add a ``cbcp'' log level and mbuf type. o Don't dump core when \T is given in ``set login'' or ``set hangup''. o Allow ``*'' and blanks as placeholders in ppp.secret and allow a fifth field for specifying auth/cbcp dialback parameters. o Remove a few extraneous #includes o Define the default number of REQs (restart counter) in defs.h rather than hardcoding ``5'' all over the place. o Fix a few man page inconsistencies.
* Remove redundant includesbrian1998-06-271-2/+1
|
* o If we come out of select() with only write descriptors thatbrian1998-06-241-2/+6
| | | | | | | | | | | end up writing zero bytes, sleep for 1/10 of a second so that we don't end up using up too much cpu. This should only ever happen on systems that wrongly report a descriptor as writable despite the tty buffer being full. Discussed with: Jeff Evarts o Do an initial run-time check to see if select() alters the passed timeval. This knowledge isn't yet used, but will be soon.
* o De-staticise things that don't need to be static.brian1998-06-151-2/+2
| | | | | | | | | | o Bring the static ``ttystate'' into struct prompt so that the tilde context is per prompt and not global. o Comment the remaining static variables so that it's clear why they're static. o Add some XXX comments suggesting that our interface list and our hostname should be re-generated after a signal (say SIGUSR1) so that a machine with PCCARDs has a chance.
* o #define the name "tun" in defs.h against the future possibilitybrian1998-05-281-2/+2
| | | | | | | | | | | | | | | | | | | | | | of supporting architectures with different device names. o Close /dev/tunX when destroying the bundle. o Don't forget to close the parent end of the pipe in the child process when exec'ing a program from a chat script. o If we close our controlling terminal, ditch the current session with it, allowing getty(8) (or whatever) to regain control. o After transferring our controlling terminal descriptor to another ppp instance, we now fork a new ppp to continue where we left off, transferring ownership of all uucp locks and the /var/run/tunX.pid file. Meanwhile the parent closes all file descriptors, defaults all signals and does a pause() to wait for a HUP after the transferred descriptor is finally closed. We don't run /bin/cat any more (again!). Suggested by: bde TODO: It seems clocal devices need their pause()d session leader to be given a manual HUP, as closing the last open descriptor doesn't do the job.
* o Move our prompt descriptor list outside of the bundle.brian1998-05-231-2/+1
| | | | | | | | | | | | | | | | | | | | It's now dealt with by the `server' object. This simplifies things as we only have one list of prompt descriptors and the log_ routines check prompt::logactive to determine whether it should be used for output. o Include the MP socket UpdateSet() result in bundle::UpdateSet(). o Don't select on the tun device unless we're in NETWORK phase or AUTO mode. o Stop the idle timer when we go to DEAD phase. We may have transferred a link and not had a chance to kill it. o Don't fail when trying to unlink our transferred datalink from our descriptor lists just before the transfer. o Add our link descriptor to the write set if we got a short write the last time (physical::out is set). o Log the connection source address when a connection is closed. o Remove descriptor::next field. Descriptor lists are not required any more.
* MFMP: Make ppp multilink capable.brian1998-05-211-458/+572
| | | | See the file README.changes, and re-read the man page.
* Remove unused #includes.brian1998-01-211-4/+1
| | | | | | Make various bits static. Remove unused variables. Submitted by: eivind
* Allow (and document) execution of commands from withinbrian1997-12-271-85/+124
| | | | | our chat script. You can now even run chat(8) - see ppp.conf.sample.
* Cosmetic (style):brian1997-12-241-8/+8
| | | | | | | sizeof(var) -> sizeof var sizeof type -> sizeof(type) Suggested by: J Wunsch <j@uriah.heep.sax.de>
* strncpy(x,y,sizeof(x)) --> strncpy(x,y,sizeof(x)-1)brian1997-12-231-2/+2
| | | | | Suggested by: Philippe Charnier <charnier@lirmm.fr> Theo de Raadt <deraadt@cvs.openbsd.org>
* Replacebrian1997-12-181-2/+3
| | | | | | | | | | | | | strcpy(a, b); /* a and b are the same size */ with strncpy(a, b, sizeof(a)); a[sizeof(a)-1] = '\0'; Making the code `correct at a glance'. Suggested by: Theo de Raadt <deraadt@cvs.openbsd.org>
* Fix prototypes.brian1997-11-221-22/+23
| | | | | | | | | | | | | | Remove extraneous decls. Add ``const'' to several places. Allow ``make NOALIAS=1'' to remove IP aliasing. Merge with OpenBSD - only the Makefiles vary. We can now survive a compile with -Wall -Wbad-function-cast -Wcast-align -Wcast-qual -Winline -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-prototypes -Wwrite-strings -Wchar-subscripts (although the Makefile just contains -Wall).
* Increase chat script sizes to 512brian1997-11-091-4/+4
| | | | Requested by: Michael Reifenberger <root@totum.plaut.de>
* Introduce ID0 logging.brian1997-11-091-10/+2
| | | | | | | | Stay as the invoking uid as much as possible. Execution as a normal user is still forbidden for now, so these changes are pretty ineffective. The next commit will implement the modifications suggested on -hackers a number of days ago.
* o Bump version to 1.3 to reflect major changesbrian1997-10-291-4/+1
| | | | | | | | | | | | o Report modem connect time properly o Report bytes in/out over physical media o Fix phases (TERMINATE is *higher than* DEAD) o Do a LayerFinish from LcpDown o Bring down IPCP & CCP when we enter PHASE_TERMINATE o Give a new prompt when we go to PHASE_DEAD o Stop the modem timer properly when idle o Treat sig 15 like an exiting carrier loss o Log (DEBUG) offline & online transitions
* Cosmetic (no functional changes):brian1997-10-261-28/+37
| | | | | | | | | | | | | | | o Add missing $Id$s o Move extern decls from .c -> .h files o Staticize o Remove #includes from .h files o style(9)ify includes o bcopy -> memcpy bzero -> memset bcmp -> memcmp index -> strchr rindex -> strrchr o Move timeout.h -> timer.h (making it consistent w/ timer.c) o Add -Wmissing-prototypes
* sleep => nointr_sleepbrian1997-10-241-3/+3
| | | | | | usleep => nointr_usleep (not just a #define) Already done by: ache
* Cosmetic: Make LogPrintf() calls consistent.brian1997-08-311-26/+26
|
* Make the code format more in line with style(9).brian1997-08-251-75/+96
| | | | | Update loadalias to use the new libalias api. Update to version 1.1.
* Fix possible buffer overrun while "expect"ingbrian1997-08-171-6/+7
| | | | something that's "nearly" what it wants.
* Allow specification of fallback phone numbers tobrian1997-08-171-5/+8
| | | | | be used only if the dial script fails. PR: 4262
* Allow a "hangup" capability.brian1997-07-141-1/+4
| | | | | | You can now "ATZ" your modem when it's closed. Submitted by: peter@citylink.dinoex.sub.org (Peter Much)
* Make HUP cause an exit (as it used to), and makebrian1997-07-011-10/+4
| | | | | | | | | | INT cause a hangup - not exiting for -ddial & -auto. HUP must exit because init sends this at system shutdown time (why, I don't know), and we don't want to end up redialing after the HUP (due to another dfilter packet). Pointed out by and discussed with: ache
* o Fix uptime for direct connections.brian1997-06-231-28/+41
| | | | | | | | | | | | o Style police o Make hangup abort the current connection, not necessarily exiting (-auto/-ddial). o Trap HUP and INT during DoChat and abort the connection attempt. This means you can now type "dial" and change your mind with ^C, or HUP the process to stop it dialing. Slapped into doing it by: Chuck Robey <chuckr@glue.umd.edu>
* Overhaul ppp:brian1997-06-091-40/+28
| | | | | | | | | | | | | | | | | | | | | | | | | o Use syslog o Remove references to stdout/stderr (incl perror()) o Introduce VarTerm - the interactive terminal or zero o Allow "set timeout" to affect current session o Change "set debug" to "set log" o Allow "set log [+|-]flag" o Make MSEXT and PASSWDAUTH stuff the default o Move all #ifdef DEBUG stuff into the code - this shouldn't be too much overhead. It's now controlled with "set log +debug" o Add "set log command, debug, tun, warn, error, alert" o Remove cdefs.h, and assume an ansi compiler. o Improve all diagnostic output o Don't trap SIGSEGV o SIGHUP now terminates again (log files are controlled by syslog) o Call CloseModem() when changing devices o Fix parsing of third arg of "delete" I think this fixes the "magic is same" problems that some people have been experiencing. The man page is being rewritten. It'll follow soon.
* De-couple ppp from libalias. If libalias isn't there, thebrian1997-05-261-1/+6
| | | | | | | | | alias commands simply won't work. Only root may specify the location of the alias lib (otherwise, it's hard-coded). Make logprintf silently fail if LogOpen hasn't been called. Suggested by: eivind
* Tidy up the code - bounds checking, returnbrian1997-05-101-16/+34
| | | | | | value checking etc. Submitted by: eivind
* Allow up to 40 args in the chat script (was 20).brian1997-05-071-6/+10
| | | | | | | Ignore subsequent args rather than scribbling. PR: 1952 Submitted by: Mikael Hybsch <micke@free.dynas.se>
* Reviewed by: ache@freebsd.orgbrian1997-03-131-1/+4
| | | | | | | | These changes should fix the signal "problems" in ppp. The signal changes should really be put into 2.2 too ! The following patches should do it. There were some other changes made by Andrey recently that havn't been brought into 2.2, it may be worth doing them now.
* cdefs cleanupache1997-03-091-2/+1
|
* I remove pending signals completely, they are not useless, they areache1997-03-091-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | dangerous! Signal handlers themself must be fixed to not call malloc, but no pended handlers, it will be correct fix. In finite case each signal handler can set some variable which will be analized later, but calling handler functions manually is too dangerous (f.e. signals not blocked while the handler or handlers switch executed in this case). Of course this code can be fixed instead of removing, but it not worth fixing in any case. Should go into 2.2 In addition sig.c code shows following dangerous fragments (there can be more, but I stop after two): This fragment if (fn == SIG_DFL || fn == SIG_IGN) { handler[sig-1] = (sig_type)0; <------------- here signal(sig,fn); } else { cause NULL pointer reference when signal comes "here", but more worse fragment is below: void handle_signals() { int sig; if (caused) for (sig=0; sig<__MAXSIG; sig++, caused>>=1) if (caused&1) (*handler[sig])(sig+1); } caused is bitmask which set corresponding bit on each signal coming. And now imagine, what happens when some signal comes (bit sets) while loop is executed (see caused>>=1 !!!) In this light carrier drop situation was (as gdb shows) 1. SIGSEGV in handle_signals because some junk called as *handler reference. 2. Since SIGSEGV was pended too (== never happens), it can cause various range of disasters.
* Unpend all signals before execv, it not makes any sense to pend them hereache1997-03-081-2/+2
| | | | Should go into 2.2
* Unpend all killing signals to shut down this thing immediately,ache1997-03-081-4/+4
| | | | | | | or it is impossible to kill it in some situations. Unpend yet one SIGARLM (see timer.c commit) Should go into 2.2
* osreldate.h stuff suggested by: Eivind Eklundbrian1997-02-251-1/+3
| | | | | | | | Remove #include's from sig.h and get dependant modules to include them themselves. Make inclusion of if_var.h depend on __FreeBSD_version so that the -current version of ppp can be used with 2.1.* 2.2 Candidate ?
* Revert $FreeBSD$ to $Id$peter1997-02-221-1/+1
|
* Tidy up signal handling.brian1997-02-191-6/+6
| | | | | | | | | | | | | | | | | | All signal() calls have been changed to pending_signal() calls. pending_signal() is defined in the new sig.c file. It remembers the handler and traps the signal with a function that will remember the signal. main.c now calls handle_signals() to actually call the required handlers (if the above handler was called). If this doesn't close PR2662 (was PR2347), I'll cry. Joerg, I think this should go into 2.2, but I havn't done anything about it because I'm bound to botch it with the new sig.[ch] files. I've just "cvs add"'d sig.[ch] so far.... can you update to 2.2 and tell me what you did ? Thanks.
* Make the long-awaited change from $Id$ to $FreeBSD$jkh1997-01-141-1/+1
| | | | | | | | This will make a number of things easier in the future, as well as (finally!) avoiding the Id-smashing problem which has plagued developers for so long. Boy, I'm glad we're not using sup anymore. This update would have been insane otherwise.
* Fix many buffer overruns in the code. Specifically, disallow ExpandStringimp1997-01-101-24/+43
| | | | | | | | | | | | | to be used to expand things beyond the size of the buffer passed in. Also do a general cleanup of sprintf -> snprintf as well as strcpy and strncat safety. Also expand some buffers to allow for the largest possible data that might be used. This is a 2.2 candidate. However, it needs to be vetted on -current since little testing has been done on this due to my lack of PPP on this machine. Reviewed by: Jordan Hubbard, Peter Wemm, Guido van Rooij
* Avoid some buffer overrun problems.pst1996-12-151-2/+2
|
* Prepare for exec properly and check return valuesache1996-06-091-1/+10
| | | | Submitted by: Arjan de Vet <devet@IAEhv.nl>
OpenPOWER on IntegriCloud