diff options
author | ache <ache@FreeBSD.org> | 1997-04-09 17:35:54 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 1997-04-09 17:35:54 +0000 |
commit | 9949bd676e67df3010077d806ac69db56f472ff7 (patch) | |
tree | 94d218f7e9f708d3c068b335158fc2f7713a0974 /usr.sbin/ppp/main.c | |
parent | 8c5b669d734fddf7f8d8e0ab0ff8dbda2c5faafc (diff) | |
download | FreeBSD-src-9949bd676e67df3010077d806ac69db56f472ff7.zip FreeBSD-src-9949bd676e67df3010077d806ac69db56f472ff7.tar.gz |
Ignore SIGPIPE or any user can quit ppp just telnetting to it
and quitting telnet immediately (while phone number dialed)
Log client connection/disconnection with PHASE_BIT now.
Add more error recovery on client disconnection
Diffstat (limited to 'usr.sbin/ppp/main.c')
-rw-r--r-- | usr.sbin/ppp/main.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/usr.sbin/ppp/main.c b/usr.sbin/ppp/main.c index 46a0f7d..c56b3da 100644 --- a/usr.sbin/ppp/main.c +++ b/usr.sbin/ppp/main.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: main.c,v 1.39 1997/03/13 14:53:55 brian Exp $ + * $Id: main.c,v 1.40 1997/03/13 21:22:07 brian Exp $ * * TODO: * o Add commands for traffic summary, version display, etc. @@ -363,7 +363,7 @@ char **argv; signal(SIGSEGV, Hangup); #endif #ifdef SIGPIPE - signal(SIGPIPE, Hangup); + signal(SIGPIPE, SIG_IGN); #endif #ifdef SIGALRM pending_signal(SIGALRM, SIG_IGN); @@ -562,10 +562,11 @@ ReadTty() if (n > 0) { DecodeCommand(linebuff, n, 1); } else { -#ifdef DEBUG - logprintf("connection closed.\n"); -#endif + LogPrintf(LOG_PHASE_BIT, "client connection closed.\n"); + VarLocalAuth = LOCAL_NO_AUTH; close(netfd); + close(1); + dup2(2, 1); /* Have to have something here or the modem will be 1 */ netfd = -1; mode &= ~MODE_INTER; } @@ -867,18 +868,24 @@ DoLoop() } if (server >= 0 && FD_ISSET(server, &rfds)) { -#ifdef DEBUG - logprintf("connected to client.\n"); -#endif + LogPrintf(LOG_PHASE_BIT, "connected to client.\n"); wfd = accept(server, (struct sockaddr *)&hisaddr, &ssize); + if (wfd < 0) { + perror("accept"); + continue; + } if (netfd >= 0) { write(wfd, "already in use.\n", 16); close(wfd); continue; } else netfd = wfd; - if (dup2(netfd, 1) < 0) + if (dup2(netfd, 1) < 0) { perror("dup2"); + close(netfd); + netfd = -1; + continue; + } mode |= MODE_INTER; Greetings(); switch ( LocalAuthInit() ) { |