diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1998-01-17 20:30:34 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1998-01-17 20:30:34 +0000 |
commit | b6c2c5d46982fa50e23e185005bab4af5592563a (patch) | |
tree | 05bba4b86a5a00dac72b1988a50d56dea8276a6e /usr.sbin | |
parent | ca091f8038b0ce14749ada5c80eb7f63cfc4f3af (diff) |
ppp-2.3.3 + some -Wall
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/pppd/Makefile | 5 | ||||
-rw-r--r-- | usr.sbin/pppd/auth.c | 72 | ||||
-rw-r--r-- | usr.sbin/pppd/ccp.c | 20 | ||||
-rw-r--r-- | usr.sbin/pppd/chap.c | 43 | ||||
-rw-r--r-- | usr.sbin/pppd/chap_ms.c | 26 | ||||
-rw-r--r-- | usr.sbin/pppd/chap_ms.h | 5 | ||||
-rw-r--r-- | usr.sbin/pppd/chat/chat.8 | 35 | ||||
-rw-r--r-- | usr.sbin/pppd/chat/chat.c | 1398 | ||||
-rw-r--r-- | usr.sbin/pppd/demand.c | 8 | ||||
-rw-r--r-- | usr.sbin/pppd/fsm.c | 42 | ||||
-rw-r--r-- | usr.sbin/pppd/ipxcp.c | 26 | ||||
-rw-r--r-- | usr.sbin/pppd/lcp.c | 30 | ||||
-rw-r--r-- | usr.sbin/pppd/main.c | 48 | ||||
-rw-r--r-- | usr.sbin/pppd/options.c | 16 | ||||
-rw-r--r-- | usr.sbin/pppd/patchlevel.h | 8 | ||||
-rw-r--r-- | usr.sbin/pppd/pppd.8 | 998 | ||||
-rw-r--r-- | usr.sbin/pppd/pppd.h | 6 | ||||
-rw-r--r-- | usr.sbin/pppd/sys-bsd.c | 9 | ||||
-rw-r--r-- | usr.sbin/pppd/upap.c | 24 |
19 files changed, 1463 insertions, 1356 deletions
diff --git a/usr.sbin/pppd/Makefile b/usr.sbin/pppd/Makefile index d0cb6239cf8..22d25dad211 100644 --- a/usr.sbin/pppd/Makefile +++ b/usr.sbin/pppd/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.12 1997/12/20 16:14:55 deraadt Exp $ +# $OpenBSD: Makefile,v 1.13 1998/01/17 20:30:16 millert Exp $ PCAPDIR=${.CURDIR}/../../lib/libpcap @@ -9,8 +9,9 @@ SRCS= auth.c cbcp.c ccp.c chap.c chap_ms.c demand.c fsm.c ipcp.c \ .PATH: ${.CURDIR}/../../lib/libpcap ${.CURDIR}/../../sys/net MAN= pppd.8 SUBDIR= pppstats chat -BINMODE=4555 +BINMODE=4550 BINOWN= root +BINGRP= dialer LDADD= -lpcap -lutil DPADD= ${LIBPCAP} ${LIBUTIL} diff --git a/usr.sbin/pppd/auth.c b/usr.sbin/pppd/auth.c index 93fae88b556..658be709314 100644 --- a/usr.sbin/pppd/auth.c +++ b/usr.sbin/pppd/auth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auth.c,v 1.11 1997/09/28 15:35:50 deraadt Exp $ */ +/* $OpenBSD: auth.c,v 1.12 1998/01/17 20:30:17 millert Exp $ */ /* * auth.c - PPP authentication and phase control. @@ -36,9 +36,9 @@ #ifndef lint #if 0 -static char rcsid[] = "Id: auth.c,v 1.32 1997/07/14 03:52:33 paulus Exp"; +static char rcsid[] = "Id: auth.c,v 1.35 1997/11/27 06:49:15 paulus Exp $"; #else -static char rcsid[] = "$OpenBSD: auth.c,v 1.11 1997/09/28 15:35:50 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: auth.c,v 1.12 1998/01/17 20:30:17 millert Exp $"; #endif #endif @@ -48,12 +48,15 @@ static char rcsid[] = "$OpenBSD: auth.c,v 1.11 1997/09/28 15:35:50 deraadt Exp $ #include <unistd.h> #include <syslog.h> #include <pwd.h> -#include <utmp.h> -#include <fcntl.h> #include <string.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/socket.h> +#include <utmp.h> +#include <fcntl.h> +#if defined(_PATH_LASTLOG) && defined(_linux_) +#include <lastlog.h> +#endif #include <netdb.h> #include <netinet/in.h> @@ -106,7 +109,7 @@ char peer_authname[MAXNAMELEN]; /* Records which authentication operations haven't completed yet. */ static int auth_pending[NUM_PPP]; -/* Set if we have successfully called login() */ +/* Set if we have successfully called plogin() */ static int logged_in; /* Set if we have run the /etc/ppp/auth-up script. */ @@ -135,10 +138,10 @@ extern char *crypt __P((const char *, const char *)); /* Prototypes for procedures local to this file. */ static void network_phase __P((int)); -static void check_idle __P((caddr_t)); -static void connect_time_expired __P((caddr_t)); -static int login __P((char *, char *, char **, int *)); -static void logout __P((void)); +static void check_idle __P((void *)); +static void connect_time_expired __P((void *)); +static int plogin __P((char *, char *, char **, int *)); +static void plogout __P((void)); static int null_login __P((int)); static int get_pap_passwd __P((char *)); static int have_pap_secret __P((void)); @@ -149,9 +152,6 @@ static int scan_authfile __P((FILE *, char *, char *, u_int32_t, char *, static void free_wordlist __P((struct wordlist *)); static void auth_script __P((char *)); static void set_allowed_addrs __P((int, struct wordlist *)); -#ifdef CBCP_SUPPORT -static void callback_phase __P((int)); -#endif /* * An Open on LCP has requested a change from Dead to Establish phase. @@ -174,7 +174,7 @@ link_terminated(unit) if (phase == PHASE_DEAD) return; if (logged_in) - logout(); + plogout(); phase = PHASE_DEAD; syslog(LOG_NOTICE, "Connection terminated."); } @@ -477,7 +477,7 @@ np_finished(unit, proto) */ static void check_idle(arg) - caddr_t arg; + void *arg; { struct ppp_idle idle; time_t itime; @@ -499,7 +499,7 @@ check_idle(arg) */ static void connect_time_expired(arg) - caddr_t arg; + void *arg; { syslog(LOG_INFO, "Connect time expired"); lcp_close(0, "Connect time expired"); /* Close connection */ @@ -644,10 +644,8 @@ check_passwd(unit, auser, userlen, apasswd, passwdlen, msg, msglen) ret = UPAP_AUTHACK; f = fopen(filename, "r"); if (f == NULL) { - if (!uselogin) { - syslog(LOG_ERR, "Can't open PAP password file %s: %m", filename); - ret = UPAP_AUTHNAK; - } + syslog(LOG_ERR, "Can't open PAP password file %s: %m", filename); + ret = UPAP_AUTHNAK; } else { check_access(f, filename); remote = ipwo->accept_remote? 0: ipwo->hisaddr; @@ -662,7 +660,7 @@ check_passwd(unit, auser, userlen, apasswd, passwdlen, msg, msglen) } if (uselogin && ret == UPAP_AUTHACK) { - ret = login(user, passwd, msg, msglen); + ret = plogin(user, passwd, msg, msglen); if (ret == UPAP_AUTHNAK) { syslog(LOG_WARNING, "PAP login failure for %s", user); } @@ -715,7 +713,7 @@ static int pam_conv(int num_msg, const struct pam_message **msg, #endif /* - * login - Check the user name and password against the system + * plogin - Check the user name and password against the system * password database, and login the user if OK. * * returns: @@ -725,7 +723,7 @@ static int pam_conv(int num_msg, const struct pam_message **msg, */ static int -login(user, passwd, msg, msglen) +plogin(user, passwd, msg, msglen) char *user; char *passwd; char **msg; @@ -821,19 +819,19 @@ login(user, passwd, msg, msglen) logwtmp(tty, user, remote_name); /* Add wtmp login entry */ #ifdef _PATH_LASTLOG -{ - struct lastlog ll; - int fd; - - if ((fd = open(_PATH_LASTLOG, O_RDWR, 0)) >= 0) { - (void)lseek(fd, (off_t)pw->pw_uid * sizeof(ll), SEEK_SET); - memset(&ll, 0, sizeof(ll)); - time(&ll.ll_time); - strncpy(ll.ll_line, tty, sizeof(ll.ll_line)); - write(fd, (char *)&ll, sizeof(ll)); - close(fd); + { + struct lastlog ll; + int fd; + + if ((fd = open(_PATH_LASTLOG, O_RDWR, 0)) >= 0) { + (void)lseek(fd, (off_t)(pw->pw_uid * sizeof(ll)), SEEK_SET); + memset((void *)&ll, 0, sizeof(ll)); + (void)time(&ll.ll_time); + (void)strncpy(ll.ll_line, tty, sizeof(ll.ll_line)); + (void)write(fd, (char *)&ll, sizeof(ll)); + (void)close(fd); + } } -} #endif logged_in = TRUE; @@ -841,10 +839,10 @@ login(user, passwd, msg, msglen) } /* - * logout - Logout the user. + * plogout - Logout the user. */ static void -logout() +plogout() { char *tty; diff --git a/usr.sbin/pppd/ccp.c b/usr.sbin/pppd/ccp.c index 19dc97ad8a5..32db770d47f 100644 --- a/usr.sbin/pppd/ccp.c +++ b/usr.sbin/pppd/ccp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ccp.c,v 1.6 1997/09/05 04:32:34 millert Exp $ */ +/* $OpenBSD: ccp.c,v 1.7 1998/01/17 20:30:18 millert Exp $ */ /* * ccp.c - PPP Compression Control Protocol. @@ -29,9 +29,9 @@ #ifndef lint #if 0 -static char rcsid[] = "Id: ccp.c,v 1.21 1997/05/22 06:45:59 paulus Exp"; +static char rcsid[] = "Id: ccp.c,v 1.21 1997/05/22 06:45:59 paulus Exp $"; #else -static char rcsid[] = "$OpenBSD: ccp.c,v 1.6 1997/09/05 04:32:34 millert Exp $"; +static char rcsid[] = "$OpenBSD: ccp.c,v 1.7 1998/01/17 20:30:18 millert Exp $"; #endif #endif @@ -98,7 +98,7 @@ static int ccp_reqci __P((fsm *, u_char *, int *, int)); static void ccp_up __P((fsm *)); static void ccp_down __P((fsm *)); static int ccp_extcode __P((fsm *, int, int, u_char *, int)); -static void ccp_rack_timeout __P((caddr_t)); +static void ccp_rack_timeout __P((void *)); static char *method_name __P((ccp_options *, ccp_options *)); static fsm_callbacks ccp_callbacks = { @@ -274,7 +274,7 @@ ccp_extcode(f, code, id, p, len) case CCP_RESETACK: if (ccp_localstate[f->unit] & RACK_PENDING && id == f->reqid) { ccp_localstate[f->unit] &= ~(RACK_PENDING | RREQ_REPEAT); - UNTIMEOUT(ccp_rack_timeout, (caddr_t) f); + UNTIMEOUT(ccp_rack_timeout, f); } break; @@ -878,7 +878,7 @@ ccp_down(f) fsm *f; { if (ccp_localstate[f->unit] & RACK_PENDING) - UNTIMEOUT(ccp_rack_timeout, (caddr_t) f); + UNTIMEOUT(ccp_rack_timeout, f); ccp_localstate[f->unit] = 0; ccp_flags_set(f->unit, 1, 0); } @@ -1026,7 +1026,7 @@ ccp_datainput(unit, pkt, len) */ if (!(ccp_localstate[f->unit] & RACK_PENDING)) { fsm_sdata(f, CCP_RESETREQ, f->reqid = ++f->id, NULL, 0); - TIMEOUT(ccp_rack_timeout, (caddr_t) f, RACKTIMEOUT); + TIMEOUT(ccp_rack_timeout, f, RACKTIMEOUT); ccp_localstate[f->unit] |= RACK_PENDING; } else ccp_localstate[f->unit] |= RREQ_REPEAT; @@ -1039,13 +1039,13 @@ ccp_datainput(unit, pkt, len) */ static void ccp_rack_timeout(arg) - caddr_t arg; + void *arg; { - fsm *f = (fsm *) arg; + fsm *f = arg; if (f->state == OPENED && ccp_localstate[f->unit] & RREQ_REPEAT) { fsm_sdata(f, CCP_RESETREQ, f->reqid, NULL, 0); - TIMEOUT(ccp_rack_timeout, (caddr_t) f, RACKTIMEOUT); + TIMEOUT(ccp_rack_timeout, f, RACKTIMEOUT); ccp_localstate[f->unit] &= ~RREQ_REPEAT; } else ccp_localstate[f->unit] &= ~RACK_PENDING; diff --git a/usr.sbin/pppd/chap.c b/usr.sbin/pppd/chap.c index 59ed468d4db..be2314a42ad 100644 --- a/usr.sbin/pppd/chap.c +++ b/usr.sbin/pppd/chap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: chap.c,v 1.6 1997/09/05 04:32:35 millert Exp $ */ +/* $OpenBSD: chap.c,v 1.7 1998/01/17 20:30:19 millert Exp $ */ /* * chap.c - Challenge Handshake Authentication Protocol. @@ -37,9 +37,9 @@ #ifndef lint #if 0 -static char rcsid[] = "Id: chap.c,v 1.14 1997/04/30 05:51:08 paulus Exp"; +static char rcsid[] = "Id: chap.c,v 1.15 1997/11/27 06:07:48 paulus Exp $"; #else -static char rcsid[] = "$OpenBSD: chap.c,v 1.6 1997/09/05 04:32:35 millert Exp $"; +static char rcsid[] = "$OpenBSD: chap.c,v 1.7 1998/01/17 20:30:19 millert Exp $"; #endif #endif @@ -92,10 +92,10 @@ struct protent chap_protent = { chap_state chap[NUM_PPP]; /* CHAP state; one for each unit */ -static void ChapChallengeTimeout __P((caddr_t)); -static void ChapResponseTimeout __P((caddr_t)); +static void ChapChallengeTimeout __P((void *)); +static void ChapResponseTimeout __P((void *)); static void ChapReceiveChallenge __P((chap_state *, u_char *, int, int)); -static void ChapRechallenge __P((caddr_t)); +static void ChapRechallenge __P((void *)); static void ChapReceiveResponse __P((chap_state *, u_char *, int, int)); static void ChapReceiveSuccess __P((chap_state *, u_char *, int, int)); static void ChapReceiveFailure __P((chap_state *, u_char *, int, int)); @@ -189,7 +189,7 @@ ChapAuthPeer(unit, our_name, digest) */ static void ChapChallengeTimeout(arg) - caddr_t arg; + void *arg; { chap_state *cstate = (chap_state *) arg; @@ -216,7 +216,7 @@ ChapChallengeTimeout(arg) */ static void ChapResponseTimeout(arg) - caddr_t arg; + void *arg; { chap_state *cstate = (chap_state *) arg; @@ -233,7 +233,7 @@ ChapResponseTimeout(arg) */ static void ChapRechallenge(arg) - caddr_t arg; + void *arg; { chap_state *cstate = (chap_state *) arg; @@ -287,12 +287,12 @@ ChapLowerDown(unit) /* Timeout(s) pending? Cancel if so. */ if (cstate->serverstate == CHAPSS_INITIAL_CHAL || cstate->serverstate == CHAPSS_RECHALLENGE) - UNTIMEOUT(ChapChallengeTimeout, (caddr_t) cstate); + UNTIMEOUT(ChapChallengeTimeout, cstate); else if (cstate->serverstate == CHAPSS_OPEN && cstate->chal_interval != 0) - UNTIMEOUT(ChapRechallenge, (caddr_t) cstate); + UNTIMEOUT(ChapRechallenge, cstate); if (cstate->clientstate == CHAPCS_RESPONSE) - UNTIMEOUT(ChapResponseTimeout, (caddr_t) cstate); + UNTIMEOUT(ChapResponseTimeout, cstate); cstate->clientstate = CHAPCS_INITIAL; cstate->serverstate = CHAPSS_INITIAL; @@ -447,7 +447,7 @@ ChapReceiveChallenge(cstate, inp, id, len) /* cancel response send timeout if necessary */ if (cstate->clientstate == CHAPCS_RESPONSE) - UNTIMEOUT(ChapResponseTimeout, (caddr_t) cstate); + UNTIMEOUT(ChapResponseTimeout, cstate); cstate->resp_id = id; cstate->resp_transmits = 0; @@ -539,7 +539,7 @@ ChapReceiveResponse(cstate, inp, id, len) return; } - UNTIMEOUT(ChapChallengeTimeout, (caddr_t) cstate); + UNTIMEOUT(ChapChallengeTimeout, cstate); if (len >= sizeof(rhostname)) len = sizeof(rhostname) - 1; @@ -592,10 +592,13 @@ ChapReceiveResponse(cstate, inp, id, len) auth_peer_success(cstate->unit, PPP_CHAP, rhostname, len); } if (cstate->chal_interval != 0) - TIMEOUT(ChapRechallenge, (caddr_t) cstate, cstate->chal_interval); + TIMEOUT(ChapRechallenge, cstate, cstate->chal_interval); + syslog(LOG_NOTICE, "CHAP peer authentication succeeded for %s", + rhostname); } else { - syslog(LOG_ERR, "CHAP peer authentication failed"); + syslog(LOG_ERR, "CHAP peer authentication failed for remote host %s", + rhostname); cstate->serverstate = CHAPSS_BADAUTH; auth_peer_fail(cstate->unit, PPP_CHAP); } @@ -625,7 +628,7 @@ ChapReceiveSuccess(cstate, inp, id, len) return; } - UNTIMEOUT(ChapResponseTimeout, (caddr_t) cstate); + UNTIMEOUT(ChapResponseTimeout, cstate); /* * Print message. @@ -658,7 +661,7 @@ ChapReceiveFailure(cstate, inp, id, len) return; } - UNTIMEOUT(ChapResponseTimeout, (caddr_t) cstate); + UNTIMEOUT(ChapResponseTimeout, cstate); /* * Print message. @@ -703,7 +706,7 @@ ChapSendChallenge(cstate) CHAPDEBUG((LOG_INFO, "ChapSendChallenge: Sent id %d.", cstate->chal_id)); - TIMEOUT(ChapChallengeTimeout, (caddr_t) cstate, cstate->timeouttime); + TIMEOUT(ChapChallengeTimeout, cstate, cstate->timeouttime); ++cstate->chal_transmits; } @@ -803,7 +806,7 @@ ChapSendResponse(cstate) output(cstate->unit, outpacket_buf, outlen + PPP_HDRLEN); cstate->clientstate = CHAPCS_RESPONSE; - TIMEOUT(ChapResponseTimeout, (caddr_t) cstate, cstate->timeouttime); + TIMEOUT(ChapResponseTimeout, cstate, cstate->timeouttime); ++cstate->resp_transmits; } diff --git a/usr.sbin/pppd/chap_ms.c b/usr.sbin/pppd/chap_ms.c index 88b923fd696..edb1e5b039b 100644 --- a/usr.sbin/pppd/chap_ms.c +++ b/usr.sbin/pppd/chap_ms.c @@ -1,4 +1,4 @@ -/* $OpenBSD: chap_ms.c,v 1.3 1997/09/05 04:32:36 millert Exp $ */ +/* $OpenBSD: chap_ms.c,v 1.4 1998/01/17 20:30:20 millert Exp $ */ /* * chap_ms.c - Microsoft MS-CHAP compatible implementation. @@ -35,18 +35,21 @@ #ifndef lint #if 0 -static char rcsid[] = "Id: chap_ms.c,v 1.4 1997/05/22 06:46:19 paulus Exp"; +static char rcsid[] = "Id: chap_ms.c,v 1.5 1997/11/27 06:08:10 paulus Exp $"; #else -static char rcsid[] = "$Id: chap_ms.c,v 1.3 1997/09/05 04:32:36 millert Exp $"; +static char rcsid[] = "$Id: chap_ms.c,v 1.4 1998/01/17 20:30:20 millert Exp $"; #endif #endif #ifdef CHAPMS #include <stdio.h> +#include <string.h> +#include <ctype.h> #include <sys/types.h> #include <sys/time.h> #include <syslog.h> +#include <unistd.h> #include <md4.h> #include "pppd.h" @@ -66,8 +69,14 @@ typedef struct { in case this struct gets padded. */ +static void ChallengeResponse __P((u_char *, u_char *, u_char *)); static void DesEncrypt __P((u_char *, u_char *, u_char *)); static void MakeKey __P((u_char *, u_char *)); +static u_char Get7Bits __P((u_char *, int)); +static void ChapMS_NT __P((char *, int, char *, int, MS_ChapResponse *)); +#ifdef MSLANMAN +static void ChapMS_LANMan __P((char *, int, char *, int, MS_ChapResponse *)); +#endif #ifdef USE_CRYPT static void Expand __P((u_char *, u_char *)); @@ -83,7 +92,7 @@ ChallengeResponse(challenge, pwHash, response) char ZPasswordHash[21]; BZERO(ZPasswordHash, sizeof(ZPasswordHash)); - BCOPY(pwHash, ZPasswordHash, 16); + BCOPY(pwHash, ZPasswordHash, MD4_SIGNATURE_SIZE); #if 0 log_packet(ZPasswordHash, sizeof(ZPasswordHash), "ChallengeResponse - ZPasswordHash", LOG_DEBUG); @@ -250,8 +259,8 @@ ChapMS_NT(rchallenge, rchallenge_len, secret, secret_len, response) { int i; MD4_CTX md4Context; + u_char hash[MD4_SIGNATURE_SIZE]; u_char unicodePassword[MAX_NT_PASSWORD * 2]; - u_char hash[16]; /* Initialize the Unicode version of the secret (== password). */ /* This implicitly supports 8-bit ISO8859/1 characters. */ @@ -264,13 +273,14 @@ ChapMS_NT(rchallenge, rchallenge_len, secret, secret_len, response) MD4Final(hash, &md4Context); /* Tell MD4 we're done */ - ChallengeResponse(rchallenge, (char *)hash, response->NTResp); + ChallengeResponse(rchallenge, hash, response->NTResp); } #ifdef MSLANMAN static u_char *StdText = (u_char *)"KGS!@#$%"; /* key from rasapi32.dll */ -static ChapMS_LANMan(rchallenge, rchallenge_len, secret, secret_len, response) +static void +ChapMS_LANMan(rchallenge, rchallenge_len, secret, secret_len, response) char *rchallenge; int rchallenge_len; char *secret; @@ -279,7 +289,7 @@ static ChapMS_LANMan(rchallenge, rchallenge_len, secret, secret_len, response) { int i; u_char UcasePassword[MAX_NT_PASSWORD]; /* max is actually 14 */ - u_char PasswordHash[16]; + u_char PasswordHash[MD4_SIGNATURE_SIZE]; /* LANMan password is case insensitive */ BZERO(UcasePassword, sizeof(UcasePassword)); diff --git a/usr.sbin/pppd/chap_ms.h b/usr.sbin/pppd/chap_ms.h index c9e6aa5314c..a5a78858923 100644 --- a/usr.sbin/pppd/chap_ms.h +++ b/usr.sbin/pppd/chap_ms.h @@ -1,4 +1,4 @@ -/* $OpenBSD: chap_ms.h,v 1.2 1997/09/05 04:32:36 millert Exp $ */ +/* $OpenBSD: chap_ms.h,v 1.3 1998/01/17 20:30:20 millert Exp $ */ /* * chap.h - Challenge Handshake Authentication Protocol definitions. @@ -21,11 +21,12 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * Id: chap_ms.h,v 1.1 1996/05/28 00:42:31 paulus Exp + * Id: chap_ms.h,v 1.2 1997/11/27 06:08:10 paulus Exp $ */ #ifndef __CHAPMS_INCLUDE__ +#define MD4_SIGNATURE_SIZE 16 /* 16 bytes in a MD4 message digest */ #define MAX_NT_PASSWORD 256 /* Maximum number of (Unicode) chars in an NT password */ void ChapMS __P((chap_state *, char *, int, char *, int)); diff --git a/usr.sbin/pppd/chat/chat.8 b/usr.sbin/pppd/chat/chat.8 index cbfa10a2260..f9299ec69ea 100644 --- a/usr.sbin/pppd/chat/chat.8 +++ b/usr.sbin/pppd/chat/chat.8 @@ -1,13 +1,13 @@ .\" -*- nroff -*- -.\" manual page [] for chat 1.9 -.\" Id: chat.8,v 1.5 1997/07/14 03:49:41 paulus Exp $ -.\" $OpenBSD: chat.8,v 1.3 1997/09/01 21:48:27 millert Exp $ +.\" manual page [] for chat 1.8 +.\" $OpenBSD: chat.8,v 1.4 1998/01/17 20:30:32 millert Exp $ +.\" Id: chat.8,v 1.6 1997/11/27 06:00:06 paulus Exp $ .\" SH section heading .\" SS subsection heading .\" LP paragraph .\" IP indented paragraph .\" TP hanging label -.TH CHAT 8 "5 May 1995" "Chat Version 1.9" +.TH CHAT 8 "27 Sep 1997" "Chat Version 1.17" .SH NAME chat \- Automated conversational script with a modem .SH SYNOPSIS @@ -52,19 +52,40 @@ to \fIstderr\fR. .TP .B -v Request that the \fIchat\fR script be executed in a verbose mode. The -\fIchat\fR program will then log all text received from the modem and -the output strings which it sends to the SYSLOG. +\fIchat\fR program will then log the execution state of the chat +script as well as all text received from the modem and the output +strings sent to the modem. The default is to log through the SYSLOG; +the logging method may be altered with the -S and -s flags. .TP .B -V Request that the \fIchat\fR script be executed in a stderr verbose mode. The \fIchat\fR program will then log all text received from the -modem and the output strings which it sends to the stderr device. This +modem and the output strings sent to the modem to the stderr device. This device is usually the local console at the station running the chat or pppd program. This option will not work properly if the stderr is redirected to the /dev/null location as is the case should pppd be run in the 'detached' mode. In that case, use the '-v' option to record the session on the SYSLOG device. .TP +.B -s +Use stderr. All log messages from '-v' and all error messages will be +sent to stderr. +.TP +.B -S +Do not use the SYSLOG. By default, error messages are sent to the +SYSLOG. The use of -S will prevent both log messages from '-v' and +error messages from being sent to the SYSLOG. +.TP +.B -T \fI<phone number> +Pass in an arbitary string, usually a phone number, that will be +substituted for the \\T substitution metacharacter in a send string. +.TP +.B -U \fI<phone number 2> +Pass in a second string, usually a phone number, that will be +substituted for the \\U substitution metacharacter in a send string. +This is useful when dialing an ISDN terminal adapter that requires two +numbers. +.TP .B script If the script is not specified in a file with the \fI-f\fR option then the script is included as parameters to the \fIchat\fR program. diff --git a/usr.sbin/pppd/chat/chat.c b/usr.sbin/pppd/chat/chat.c index 591a373d9c5..ba7cb62411b 100644 --- a/usr.sbin/pppd/chat/chat.c +++ b/usr.sbin/pppd/chat/chat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: chat.c,v 1.5 1997/11/16 21:16:49 millert Exp $ */ +/* $OpenBSD: chat.c,v 1.6 1998/01/17 20:30:33 millert Exp $ */ /* * Chat -- a program for automatic session establishment (i.e. dial @@ -7,7 +7,7 @@ * Standard termination codes: * 0 - successful completion of the script * 1 - invalid argument, expect string too large, etc. - * 2 - error on an I/O operation or fatal error condtion. + * 2 - error on an I/O operation or fatal error condition. * 3 - timeout waiting for a simple string. * 4 - the first string declared as "ABORT" * 5 - the second string declared as "ABORT" @@ -16,6 +16,10 @@ * This software is in the public domain. * * ----------------- + * added -T and -U option and \T and \U substitution to pass a phone + * number into chat script. Two are needed for some ISDN TA applications. + * Keith Dart <kdart@cisco.com> + * * * Added SAY keyword to send output to stderr. * This allows to turn ECHO OFF and to output specific, user selected, @@ -50,6 +54,10 @@ * Added -r "report file" switch & REPORT keyword. * Robert Geer <bgeer@xmission.com> * + * Added -s "use stderr" and -S "don't use syslog" switches. + * June 18, 1997 + * Karl O. Pinc <kop@meme.com> + * * * Added -e "echo" switch & ECHO keyword * Dick Streefland <dicks@tasking.nl> @@ -73,9 +81,9 @@ #ifndef lint #if 0 -static char rcsid[] = "Id: chat.c,v 1.15 1997/07/14 03:50:22 paulus Exp $"; +static char rcsid[] = "Id: chat.c,v 1.17 1997/11/27 06:37:15 paulus Exp $"; #else -static char rcsid[] = "$OpenBSD: chat.c,v 1.5 1997/11/16 21:16:49 millert Exp $"; +static char rcsid[] = "$OpenBSD: chat.c,v 1.6 1998/01/17 20:30:33 millert Exp $"; #endif #endif @@ -110,10 +118,16 @@ static char rcsid[] = "$OpenBSD: chat.c,v 1.5 1997/11/16 21:16:49 millert Exp $" #define SIGTYPE void #endif -#ifdef __STDC__ #undef __P +#undef __V + +#ifdef __STDC__ +#include <stdarg.h> +#define __V(x) x #define __P(x) x #else +#include <varargs.h> +#define __V(x) (va_alist) va_dcl #define __P(x) () #define const #endif @@ -122,12 +136,22 @@ static char rcsid[] = "$OpenBSD: chat.c,v 1.5 1997/11/16 21:16:49 millert Exp $" #define O_NONBLOCK O_NDELAY #endif +#ifdef SUNOS +extern int sys_nerr; +extern char *sys_errlist[]; +#define memmove(to, from, n) bcopy(from, to, n) +#define strerror(n) ((unsigned)(n) < sys_nerr? sys_errlist[(n)] :\ + "unknown error") +#endif + #define MAX_ABORTS 50 #define MAX_REPORTS 50 #define DEFAULT_CHAT_TIMEOUT 45 int echo = 0; int verbose = 0; +int to_log = 1; +int to_stderr = 0; int Verbose = 0; int quiet = 0; int report = 0; @@ -135,6 +159,8 @@ int exit_code = 0; FILE* report_fp = (FILE *) 0; char *report_file = (char *) 0; char *chat_file = (char *) 0; +char *phone_num = (char *) 0; +char *phone_num2 = (char *) 0; int timeout = DEFAULT_CHAT_TIMEOUT; int have_tty_parameters = 0; @@ -170,10 +196,8 @@ int say_next = 0, hup_next = 0; void *dup_mem __P((void *b, size_t c)); void *copy_of __P((char *s)); void usage __P((void)); -void logf __P((const char *str)); -void logflush __P((void)); -void fatal __P((const char *msg)); -void sysfatal __P((const char *msg)); +void logf __P((const char *fmt, ...)); +void fatal __P((int code, const char *fmt, ...)); SIGTYPE sigalrm __P((int signo)); SIGTYPE sigint __P((int signo)); SIGTYPE sigterm __P((int signo)); @@ -196,152 +220,147 @@ void chat_expect __P((register char *s)); char *clean __P((register char *s, int sending)); void break_sequence __P((void)); void terminate __P((int status)); -void die __P((void)); void pack_array __P((char **array, int end)); char *expect_strtok __P((char *, char *)); +int vfmtmsg __P((char *, int, const char *, va_list)); /* vsprintf++ */ int main __P((int, char *[])); void *dup_mem(b, c) void *b; size_t c; - { +{ void *ans = malloc (c); if (!ans) - { - fatal ("memory error!\n"); - } + fatal(2, "memory error!"); + memcpy (ans, b, c); return ans; - } +} void *copy_of (s) char *s; - { +{ return dup_mem (s, strlen (s) + 1); - } +} /* - * chat [ -v ] [ -t timeout ] [ -f chat-file ] [ -r report-file ] \ + * chat [ -v ] [-T number] [-U number] [ -t timeout ] [ -f chat-file ] \ + * [ -r report-file ] \ * [...[[expect[-say[-expect...]] say expect[-say[-expect]] ...]]] * * Perform a UUCP-dialer-like chat script on stdin and stdout. */ int main(argc, argv) -int argc; -char **argv; - { + int argc; + char **argv; +{ int option; tzset(); - while ((option = getopt(argc, argv, "evVt:r:f:")) != -1) - { - switch (option) - { - case 'e': - ++echo; - break; + while ((option = getopt(argc, argv, "evVt:r:f:T:U:")) != -1) { + switch (option) { + case 'e': + ++echo; + break; - case 'v': - ++verbose; - break; + case 'v': + ++verbose; + break; - case 'V': - ++Verbose; - break; + case 'V': + ++Verbose; + break; - case 'f': - chat_file = copy_of(optarg); - break; + case 's': + ++to_stderr; + break; - case 't': - timeout = atoi(optarg); - break; + case 'S': + to_log = 0; + break; - case 'r': - if (report_fp != NULL) - { - fclose (report_fp); - } - report_file = copy_of (optarg); - report_fp = fopen (report_file, "a"); - if (report_fp != NULL) - { - if (verbose) - { - fprintf (report_fp, "Opening \"%s\"...\n", - report_file); - } - report = 1; - } - break; + case 'f': + chat_file = copy_of(optarg); + break; - case ':': - fprintf(stderr, "Option -%c requires an argument\n", - optopt); + case 't': + timeout = atoi(optarg); + break; - default: - usage(); - break; + case 'r': + if (report_fp != NULL) + fclose (report_fp); + report_file = copy_of (optarg); + report_fp = fopen (report_file, "a"); + if (report_fp != NULL) { + if (verbose) + fprintf (report_fp, "Opening \"%s\"...\n", + report_file); + report = 1; } - } - argc -= optind; - argv += optind; + break; + + case 'T': + phone_num = copy_of(optarg); + break; + + case 'U': + phone_num2 = copy_of(optarg); + break; + + case ':': + fprintf(stderr, "Option -%c requires an argument\n", + optopt); + + default: + usage(); + break; + } + } + argc -= optind; + argv += optind; /* * Default the report file to the stderr location */ if (report_fp == NULL) - { report_fp = stderr; - } + if (to_log) { #ifdef ultrix - openlog("chat", LOG_PID); + openlog("chat", LOG_PID); #else - openlog("chat", LOG_PID | LOG_NDELAY, LOG_LOCAL2); + openlog("chat", LOG_PID | LOG_NDELAY, LOG_LOCAL2); - if (verbose) - { - setlogmask(LOG_UPTO(LOG_INFO)); - } - else - { - setlogmask(LOG_UPTO(LOG_WARNING)); - } + if (verbose) + setlogmask(LOG_UPTO(LOG_INFO)); + else + setlogmask(LOG_UPTO(LOG_WARNING)); #endif + } init(); - if (chat_file != NULL) - { + if (chat_file != NULL) { if (argc > 0) - { usage(); - } else - { do_file (chat_file); - } - } - else - { - while (*argv != NULL) - { + } else { + while (*argv != NULL) { chat_expect(*argv); if (*(++argv) != NULL) - { chat_send(*argv); - } - } - argv++; } + argv++; + } terminate(0); return 0; - } +} /* * Process a chat script when read from a file. @@ -349,7 +368,7 @@ char **argv; void do_file (chat_file) char *chat_file; - { +{ int linect, sendflg; char *sp, *arg, quote; char buf [STR_LEN]; @@ -357,223 +376,175 @@ char *chat_file; cfp = fopen (chat_file, "r"); if (cfp == NULL) - { - syslog (LOG_ERR, "%s -- open failed: %m", chat_file); - terminate (1); - } + fatal(1, "%s -- open failed: %m", chat_file); linect = 0; sendflg = 0; - while (fgets(buf, STR_LEN, cfp) != NULL) - { + while (fgets(buf, STR_LEN, cfp) != NULL) { sp = strchr (buf, '\n'); if (sp) - { *sp = '\0'; - } linect++; sp = buf; /* lines starting with '#' are comments. If a real '#' is to be expected, it should be quoted .... */ - if ( *sp == '#' ) continue; + if ( *sp == '#' ) + continue; - while (*sp != '\0') - { - if (*sp == ' ' || *sp == '\t') - { + while (*sp != '\0') { + if (*sp == ' ' || *sp == '\t') { ++sp; continue; - } + } - if (*sp == '"' || *sp == '\'') - { + if (*sp == '"' || *sp == '\'') { quote = *sp++; arg = sp; - while (*sp != quote) - { + while (*sp != quote) { if (*sp == '\0') - { - syslog (LOG_ERR, "unterminated quote (line %d)", - linect); - terminate (1); - } - - if (*sp++ == '\\') - { + fatal(1, "unterminated quote (line %d)", linect); + + if (*sp++ == '\\') { if (*sp != '\0') - { ++sp; - } - } } } - else - { + } + else { arg = sp; while (*sp != '\0' && *sp != ' ' && *sp != '\t') - { ++sp; - } - } + } if (*sp != '\0') - { *sp++ = '\0'; - } if (sendflg) - { chat_send (arg); - } else - { chat_expect (arg); - } sendflg = !sendflg; - } } - fclose (cfp); } + fclose (cfp); +} /* * We got an error parsing the command line. */ void usage() - { - fprintf(stderr, "Usage: %s [-e] [-v] [-V] [-t timeout] [-r report-file]" - "{-f chat-file | chat-script}\n", __progname); +{ + fprintf(stderr, "\ +Usage: %s [-e] [-v] [-V] [-t timeout] [-r report-file] [-T phone-number]\n\ + [-U phone-number2] {-f chat-file | chat-script}\n", __progname); exit(1); - } +} -char line[256]; +char line[1024]; -void logf (str) -const char *str; +/* + * Send a message to syslog and/or stderr. + */ +void logf __V((const char *fmt, ...)) { - int l = strlen(line); + va_list args; - if (l + strlen(str) >= sizeof(line)) { - syslog(LOG_INFO, "%s", line); - l = 0; - } - strcpy(line + l, str); - - if (str[strlen(str)-1] == '\n') { - syslog (LOG_INFO, "%s", line); - line[0] = 0; - } -} +#ifdef __STDC__ + va_start(args, fmt); +#else + char *fmt; + va_start(args); + fmt = va_arg(args, char *); +#endif -void logflush() - { - if (line[0] != 0) - { + vfmtmsg(line, sizeof(line), fmt, args); + if (to_log) syslog(LOG_INFO, "%s", line); - line[0] = 0; - } - } - -/* - * Terminate with an error. - */ -void die() - { - terminate(1); - } + if (to_stderr) + fprintf(stderr, "%s\n", line); +} /* * Print an error message and terminate. */ -void fatal (msg) -const char *msg; - { - syslog(LOG_ERR, "%s", msg); - terminate(2); - } +void fatal __V((int code, const char *fmt, ...)) +{ + va_list args; -/* - * Print an error message along with the system error message and - * terminate. - */ +#ifdef __STDC__ + va_start(args, fmt); +#else + int code; + char *fmt; + va_start(args); + code = va_arg(args, int); + fmt = va_arg(args, char *); +#endif -void sysfatal (msg) -const char *msg; - { - syslog(LOG_ERR, "%s: %m", msg); - terminate(2); - } + vfmtmsg(line, sizeof(line), fmt, args); + if (to_log) + syslog(LOG_ERR, "%s", line); + if (to_stderr) + fprintf(stderr, "%s\n", line); + terminate(code); +} int alarmed = 0; SIGTYPE sigalrm(signo) int signo; - { +{ int flags; alarm(1); alarmed = 1; /* Reset alarm to avoid race window */ signal(SIGALRM, sigalrm); /* that can cause hanging in read() */ - logflush(); if ((flags = fcntl(0, F_GETFL, 0)) == -1) - { - sysfatal("Can't get file mode flags on stdin"); - } - else - { - if (fcntl(0, F_SETFL, flags | O_NONBLOCK) == -1) - { - sysfatal("Can't set file mode flags on stdin"); - } - } + fatal(2, "Can't get file mode flags on stdin: %m"); + + if (fcntl(0, F_SETFL, flags | O_NONBLOCK) == -1) + fatal(2, "Can't set file mode flags on stdin: %m"); if (verbose) - { - syslog(LOG_INFO, "alarm"); - } - } + logf("alarm"); +} void unalarm() - { +{ int flags; if ((flags = fcntl(0, F_GETFL, 0)) == -1) - { - sysfatal("Can't get file mode flags on stdin"); - } - else - { - if (fcntl(0, F_SETFL, flags & ~O_NONBLOCK) == -1) - { - sysfatal("Can't set file mode flags on stdin"); - } - } - } + fatal(2, "Can't get file mode flags on stdin: %m"); + + if (fcntl(0, F_SETFL, flags & ~O_NONBLOCK) == -1) + fatal(2, "Can't set file mode flags on stdin: %m"); +} SIGTYPE sigint(signo) int signo; - { - fatal("SIGINT"); - } +{ + fatal(2, "SIGINT"); +} SIGTYPE sigterm(signo) int signo; - { - fatal("SIGTERM"); - } +{ + fatal(2, "SIGTERM"); +} SIGTYPE sighup(signo) int signo; - { - fatal("SIGHUP"); - } +{ + fatal(2, "SIGHUP"); +} void init() - { +{ signal(SIGINT, sigint); signal(SIGTERM, sigterm); signal(SIGHUP, sighup); @@ -582,17 +553,15 @@ void init() signal(SIGALRM, sigalrm); alarm(0); alarmed = 0; - } +} void set_tty_parameters() - { +{ #if defined(get_term_param) term_parms t; if (get_term_param (&t) < 0) - { - sysfatal("Can't get terminal parameters"); - } + fatal(2, "Can't get terminal parameters: %m"); saved_tty_parameters = t; have_tty_parameters = 1; @@ -606,25 +575,22 @@ void set_tty_parameters() t.c_cc[VTIME] = 0; if (set_term_param (&t) < 0) - { - sysfatal("Can't set terminal parameters"); - } + fatal(2, "Can't set terminal parameters: %m"); #endif - } +} void break_sequence() - { +{ #ifdef TERMIOS tcsendbreak (0, 0); #endif - } +} void terminate(status) int status; - { +{ echo_stderr(-1); - if (report_file != (char *) 0 && report_fp != (FILE *) NULL) - { + if (report_file != (char *) 0 && report_fp != (FILE *) NULL) { /* * Allow the last of the report string to be gathered before we terminate. */ @@ -645,91 +611,73 @@ int status; fprintf (report_fp, "chat: %s\n", report_buffer); } if (verbose) - { fprintf (report_fp, "Closing \"%s\".\n", report_file); - } fclose (report_fp); report_fp = (FILE *) NULL; - } + } #if defined(get_term_param) - if (have_tty_parameters) - { + if (have_tty_parameters) { if (set_term_param (&saved_tty_parameters) < 0) - { - syslog(LOG_ERR, "Can't restore terminal parameters: %m"); - exit(1); - } - } + fatal(2, "Can't restore terminal parameters: %m"); + } #endif exit(status); - } +} /* * 'Clean up' this string. */ char *clean(s, sending) register char *s; -int sending; - { +int sending; /* set to 1 when sending (putting) this string. */ +{ char temp[STR_LEN], cur_chr; - register char *s1; + register char *s1, *phchar; int add_return = sending; #define isoctal(chr) (((chr) >= '0') && ((chr) <= '7')) s1 = temp; - while (*s) - { + while (*s) { cur_chr = *s++; - if (cur_chr == '^') - { + if (cur_chr == '^') { cur_chr = *s++; - if (cur_chr == '\0') - { + if (cur_chr == '\0') { *s1++ = '^'; break; - } + } cur_chr &= 0x1F; - if (cur_chr != 0) - { + if (cur_chr != 0) { *s1++ = cur_chr; - } - continue; } + continue; + } - if (cur_chr != '\\') - { + if (cur_chr != '\\') { *s1++ = cur_chr; continue; - } + } cur_chr = *s++; - if (cur_chr == '\0') - { - if (sending) - { + if (cur_chr == '\0') { + if (sending) { *s1++ = '\\'; *s1++ = '\\'; - } - break; } + break; + } - switch (cur_chr) - { + switch (cur_chr) { case 'b': *s1++ = '\b'; break; case 'c': if (sending && *s == '\0') - { add_return = 0; - } else - { *s1++ = cur_chr; - } break; case '\\': @@ -737,13 +685,33 @@ int sending; case 'p': case 'd': if (sending) - { *s1++ = '\\'; - } *s1++ = cur_chr; break; + case 'T': + if (sending && phone_num) { + for ( phchar = phone_num; *phchar != '\0'; phchar++) + *s1++ = *phchar; + } + else { + *s1++ = '\\'; + *s1++ = 'T'; + } + break; + + case 'U': + if (sending && phone_num2) { + for ( phchar = phone_num2; *phchar != '\0'; phchar++) + *s1++ = *phchar; + } + else { + *s1++ = '\\'; + *s1++ = 'U'; + } + break; + case 'q': quiet = 1; break; @@ -765,122 +733,103 @@ int sending; break; case 'N': - if (sending) - { + if (sending) { *s1++ = '\\'; *s1++ = '\0'; - } + } else - { *s1++ = 'N'; - } break; default: - if (isoctal (cur_chr)) - { + if (isoctal (cur_chr)) { cur_chr &= 0x07; - if (isoctal (*s)) - { + if (isoctal (*s)) { cur_chr <<= 3; cur_chr |= *s++ - '0'; - if (isoctal (*s)) - { + if (isoctal (*s)) { cur_chr <<= 3; cur_chr |= *s++ - '0'; - } } + } - if (cur_chr != 0 || sending) - { + if (cur_chr != 0 || sending) { if (sending && (cur_chr == '\\' || cur_chr == 0)) - { *s1++ = '\\'; - } *s1++ = cur_chr; - } - break; } + break; + } if (sending) - { *s1++ = '\\'; - } *s1++ = cur_chr; break; - } } + } if (add_return) - { *s1++ = '\r'; - } *s1++ = '\0'; /* guarantee closure */ *s1++ = '\0'; /* terminate the string */ return dup_mem (temp, (size_t) (s1 - temp)); /* may have embedded nuls */ - } +} /* * A modified version of 'strtok'. This version skips \ sequences. */ char *expect_strtok (s, term) -char *s, *term; - { + char *s, *term; +{ static char *str = ""; int escape_flag = 0; char *result; + /* * If a string was specified then do initial processing. */ if (s) - { str = s; - } + /* * If this is the escape flag then reset it and ignore the character. */ if (*str) - { result = str; - } else - { result = (char *) 0; - } - while (*str) - { - if (escape_flag) - { + while (*str) { + if (escape_flag) { escape_flag = 0; ++str; continue; - } + } - if (*str == '\\') - { + if (*str == '\\') { ++str; escape_flag = 1; continue; - } + } + /* * If this is not in the termination string, continue. */ - if (strchr (term, *str) == (char *) 0) - { + if (strchr (term, *str) == (char *) 0) { ++str; continue; - } + } + /* * This is the terminator. Mark the end of the string and stop. */ *str++ = '\0'; break; - } - return (result); } + return (result); +} /* * Process the expect string @@ -888,101 +837,87 @@ char *s, *term; void chat_expect (s) char *s; - { +{ char *expect; char *reply; - if (strcmp(s, "HANGUP") == 0) - { + if (strcmp(s, "HANGUP") == 0) { ++hup_next; return; - } + } - if (strcmp(s, "ABORT") == 0) - { + if (strcmp(s, "ABORT") == 0) { ++abort_next; return; - } + } - if (strcmp(s, "CLR_ABORT") == 0) - { + if (strcmp(s, "CLR_ABORT") == 0) { ++clear_abort_next; return; - } + } - if (strcmp(s, "REPORT") == 0) - { + if (strcmp(s, "REPORT") == 0) { ++report_next; return; - } + } - if (strcmp(s, "CLR_REPORT") == 0) - { + if (strcmp(s, "CLR_REPORT") == 0) { ++clear_report_next; return; - } + } - if (strcmp(s, "TIMEOUT") == 0) - { + if (strcmp(s, "TIMEOUT") == 0) { ++timeout_next; return; - } + } - if (strcmp(s, "ECHO") == 0) - { + if (strcmp(s, "ECHO") == 0) { ++echo_next; return; - } - if (strcmp(s, "SAY") == 0) - { + } + + if (strcmp(s, "SAY") == 0) { ++say_next; return; - } + } + /* * Fetch the expect and reply string. */ - for (;;) - { + for (;;) { expect = expect_strtok (s, "-"); s = (char *) 0; if (expect == (char *) 0) - { return; - } reply = expect_strtok (s, "-"); + /* * Handle the expect string. If successful then exit. */ if (get_string (expect)) - { return; - } + /* * If there is a sub-reply string then send it. Otherwise any condition * is terminal. */ if (reply == (char *) 0 || exit_code != 3) - { break; - } chat_send (reply); - } + } + /* * The expectation did not occur. This is terminal. */ if (fail_reason) - { - syslog(LOG_INFO, "Failed (%s)", fail_reason); - } + logf("Failed (%s)", fail_reason); else - { - syslog(LOG_INFO, "Failed"); - } + logf("Failed"); terminate(exit_code); - } +} /* * Translate the input character to the appropriate string for printing @@ -991,7 +926,7 @@ char *s; char *character(c) int c; - { +{ static char string[10]; char *meta; @@ -999,93 +934,67 @@ int c; c &= 0x7F; if (c < 32) - { sprintf(string, "%s^%c", meta, (int)c + '@'); - } + else if (c == 127) + sprintf(string, "%s^?", meta); else - { - if (c == 127) - { - sprintf(string, "%s^?", meta); - } - else - { - sprintf(string, "%s%c", meta, c); - } - } + sprintf(string, "%s%c", meta, c); return (string); - } +} /* * process the reply string */ void chat_send (s) register char *s; - { - if (say_next) - { +{ + if (say_next) { say_next = 0; s = clean(s,0); write(2, s, strlen(s)); free(s); return; - } - if (hup_next) - { + } + + if (hup_next) { hup_next = 0; if (strcmp(s, "OFF") == 0) signal(SIGHUP, SIG_IGN); else signal(SIGHUP, sighup); return; - } - if (echo_next) - { + } + + if (echo_next) { echo_next = 0; echo = (strcmp(s, "ON") == 0); return; - } - if (abort_next) - { + } + + if (abort_next) { char *s1; abort_next = 0; if (n_aborts >= MAX_ABORTS) - { - fatal("Too many ABORT strings"); - } + fatal(2, "Too many ABORT strings"); s1 = clean(s, 0); if (strlen(s1) > strlen(s) || strlen(s1) + 1 > sizeof(fail_buffer)) - { - syslog(LOG_WARNING, "Illegal or too-long ABORT string ('%s')", s); - die(); - } + fatal(1, "Illegal or too-long ABORT string ('%v')", s); abort_string[n_aborts++] = s1; if (verbose) - { - logf("abort on ("); - - for (s1 = s; *s1; ++s1) - { - logf(character(*s1)); - } - - logf(")\n"); - } + logf("abort on (%v)", s); return; - } + } - if (clear_abort_next) - { + if (clear_abort_next) { char *s1; - char *s2 = s; int i; int old_max; int pack = 0; @@ -1096,76 +1005,46 @@ register char *s; if (strlen(s1) > strlen(s) || strlen(s1) + 1 > sizeof(fail_buffer)) - { - syslog(LOG_WARNING, "Illegal or too-long CLR_ABORT string ('%s')", s); - die(); - } + fatal(1, "Illegal or too-long CLR_ABORT string ('%v')", s); old_max = n_aborts; - for (i=0; i < n_aborts; i++) - { - if ( strcmp(s1,abort_string[i]) == 0 ) - { - free(abort_string[i]); - abort_string[i] = NULL; - pack++; - n_aborts--; - if (verbose) - { - logf("clear abort on ("); - - for (s2 = s; *s2; ++s2) - { - logf(character(*s2)); - } - - logf(")\n"); - } - } + for (i=0; i < n_aborts; i++) { + if ( strcmp(s1,abort_string[i]) == 0 ) { + free(abort_string[i]); + abort_string[i] = NULL; + pack++; + n_aborts--; + if (verbose) + logf("clear abort on (%v)", s); } + } free(s1); - if (pack) pack_array(abort_string,old_max); + if (pack) + pack_array(abort_string,old_max); return; - } + } - if (report_next) - { + if (report_next) { char *s1; report_next = 0; if (n_reports >= MAX_REPORTS) - { - fatal("Too many REPORT strings"); - } + fatal(2, "Too many REPORT strings"); s1 = clean(s, 0); if (strlen(s1) > strlen(s) || strlen(s1) > sizeof fail_buffer - 1) - { - syslog(LOG_WARNING, "Illegal or too-long REPORT string ('%s')", s); - die(); - } + fatal(1, "Illegal or too-long REPORT string ('%v')", s); report_string[n_reports++] = s1; if (verbose) - { - logf("report ("); - s1 = s; - while (*s1) - { - logf(character(*s1)); - ++s1; - } - logf(")\n"); - } + logf("report (%v)", s); return; - } + } - if (clear_report_next) - { + if (clear_report_next) { char *s1; - char *s2 = s; int i; int old_max; int pack = 0; @@ -1175,111 +1054,76 @@ register char *s; s1 = clean(s, 0); if (strlen(s1) > strlen(s) || strlen(s1) > sizeof fail_buffer - 1) - { - syslog(LOG_WARNING, "Illegal or too-long REPORT string ('%s')", s); - die(); - } + fatal(1, "Illegal or too-long REPORT string ('%v')", s); old_max = n_reports; - for (i=0; i < n_reports; i++) - { - if ( strcmp(s1,report_string[i]) == 0 ) - { - free(report_string[i]); - report_string[i] = NULL; - pack++; - n_reports--; - if (verbose) - { - logf("clear report ("); - - for (s2 = s; *s2; ++s2) - { - logf(character(*s2)); - } - - logf(")\n"); - } - } + for (i=0; i < n_reports; i++) { + if ( strcmp(s1,report_string[i]) == 0 ) { + free(report_string[i]); + report_string[i] = NULL; + pack++; + n_reports--; + if (verbose) + logf("clear report (%v)", s); } + } free(s1); - if (pack) pack_array(report_string,old_max); + if (pack) + pack_array(report_string,old_max); return; - } + } - if (timeout_next) - { + if (timeout_next) { timeout_next = 0; timeout = atoi(s); if (timeout <= 0) - { timeout = DEFAULT_CHAT_TIMEOUT; - } if (verbose) - { - syslog(LOG_INFO, "timeout set to %d seconds", timeout); - } + logf("timeout set to %d seconds", timeout); + return; - } + } if (strcmp(s, "EOT") == 0) - { s = "^D\\c"; - } - else - { - if (strcmp(s, "BREAK") == 0) - { - s = "\\K\\c"; - } - } + else if (strcmp(s, "BREAK") == 0) + s = "\\K\\c"; if (!put_string(s)) - { - syslog(LOG_INFO, "Failed"); - terminate(1); - } - } + fatal(1, "Failed"); +} int get_char() - { +{ int status; char c; status = read(0, &c, 1); - switch (status) - { + switch (status) { case 1: return ((int)c & 0x7F); default: - syslog(LOG_WARNING, "warning: read() on stdin returned %d", - status); + logf("warning: read() on stdin returned %d", status); case -1: if ((status = fcntl(0, F_GETFL, 0)) == -1) - { - sysfatal("Can't get file mode flags on stdin"); - } - else - { - if (fcntl(0, F_SETFL, status & ~O_NONBLOCK) == -1) - { - sysfatal("Can't set file mode flags on stdin"); - } - } + fatal(2, "Can't get file mode flags on stdin: %m"); + + if (fcntl(0, F_SETFL, status & ~O_NONBLOCK) == -1) + fatal(2, "Can't set file mode flags on stdin: %m"); return (-1); - } } +} int put_char(c) int c; - { +{ int status; char ch = c; @@ -1287,103 +1131,68 @@ int c; status = write(1, &ch, 1); - switch (status) - { + switch (status) { case 1: return (0); default: - syslog(LOG_WARNING, "warning: write() on stdout returned %d", - status); + logf("warning: write() on stdout returned %d", status); case -1: if ((status = fcntl(0, F_GETFL, 0)) == -1) - { - sysfatal("Can't get file mode flags on stdin"); - } - else - { - if (fcntl(0, F_SETFL, status & ~O_NONBLOCK) == -1) - { - sysfatal("Can't set file mode flags on stdin"); - } - } + fatal(2, "Can't get file mode flags on stdin, %m"); + + if (fcntl(0, F_SETFL, status & ~O_NONBLOCK) == -1) + fatal(2, "Can't set file mode flags on stdin: %m"); return (-1); - } } +} int write_char (c) int c; - { - if (alarmed || put_char(c) < 0) - { - extern int errno; - +{ + if (alarmed || put_char(c) < 0) { alarm(0); alarmed = 0; - if (verbose) - { + if (verbose) { if (errno == EINTR || errno == EWOULDBLOCK) - { - syslog(LOG_INFO, " -- write timed out"); - } + logf(" -- write timed out"); else - { - syslog(LOG_INFO, " -- write failed: %m"); - } - } - return (0); + logf(" -- write failed: %m"); } - return (1); + return (0); } + return (1); +} int put_string (s) register char *s; - { +{ quiet = 0; s = clean(s, 1); - if (verbose) - { - logf("send ("); - + if (verbose) { if (quiet) - { - logf("??????"); - } + logf("send (??????)"); else - { - register char *s1 = s; - - for (s1 = s; *s1; ++s1) - { - logf(character(*s1)); - } - } - - logf(")\n"); - } + logf("send (%v)", s); + } alarm(timeout); alarmed = 0; - while (*s) - { + while (*s) { register char c = *s++; - if (c != '\\') - { + if (c != '\\') { if (!write_char (c)) - { return 0; - } continue; - } + } c = *s++; - switch (c) - { + switch (c) { case 'd': sleep(1); break; @@ -1400,13 +1209,13 @@ register char *s; if (!write_char (c)) return 0; break; - } } + } alarm(0); alarmed = 0; return (1); - } +} /* * Echo a character to stderr. @@ -1415,39 +1224,39 @@ register char *s; */ void echo_stderr(n) int n; - { - static int need_lf; - char *s; +{ + static int need_lf; + char *s; - switch (n) - { - case '\r': /* ignore '\r' */ - break; - case -1: - if (need_lf == 0) - break; - /* fall through */ - case '\n': - write(2, "\n", 1); - need_lf = 0; - break; - default: - s = character(n); - write(2, s, strlen(s)); - need_lf = 1; + switch (n) { + case '\r': /* ignore '\r' */ + break; + case -1: + if (need_lf == 0) break; - } + /* fall through */ + case '\n': + write(2, "\n", 1); + need_lf = 0; + break; + default: + s = character(n); + write(2, s, strlen(s)); + need_lf = 1; + break; } +} /* * 'Wait for' this string to appear on this file descriptor. */ int get_string(string) register char *string; - { +{ char temp[STR_LEN]; int c, printed = 0, len, minlen; register char *s = temp, *end = s + STR_LEN; + char *logged = temp; fail_reason = (char *)0; string = clean(string, 0); @@ -1455,74 +1264,55 @@ register char *string; minlen = (len > sizeof(fail_buffer)? len: sizeof(fail_buffer)) - 1; if (verbose) - { - register char *s1; - - logf("expect ("); - - for (s1 = string; *s1; ++s1) - { - logf(character(*s1)); - } - - logf(")\n"); - } + logf("expect (%v)", string); - if (len > STR_LEN) - { - syslog(LOG_INFO, "expect string is too long"); + if (len > STR_LEN) { + logf("expect string is too long"); exit_code = 1; return 0; - } + } - if (len == 0) - { + if (len == 0) { if (verbose) - { - syslog(LOG_INFO, "got it"); - } - + logf("got it"); return (1); - } + } alarm(timeout); alarmed = 0; - while ( ! alarmed && (c = get_char()) >= 0) - { + while ( ! alarmed && (c = get_char()) >= 0) { int n, abort_len, report_len; if (echo) - { echo_stderr(c); - } - if (verbose) - { - if (c == '\n') - { - logf("\n"); - } + if (verbose && c == '\n') { + if (s == logged) + logf(""); /* blank line */ else - { - logf(character(c)); - } - } - - if (Verbose) { - if (c == '\n') fputc( '\n', stderr ); - else if (c != '\r') fprintf( stderr, "%s", character(c) ); + logf("%0.*v", s - logged, logged); + logged = s + 1; } *s++ = c; - if (!report_gathering) - { - for (n = 0; n < n_reports; ++n) - { + if (verbose && s >= logged + 80) { + logf("%0.*v", s - logged, logged); + logged = s; + } + + if (Verbose) { + if (c == '\n') + fputc( '\n', stderr ); + else if (c != '\r') + fprintf( stderr, "%s", character(c) ); + } + + if (!report_gathering) { + for (n = 0; n < n_reports; ++n) { if ((report_string[n] != (char*) NULL) && s - temp >= (report_len = strlen(report_string[n])) && - strncmp(s - report_len, report_string[n], report_len) == 0) - { + strncmp(s - report_len, report_string[n], report_len) == 0) { time_t time_now = time ((time_t*) NULL); struct tm* tm_now = localtime (&time_now); @@ -1532,87 +1322,80 @@ register char *string; report_string[n] = (char *) NULL; report_gathering = 1; break; - } - } + } } - else - { - if (!iscntrl (c)) - { + } + else { + if (!iscntrl (c)) { int rep_len = strlen (report_buffer); report_buffer[rep_len] = c; report_buffer[rep_len + 1] = '\0'; - } - else - { + } + else { report_gathering = 0; fprintf (report_fp, "chat: %s\n", report_buffer); - } } + } if (s - temp >= len && c == string[len - 1] && - strncmp(s - len, string, len) == 0) - { - if (verbose) - { + strncmp(s - len, string, len) == 0) { + if (verbose) { + if (s > logged) + logf("%0.*v", s - logged, logged); logf(" -- got it\n"); - } + } alarm(0); alarmed = 0; return (1); - } + } - for (n = 0; n < n_aborts; ++n) - { + for (n = 0; n < n_aborts; ++n) { if (s - temp >= (abort_len = strlen(abort_string[n])) && - strncmp(s - abort_len, abort_string[n], abort_len) == 0) - { - if (verbose) - { - logf(" -- failed\n"); - } - + strncmp(s - abort_len, abort_string[n], abort_len) == 0) { + if (verbose) { + if (s > logged) + logf("%0.*v", s - logged, logged); + logf(" -- failed"); + } + alarm(0); alarmed = 0; exit_code = n + 4; strcpy(fail_reason = fail_buffer, abort_string[n]); return (0); - } } + } - if (s >= end) - { - strncpy (temp, s - minlen, minlen); - s = temp + minlen; + if (s >= end) { + if (logged < s - minlen) { + logf("%0.*v", s - logged, logged); + logged = s; } + s -= minlen; + memmove(temp, s, minlen); + logged = temp + (logged - s); + s = temp + minlen; + } if (alarmed && verbose) - { - syslog(LOG_WARNING, "warning: alarm synchronization problem"); - } - } + logf("warning: alarm synchronization problem"); + } alarm(0); - if (verbose && printed) - { + if (verbose && printed) { if (alarmed) - { - logf(" -- read timed out\n"); - } + logf(" -- read timed out"); else - { - logflush(); - syslog(LOG_INFO, " -- read failed: %m"); - } - } + logf(" -- read failed: %m"); + } exit_code = 3; alarmed = 0; return (0); - } +} #ifdef NO_USLEEP #include <sys/types.h> @@ -1629,16 +1412,15 @@ int usleep( usec ) /* returns 0 if ok, else -1 */ long usec; /* delay in microseconds */ { - static struct /* `timeval' */ - { + static struct { /* `timeval' */ long tv_sec; /* seconds */ long tv_usec; /* microsecs */ - } delay; /* _select() timeout */ + } delay; /* _select() timeout */ delay.tv_sec = usec / 1000000L; delay.tv_usec = usec % 1000000L; - return select( 0, (long *)0, (long *)0, (long *)0, &delay ); + return select(0, (long *)0, (long *)0, (long *)0, &delay); } #endif @@ -1660,3 +1442,207 @@ pack_array (array, end) } } } + +/* + * vfmtmsg - format a message into a buffer. Like vsprintf except we + * also specify the length of the output buffer, and we handle the + * %m (error message) format. + * Doesn't do floating-point formats. + * Returns the number of chars put into buf. + */ +#define OUTCHAR(c) (buflen > 0? (--buflen, *buf++ = (c)): 0) + +int +vfmtmsg(buf, buflen, fmt, args) + char *buf; + int buflen; + const char *fmt; + va_list args; +{ + int c, i, n; + int width, prec, fillch; + int base, len, neg, quoted; + unsigned long val = 0; + char *str, *buf0; + const char *f; + unsigned char *p; + char num[32]; + static char hexchars[] = "0123456789abcdef"; + + buf0 = buf; + --buflen; + while (buflen > 0) { + for (f = fmt; *f != '%' && *f != 0; ++f) + ; + if (f > fmt) { + len = f - fmt; + if (len > buflen) + len = buflen; + memcpy(buf, fmt, len); + buf += len; + buflen -= len; + fmt = f; + } + if (*fmt == 0) + break; + c = *++fmt; + width = prec = 0; + fillch = ' '; + if (c == '0') { + fillch = '0'; + c = *++fmt; + } + if (c == '*') { + width = va_arg(args, int); + c = *++fmt; + } else { + while (isdigit(c)) { + width = width * 10 + c - '0'; + c = *++fmt; + } + } + if (c == '.') { + c = *++fmt; + if (c == '*') { + prec = va_arg(args, int); + c = *++fmt; + } else { + while (isdigit(c)) { + prec = prec * 10 + c - '0'; + c = *++fmt; + } + } + } + str = 0; + base = 0; + neg = 0; + ++fmt; + switch (c) { + case 'd': + i = va_arg(args, int); + if (i < 0) { + neg = 1; + val = -i; + } else + val = i; + base = 10; + break; + case 'o': + val = va_arg(args, unsigned int); + base = 8; + break; + case 'x': + val = va_arg(args, unsigned int); + base = 16; + break; + case 'p': + val = (unsigned long) va_arg(args, void *); + base = 16; + neg = 2; + break; + case 's': + str = va_arg(args, char *); + break; + case 'c': + num[0] = va_arg(args, int); + num[1] = 0; + str = num; + break; + case 'm': + str = strerror(errno); + break; + case 'v': /* "visible" string */ + case 'q': /* quoted string */ + quoted = c == 'q'; + p = va_arg(args, unsigned char *); + if (fillch == '0' && prec > 0) { + n = prec; + } else { + n = strlen((char *)p); + if (prec > 0 && prec < n) + n = prec; + } + while (n > 0 && buflen > 0) { + c = *p++; + --n; + if (!quoted && c >= 0x80) { + OUTCHAR('M'); + OUTCHAR('-'); + c -= 0x80; + } + if (quoted && (c == '"' || c == '\\')) + OUTCHAR('\\'); + if (c < 0x20 || (0x7f <= c && c < 0xa0)) { + if (quoted) { + OUTCHAR('\\'); + switch (c) { + case '\t': OUTCHAR('t'); break; + case '\n': OUTCHAR('n'); break; + case '\b': OUTCHAR('b'); break; + case '\f': OUTCHAR('f'); break; + default: + OUTCHAR('x'); + OUTCHAR(hexchars[c >> 4]); + OUTCHAR(hexchars[c & 0xf]); + } + } else { + if (c == '\t') + OUTCHAR(c); + else { + OUTCHAR('^'); + OUTCHAR(c ^ 0x40); + } + } + } else + OUTCHAR(c); + } + continue; + default: + *buf++ = '%'; + if (c != '%') + --fmt; /* so %z outputs %z etc. */ + --buflen; + continue; + } + if (base != 0) { + str = num + sizeof(num); + *--str = 0; + while (str > num + neg) { + *--str = hexchars[val % base]; + val = val / base; + if (--prec <= 0 && val == 0) + break; + } + switch (neg) { + case 1: + *--str = '-'; + break; + case 2: + *--str = 'x'; + *--str = '0'; + break; + } + len = num + sizeof(num) - 1 - str; + } else { + len = strlen(str); + if (prec > 0 && len > prec) + len = prec; + } + if (width > 0) { + if (width > buflen) + width = buflen; + if ((n = width - len) > 0) { + buflen -= n; + for (; n > 0; --n) + *buf++ = fillch; + } + } + if (len > buflen) + len = buflen; + memcpy(buf, str, len); + buf += len; + buflen -= len; + } + *buf = 0; + return buf - buf0; +} diff --git a/usr.sbin/pppd/demand.c b/usr.sbin/pppd/demand.c index f249bceb375..f72e61ecc09 100644 --- a/usr.sbin/pppd/demand.c +++ b/usr.sbin/pppd/demand.c @@ -1,4 +1,4 @@ -/* $OpenBSD: demand.c,v 1.4 1997/09/05 04:32:37 millert Exp $ */ +/* $OpenBSD: demand.c,v 1.5 1998/01/17 20:30:21 millert Exp $ */ /* * demand.c - Support routines for demand-dialling. @@ -21,9 +21,9 @@ #ifndef lint #if 0 -static char rcsid[] = "Id: demand.c,v 1.6 1997/04/30 05:51:56 paulus Exp"; +static char rcsid[] = "Id: demand.c,v 1.7 1997/11/27 06:08:26 paulus Exp $"; #else -static char rcsid[] = "$OpenBSD: demand.c,v 1.4 1997/09/05 04:32:37 millert Exp $"; +static char rcsid[] = "$OpenBSD: demand.c,v 1.5 1998/01/17 20:30:21 millert Exp $"; #endif #endif @@ -41,8 +41,8 @@ static char rcsid[] = "$OpenBSD: demand.c,v 1.4 1997/09/05 04:32:37 millert Exp #include <sys/resource.h> #include <sys/stat.h> #include <sys/socket.h> -#include <net/if.h> #ifdef PPP_FILTER +#include <net/if.h> #include <net/bpf.h> #include <pcap.h> #endif diff --git a/usr.sbin/pppd/fsm.c b/usr.sbin/pppd/fsm.c index a31b3f68d00..23eeb1bb290 100644 --- a/usr.sbin/pppd/fsm.c +++ b/usr.sbin/pppd/fsm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fsm.c,v 1.4 1997/09/05 04:32:37 millert Exp $ */ +/* $OpenBSD: fsm.c,v 1.5 1998/01/17 20:30:22 millert Exp $ */ /* * fsm.c - {Link, IP} Control Protocol Finite State Machine. @@ -23,7 +23,7 @@ #if 0 static char rcsid[] = "Id: fsm.c,v 1.13 1997/04/30 05:52:17 paulus Exp"; #else -static char rcsid[] = "$OpenBSD: fsm.c,v 1.4 1997/09/05 04:32:37 millert Exp $"; +static char rcsid[] = "$OpenBSD: fsm.c,v 1.5 1998/01/17 20:30:22 millert Exp $"; #endif #endif @@ -41,7 +41,7 @@ static char rcsid[] = "$OpenBSD: fsm.c,v 1.4 1997/09/05 04:32:37 millert Exp $"; #include "pppd.h" #include "fsm.h" -static void fsm_timeout __P((caddr_t)); +static void fsm_timeout __P((void *)); static void fsm_rconfreq __P((fsm *, int, u_char *, int)); static void fsm_rconfack __P((fsm *, int, u_char *, int)); static void fsm_rconfnakrej __P((fsm *, int, int, u_char *, int)); @@ -126,7 +126,7 @@ fsm_lowerdown(f) case CLOSING: f->state = INITIAL; - UNTIMEOUT(fsm_timeout, (caddr_t) f); /* Cancel timeout */ + UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ break; case STOPPING: @@ -134,7 +134,7 @@ fsm_lowerdown(f) case ACKRCVD: case ACKSENT: f->state = STARTING; - UNTIMEOUT(fsm_timeout, (caddr_t) f); /* Cancel timeout */ + UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ break; case OPENED: @@ -217,7 +217,7 @@ fsm_close(f, reason) case ACKSENT: case OPENED: if( f->state != OPENED ) - UNTIMEOUT(fsm_timeout, (caddr_t) f); /* Cancel timeout */ + UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ else if( f->callbacks->down ) (*f->callbacks->down)(f); /* Inform upper layers we're down */ @@ -225,7 +225,7 @@ fsm_close(f, reason) f->retransmits = f->maxtermtransmits; fsm_sdata(f, TERMREQ, f->reqid = ++f->id, (u_char *) f->term_reason, f->term_reason_len); - TIMEOUT(fsm_timeout, (caddr_t) f, f->timeouttime); + TIMEOUT(fsm_timeout, f, f->timeouttime); --f->retransmits; f->state = CLOSING; @@ -239,7 +239,7 @@ fsm_close(f, reason) */ static void fsm_timeout(arg) - caddr_t arg; + void *arg; { fsm *f = (fsm *) arg; @@ -257,7 +257,7 @@ fsm_timeout(arg) /* Send Terminate-Request */ fsm_sdata(f, TERMREQ, f->reqid = ++f->id, (u_char *) f->term_reason, f->term_reason_len); - TIMEOUT(fsm_timeout, (caddr_t) f, f->timeouttime); + TIMEOUT(fsm_timeout, f, f->timeouttime); --f->retransmits; } break; @@ -424,7 +424,7 @@ fsm_rconfreq(f, id, inp, len) if (code == CONFACK) { if (f->state == ACKRCVD) { - UNTIMEOUT(fsm_timeout, (caddr_t) f); /* Cancel timeout */ + UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ f->state = OPENED; if (f->callbacks->up) (*f->callbacks->up)(f); /* Inform upper layers */ @@ -480,13 +480,13 @@ fsm_rconfack(f, id, inp, len) case ACKRCVD: /* Huh? an extra valid Ack? oh well... */ - UNTIMEOUT(fsm_timeout, (caddr_t) f); /* Cancel timeout */ + UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ fsm_sconfreq(f, 0); f->state = REQSENT; break; case ACKSENT: - UNTIMEOUT(fsm_timeout, (caddr_t) f); /* Cancel timeout */ + UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ f->state = OPENED; f->retransmits = f->maxconfreqtransmits; if (f->callbacks->up) @@ -541,7 +541,7 @@ fsm_rconfnakrej(f, code, id, inp, len) case REQSENT: case ACKSENT: /* They didn't agree to what we wanted - try another request */ - UNTIMEOUT(fsm_timeout, (caddr_t) f); /* Cancel timeout */ + UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ if (ret < 0) f->state = STOPPED; /* kludge for stopping CCP */ else @@ -550,7 +550,7 @@ fsm_rconfnakrej(f, code, id, inp, len) case ACKRCVD: /* Got a Nak/reject when we had already had an Ack?? oh well... */ - UNTIMEOUT(fsm_timeout, (caddr_t) f); /* Cancel timeout */ + UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ fsm_sconfreq(f, 0); f->state = REQSENT; break; @@ -597,7 +597,7 @@ fsm_rtermreq(f, id, p, len) (*f->callbacks->down)(f); /* Inform upper layers */ f->retransmits = 0; f->state = STOPPING; - TIMEOUT(fsm_timeout, (caddr_t) f, f->timeouttime); + TIMEOUT(fsm_timeout, f, f->timeouttime); break; } @@ -616,13 +616,13 @@ fsm_rtermack(f) switch (f->state) { case CLOSING: - UNTIMEOUT(fsm_timeout, (caddr_t) f); + UNTIMEOUT(fsm_timeout, f); f->state = CLOSED; if( f->callbacks->finished ) (*f->callbacks->finished)(f); break; case STOPPING: - UNTIMEOUT(fsm_timeout, (caddr_t) f); + UNTIMEOUT(fsm_timeout, f); f->state = STOPPED; if( f->callbacks->finished ) (*f->callbacks->finished)(f); @@ -679,7 +679,7 @@ fsm_protreject(f) { switch( f->state ){ case CLOSING: - UNTIMEOUT(fsm_timeout, (caddr_t) f); /* Cancel timeout */ + UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ /* fall through */ case CLOSED: f->state = CLOSED; @@ -691,7 +691,7 @@ fsm_protreject(f) case REQSENT: case ACKRCVD: case ACKSENT: - UNTIMEOUT(fsm_timeout, (caddr_t) f); /* Cancel timeout */ + UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ /* fall through */ case STOPPED: f->state = STOPPED; @@ -707,7 +707,7 @@ fsm_protreject(f) f->retransmits = f->maxtermtransmits; fsm_sdata(f, TERMREQ, f->reqid = ++f->id, (u_char *) f->term_reason, f->term_reason_len); - TIMEOUT(fsm_timeout, (caddr_t) f, f->timeouttime); + TIMEOUT(fsm_timeout, f, f->timeouttime); --f->retransmits; f->state = STOPPING; @@ -764,7 +764,7 @@ fsm_sconfreq(f, retransmit) /* start the retransmit timer */ --f->retransmits; - TIMEOUT(fsm_timeout, (caddr_t) f, f->timeouttime); + TIMEOUT(fsm_timeout, f, f->timeouttime); FSMDEBUG((LOG_INFO, "%s: sending Configure-Request, id %d", PROTO_NAME(f), f->reqid)); diff --git a/usr.sbin/pppd/ipxcp.c b/usr.sbin/pppd/ipxcp.c index 86387bd8add..aa7702c159d 100644 --- a/usr.sbin/pppd/ipxcp.c +++ b/usr.sbin/pppd/ipxcp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ipxcp.c,v 1.3 1997/09/05 04:32:39 millert Exp $ */ +/* $OpenBSD: ipxcp.c,v 1.4 1998/01/17 20:30:22 millert Exp $ */ /* * ipxcp.c - PPP IPX Control Protocol. @@ -24,7 +24,7 @@ #if 0 static char rcsid[] = "Id: ipxcp.c,v 1.5 1997/03/04 03:39:32 paulus Exp"; #else -static char rcsid[] = "$OpenBSD: ipxcp.c,v 1.3 1997/09/05 04:32:39 millert Exp $"; +static char rcsid[] = "$OpenBSD: ipxcp.c,v 1.4 1998/01/17 20:30:22 millert Exp $"; #endif #endif @@ -42,6 +42,7 @@ static char rcsid[] = "$OpenBSD: ipxcp.c,v 1.3 1997/09/05 04:32:39 millert Exp $ #include "pppd.h" #include "fsm.h" #include "ipxcp.h" +#include "magic.h" #include "pathnames.h" /* global vars */ @@ -169,7 +170,7 @@ ipx_ntoa(ipxaddr) u_int32_t ipxaddr; { static char b[64]; - sprintf(b, "%lx", ipxaddr); + sprintf(b, "%x", ipxaddr); return b; } @@ -342,8 +343,6 @@ static void ipxcp_resetci(f) fsm *f; { - u_int32_t network; - int unit = f->unit; wo->req_node = wo->neg_node && ao->neg_node; wo->req_nn = wo->neg_nn && ao->neg_nn; @@ -393,7 +392,6 @@ static int ipxcp_cilen(f) fsm *f; { - int unit = f->unit; int len; len = go->neg_nn ? CILEN_NETN : 0; @@ -417,8 +415,6 @@ ipxcp_addci(f, ucp, lenp) u_char *ucp; int *lenp; { - int len = *lenp; - int unit = f->unit; /* * Add the options to the record. */ @@ -468,7 +464,6 @@ ipxcp_ackci(f, p, len) u_char *p; int len; { - int unit = f->unit; u_short cilen, citype, cishort; u_char cichar; u_int32_t cilong; @@ -577,7 +572,6 @@ ipxcp_nakci(f, p, len) u_char *p; int len; { - int unit = f->unit; u_char citype, cilen, *next; u_short s; u_int32_t l; @@ -696,7 +690,6 @@ ipxcp_rejci(f, p, len) u_char *p; int len; { - int unit = f->unit; u_short cilen, citype, cishort; u_char cichar; u_int32_t cilong; @@ -813,17 +806,15 @@ ipxcp_reqci(f, inp, len, reject_if_disagree) int *len; /* Length of requested CIs */ int reject_if_disagree; { - int unit = f->unit; u_char *cip, *next; /* Pointer to current and next CIs */ u_short cilen, citype; /* Parsed len, type */ - u_short cishort, ts; /* Parsed short value */ - u_int32_t tl, cinetwork, outnet;/* Parsed address values */ + u_short cishort; /* Parsed short value */ + u_int32_t tl, cinetwork; /* Parsed address values */ int rc = CONFACK; /* Final packet return code */ int orc; /* Individual option return code */ u_char *p; /* Pointer to next char to parse */ u_char *ucp = inp; /* Pointer to current output char */ int l = *len; /* Length left */ - u_char maxslotindex, cflag; /* * Reset all his options. @@ -865,7 +856,7 @@ ipxcp_reqci(f, inp, len, reject_if_disagree) break; } GETLONG(cinetwork, p); - IPXCPDEBUG((LOG_INFO,"Remote proposed IPX network number is %8Lx",tl)); + IPXCPDEBUG((LOG_INFO,"Remote proposed IPX network number is %8x",tl)); /* If the network numbers match then acknowledge them. */ if (cinetwork != 0) { @@ -1100,7 +1091,6 @@ endswitch: if (rc != CONFREJ && !ho->neg_node && wo->req_nn && !reject_if_disagree) { - u_char *ps; if (rc == CONFACK) { rc = CONFNAK; wo->req_nn = 0; /* don't ask again */ @@ -1203,7 +1193,6 @@ static void ipxcp_down(f) fsm *f; { - u_int32_t ournn, network; IPXCPDEBUG((LOG_INFO, "ipxcp: down")); @@ -1222,7 +1211,6 @@ ipxcp_script(f, script) fsm *f; char *script; { - int unit = f->unit; char strspeed[32], strlocal[32], strremote[32]; char strnetwork[32], strpid[32]; char *argv[14], strproto_lcl[32], strproto_rmt[32]; diff --git a/usr.sbin/pppd/lcp.c b/usr.sbin/pppd/lcp.c index 7900fbd43b3..5acc924395a 100644 --- a/usr.sbin/pppd/lcp.c +++ b/usr.sbin/pppd/lcp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lcp.c,v 1.5 1997/09/05 04:32:40 millert Exp $ */ +/* $OpenBSD: lcp.c,v 1.6 1998/01/17 20:30:24 millert Exp $ */ /* * lcp.c - PPP Link Control Protocol. @@ -21,9 +21,9 @@ #ifndef lint #if 0 -static char rcsid[] = "Id: lcp.c,v 1.30 1997/04/30 05:52:59 paulus Exp"; +static char rcsid[] = "Id: lcp.c,v 1.31 1997/11/27 06:08:44 paulus Exp $"; #else -static char rcsid[] = "$OpenBSD: lcp.c,v 1.5 1997/09/05 04:32:40 millert Exp $"; +static char rcsid[] = "$OpenBSD: lcp.c,v 1.6 1998/01/17 20:30:24 millert Exp $"; #endif #endif @@ -84,7 +84,7 @@ static void lcp_rprotrej __P((fsm *, u_char *, int)); static void lcp_echo_lowerup __P((int)); static void lcp_echo_lowerdown __P((int)); -static void LcpEchoTimeout __P((caddr_t)); +static void LcpEchoTimeout __P((void *)); static void lcp_received_echo_reply __P((fsm *, int, u_char *, int)); static void LcpSendEchoRequest __P((fsm *)); static void LcpLinkFailure __P((fsm *)); @@ -272,7 +272,7 @@ lcp_lowerup(unit) */ ppp_set_xaccm(unit, xmit_accm[unit]); ppp_send_config(unit, PPP_MRU, 0xffffffff, 0, 0); - ppp_recv_config(unit, PPP_MRU, 0x00000000, + ppp_recv_config(unit, PPP_MRU, 0xffffffff, wo->neg_pcompression, wo->neg_accompression); peer_mru[unit] = PPP_MRU; lcp_allowoptions[unit].asyncmap = xmit_accm[unit][0]; @@ -791,7 +791,7 @@ lcp_nakci(f, p, len) */ if (go->neg_mru && go->mru != DEFMRU) { NAKCISHORT(CI_MRU, neg_mru, - if (cishort <= wo->mru || cishort < DEFMRU) + if (cishort <= wo->mru || cishort <= DEFMRU) try.mru = cishort; ); } @@ -1490,13 +1490,8 @@ lcp_up(f) ppp_send_config(f->unit, MIN(ao->mru, (ho->neg_mru? ho->mru: PPP_MRU)), (ho->neg_asyncmap? ho->asyncmap: 0xffffffff), ho->neg_pcompression, ho->neg_accompression); - /* - * If the asyncmap hasn't been negotiated, we really should - * set the receive asyncmap to ffffffff, but we set it to 0 - * for backwards contemptibility. - */ ppp_recv_config(f->unit, (go->neg_mru? MAX(wo->mru, go->mru): PPP_MRU), - (go->neg_asyncmap? go->asyncmap: 0x00000000), + (go->neg_asyncmap? go->asyncmap: 0xffffffff), go->neg_pcompression, go->neg_accompression); if (ho->neg_mru) @@ -1525,7 +1520,7 @@ lcp_down(f) ppp_send_config(f->unit, PPP_MRU, 0xffffffff, 0, 0); ppp_recv_config(f->unit, PPP_MRU, - (go->neg_asyncmap? go->asyncmap: 0x00000000), + (go->neg_asyncmap? go->asyncmap: 0xffffffff), go->neg_pcompression, go->neg_accompression); peer_mru[f->unit] = PPP_MRU; } @@ -1753,7 +1748,7 @@ LcpEchoCheck (f) * Start the timer for the next interval. */ assert (lcp_echo_timer_running==0); - TIMEOUT (LcpEchoTimeout, (caddr_t) f, lcp_echo_interval); + TIMEOUT (LcpEchoTimeout, f, lcp_echo_interval); lcp_echo_timer_running = 1; } @@ -1763,7 +1758,7 @@ LcpEchoCheck (f) static void LcpEchoTimeout (arg) - caddr_t arg; + void *arg; { if (lcp_echo_timer_running != 0) { lcp_echo_timer_running = 0; @@ -1813,7 +1808,7 @@ LcpSendEchoRequest (f) * Detect the failure of the peer at this point. */ if (lcp_echo_fails != 0) { - if (lcp_echos_pending++ >= lcp_echo_fails) { + if (lcp_echos_pending >= lcp_echo_fails) { LcpLinkFailure(f); lcp_echos_pending = 0; } @@ -1827,6 +1822,7 @@ LcpSendEchoRequest (f) pktp = pkt; PUTLONG(lcp_magic, pktp); fsm_sdata(f, ECHOREQ, lcp_echo_number++ & 0xFF, pkt, pktp - pkt); + ++lcp_echos_pending; } } @@ -1861,7 +1857,7 @@ lcp_echo_lowerdown (unit) fsm *f = &lcp_fsm[unit]; if (lcp_echo_timer_running != 0) { - UNTIMEOUT (LcpEchoTimeout, (caddr_t) f); + UNTIMEOUT (LcpEchoTimeout, f); lcp_echo_timer_running = 0; } } diff --git a/usr.sbin/pppd/main.c b/usr.sbin/pppd/main.c index 16fb43056ca..aa69550c03f 100644 --- a/usr.sbin/pppd/main.c +++ b/usr.sbin/pppd/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.20 1997/11/14 00:16:14 millert Exp $ */ +/* $OpenBSD: main.c,v 1.21 1998/01/17 20:30:25 millert Exp $ */ /* * main.c - Point-to-Point Protocol main module @@ -20,7 +20,11 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: main.c,v 1.20 1997/11/14 00:16:14 millert Exp $"; +#if 0 +static char rcsid[] = "Id: main.c,v 1.43 1997/11/27 06:09:20 paulus Exp $"; +#else +static char rcsid[] = "$OpenBSD: main.c,v 1.21 1998/01/17 20:30:25 millert Exp $"; +#endif #endif #include <stdio.h> @@ -117,7 +121,7 @@ static void chld __P((int)); static void toggle_debug __P((int)); static void open_ccp __P((int)); static void bad_signal __P((int)); -static void holdoff_end __P((caddr_t)); +static void holdoff_end __P((void *)); static int device_script __P((char *, int, int)); static void reap_kids __P((void)); static void pr_log __P((void *, char *, ...)); @@ -163,7 +167,7 @@ main(argc, argv) int argc; char *argv[]; { - int i, nonblock, fdflags; + int i, fdflags; struct sigaction sa; FILE *pidfile; char *p; @@ -437,6 +441,7 @@ main(argc, argv) || fcntl(ttyfd, F_SETFL, fdflags & ~O_NONBLOCK) < 0) syslog(LOG_WARNING, "Couldn't reset non-blocking mode on device: %m"); + hungup = 0; kill_link = 0; @@ -450,18 +455,21 @@ main(argc, argv) } else tty_mode = statbuf.st_mode; - /* - * Set line speed, flow control, etc. - * Note that unless modem_chat is set the chat script has - * no way of noticing if carrier drops. This is a necessary - * evil for systems without cua devices. - */ - set_up_tty(ttyfd, (modem_chat == 0)); - /* run connection script */ if (connector && connector[0]) { MAINDEBUG((LOG_INFO, "Connecting with <%s>", connector)); + /* + * Set line speed, flow control, etc. + * On most systems we set CLOCAL for now so that we can talk + * to the modem before carrier comes up. But this has the + * side effect that we might miss it if CD drops before we + * get to clear CLOCAL below. On systems where we can talk + * successfully to the modem with CLOCAL clear and CD down, + * we can clear CLOCAL at this point. + */ + set_up_tty(ttyfd, (modem_chat == 0)); + /* drop dtr to hang up in case modem is off hook */ if (!default_device && modem) { setdtr(ttyfd, FALSE); @@ -584,7 +592,7 @@ main(argc, argv) } if (!persist) - break; + die(1); if (demand) demand_discard(); @@ -614,7 +622,7 @@ main(argc, argv) */ static void holdoff_end(arg) - caddr_t arg; + void *arg; { phase = PHASE_DORMANT; } @@ -769,8 +777,8 @@ close_tty() struct callout { struct timeval c_time; /* time at which to call routine */ - caddr_t c_arg; /* argument to routine */ - void (*c_func) __P((caddr_t)); /* routine */ + void *c_arg; /* argument to routine */ + void (*c_func) __P((void *)); /* routine */ struct callout *c_next; }; @@ -785,8 +793,8 @@ static struct timeval timenow; /* Current time */ */ void timeout(func, arg, time) - void (*func) __P((caddr_t)); - caddr_t arg; + void (*func) __P((void *)); + void *arg; int time; { struct callout *newp, *p, **pp; @@ -825,8 +833,8 @@ timeout(func, arg, time) */ void untimeout(func, arg) - void (*func) __P((caddr_t)); - caddr_t arg; + void (*func) __P((void *)); + void *arg; { struct callout **copp, *freep; diff --git a/usr.sbin/pppd/options.c b/usr.sbin/pppd/options.c index 2ee306d84d1..6a38bf88f5e 100644 --- a/usr.sbin/pppd/options.c +++ b/usr.sbin/pppd/options.c @@ -1,4 +1,4 @@ -/* $OpenBSD: options.c,v 1.10 1997/10/25 05:09:57 millert Exp $ */ +/* $OpenBSD: options.c,v 1.11 1998/01/17 20:30:26 millert Exp $ */ /* * options.c - handles option processing for PPP. @@ -21,9 +21,9 @@ #ifndef lint #if 0 -static char rcsid[] = "Id: options.c,v 1.39 1997/07/14 03:53:34 paulus Exp"; +static char rcsid[] = "Id: options.c,v 1.40 1997/11/27 06:09:34 paulus Exp $"; #else -static char rcsid[] = "$OpenBSD: options.c,v 1.10 1997/10/25 05:09:57 millert Exp $"; +static char rcsid[] = "$OpenBSD: options.c,v 1.11 1998/01/17 20:30:26 millert Exp $"; #endif #endif @@ -166,7 +166,7 @@ static int setescape __P((char **)); static int setmru __P((char **)); static int setmtu __P((char **)); #ifdef CBCP_SUPPORT -static int setcbcp __P((char *)); +static int setcbcp __P((char **)); #endif static int nomru __P((char **)); static int nopcomp __P((char **)); @@ -258,7 +258,7 @@ static int setipxcpfails __P((char **)); #endif /* IPX_CHANGE */ #ifdef MSLANMAN -static int setmslanman __P((void)); +static int setmslanman __P((char **)); #endif static int number_option __P((char *, u_int32_t *, int)); @@ -2445,6 +2445,7 @@ setipxanet(argv) { ipxcp_wantoptions[0].accept_network = 1; ipxcp_allowoptions[0].accept_network = 1; + return 1; } static int @@ -2453,6 +2454,7 @@ setipxalcl(argv) { ipxcp_wantoptions[0].accept_local = 1; ipxcp_allowoptions[0].accept_local = 1; + return 1; } static int @@ -2461,6 +2463,7 @@ setipxarmt(argv) { ipxcp_wantoptions[0].accept_remote = 1; ipxcp_allowoptions[0].accept_remote = 1; + return 1; } static u_char * @@ -2538,7 +2541,8 @@ resetipxproto(argv) #ifdef MSLANMAN static int -setmslanman() +setmslanman(argv) + char **argv; { ms_lanman = 1; return (1); diff --git a/usr.sbin/pppd/patchlevel.h b/usr.sbin/pppd/patchlevel.h index b7c40c8be37..d32fb0adb33 100644 --- a/usr.sbin/pppd/patchlevel.h +++ b/usr.sbin/pppd/patchlevel.h @@ -1,8 +1,8 @@ -/* $OpenBSD: patchlevel.h,v 1.5 1997/09/05 04:32:44 millert Exp $ */ -/* Id: patchlevel.h,v 1.29 1997/07/14 03:53:42 paulus Exp */ +/* $OpenBSD: patchlevel.h,v 1.6 1998/01/17 20:30:26 millert Exp $ */ +/* Id: patchlevel.h,v 1.30 1997/11/27 06:09:44 paulus Exp $ */ -#define PATCHLEVEL 1 +#define PATCHLEVEL 3 #define VERSION "2.3" #define IMPLEMENTATION "" -#define DATE "27 June 97" +#define DATE "11 December 1997" diff --git a/usr.sbin/pppd/pppd.8 b/usr.sbin/pppd/pppd.8 index 6820acca236..b3dfddab88b 100644 --- a/usr.sbin/pppd/pppd.8 +++ b/usr.sbin/pppd/pppd.8 @@ -1,5 +1,6 @@ -.\" $OpenBSD: pppd.8,v 1.12 1997/11/17 18:15:14 millert Exp $ +.\" $OpenBSD: pppd.8,v 1.13 1998/01/17 20:30:27 millert Exp $ .\" manual page [] for pppd 2.3 +.\" Id: pppd.8,v 1.26 1997/04/30 05:56:22 paulus Exp $ .\" SH section heading .\" SS subsection heading .\" LP paragraph @@ -27,19 +28,17 @@ a family of Network Control Protocols (NCP) for establishing and configuring different network-layer protocols. .LP The encapsulation scheme is provided by driver code in the kernel. -.B pppd -provides the basic LCP, authentication support, and an -NCP for establishing and configuring the Internet Protocol (IP) -(called the IP Control Protocol, IPCP). +Pppd provides the basic LCP, authentication support, and an NCP for +establishing and configuring the Internet Protocol (IP) (called the IP +Control Protocol, IPCP). .SH FREQUENTLY USED OPTIONS .TP .I <tty_name> -Communicate over the named device. The string "/dev/" -is prepended if necessary. If no device name is given, -or if the name of the controlling terminal is given, -.I pppd -will use the controlling terminal, and will not fork to put itself in -the background. This option is privileged if the \fInoauth\fR option is +Communicate over the named device. The string "/dev/" is prepended if +necessary. If no device name is given, or if the name of the terminal +connected to the standard input is given, pppd +will use that terminal, and will not fork to put itself in the +background. This option is privileged if the \fInoauth\fR option is used. .TP .I <speed> @@ -47,21 +46,33 @@ Set the baud rate to <speed> (a decimal number). On systems such as 4.4BSD and OpenBSD, any speed can be specified. Other systems (e.g. SunOS) allow only a limited set of speeds. .TP +.B active-filter \fIfilter-expression +Specifies a packet filter to be applied to data packets to determine +which packets are to be regarded as link activity, and therefore reset +the idle timer, or cause the link to be brought up in demand-dialling +mode. This option is useful in conjunction with the +\fBidle\fR option if there are packets being sent or received +regularly over the link (for example, routing information packets) +which would otherwise prevent the link from ever appearing to be idle. +The \fIfilter-expression\fR syntax is as described for tcpdump(1), +except that qualifiers which are inappropriate for a PPP link, such as +\fBether\fR and \fBarp\fR, are not permitted. Generally the filter +expression should be enclosed in single-quotes to prevent whitespace +in the expression from being interpreted by the shell. This option +is currently only available under OpenBSD, and then only +if both the kernel and pppd were compiled with PPP_FILTER defined. +.TP .B asyncmap \fI<map> Set the async character map to <map>. This map describes which control characters cannot be successfully received over the serial -line. -.I pppd -will ask the peer to send these characters as a 2-byte escape sequence. -The argument is a 32 bit hex number with each bit representing a character -to escape. -Bit 0 (00000001) represents the character 0x00; -bit 31 (80000000) represents the character 0x1f or ^_. -If multiple \fBasyncmap\fR options are -given, the values are ORed together. -If no \fBasyncmap\fR option is given, no async character map will be -negotiated for the receive direction; the peer should then escape -\fIall\fR control characters. To escape transmitted +line. Pppd will ask the peer to send these characters as a 2-byte +escape sequence. The argument is a 32 bit hex number with each bit +representing a character to escape. Bit 0 (00000001) represents the +character 0x00; bit 31 (80000000) represents the character 0x1f or ^_. +If multiple \fIasyncmap\fR options are given, the values are ORed +together. If no \fIasyncmap\fR option is given, no async character +map will be negotiated for the receive direction; the peer should then +escape \fIall\fR control characters. To escape transmitted characters, use the \fIescape\fR option. .TP .B auth @@ -75,38 +86,39 @@ is not being run by root. The \fIname\fR string may not begin with / or include .. as a pathname component. The format of the options file is described below. .TP -.B connect \fI<p> -Use the executable or shell command specified by \fI<p>\fR to set +.B connect \fIscript +Use the executable or shell command specified by \fIscript\fR to set up the serial line. This script would typically use the chat(8) -program to dial the modem and start the remote ppp session. This -option is privileged if the \fBnoauth\fR option is used. +program to dial the modem and start the remote ppp session. This +option is privileged if the \fInoauth\fR option is used. .TP .B crtscts Use hardware flow control (i.e. RTS/CTS) to control the flow of data -on the serial port. If neither the \fBcrtscts\fR nor the -\fB\-crtscts\fR option is given, the hardware flow control setting +on the serial port. If neither the \fIcrtscts\fR nor the +\fInocrtscts\fR option is given, the hardware flow control setting for the serial port is left unchanged. .TP .B defaultroute Add a default route to the system routing tables, using the peer as the gateway, when IPCP negotiation is successfully completed. This entry is removed when the PPP connection is broken. This option -is privileged if the \fBnodefaultroute\fR option has been specified. +is privileged if the \fInodefaultroute\fR option has been specified. .TP .B disconnect \fIscript Run the executable or shell command specified by \fIscript\fR after -\fIpppd\fR has terminated the link. This script could, for example, -issue commands to the modem to cause it to hang up if hardware modem -control signals were not available. This option is privileged if the -\fBnoauth\fR option is used. +pppd has terminated the link. This script could, for example, issue +commands to the modem to cause it to hang up if hardware modem control +signals were not available. The disconnect script is not run if the +modem has already hung up. This option is privileged if the +\fInoauth\fR option is used. .TP .B escape \fIxx,yy,... Specifies that certain characters should be escaped on transmission (regardless of whether the peer requests them to be escaped with its async control character map). The characters to be escaped are specified as a list of hex numbers separated by commas. Note that -almost any character can be specified for the \fBescape\fR option, -unlike the \fBasyncmap\fR option which only allows control characters +almost any character can be specified for the \fIescape\fR option, +unlike the \fIasyncmap\fR option which only allows control characters to be specified. The characters which may not be escaped are those with hex values 0x20 - 0x3f or 0x5e. .TP @@ -115,31 +127,27 @@ Read options from file \fIname\fR (the format is described below). The file must be readable by the user who has invoked pppd. .TP .B lock -Specifies that \fIpppd\fR should create a UUCP-style lock file for the +Specifies that pppd should create a UUCP-style lock file for the serial device to ensure exclusive access to the device. .TP -.B mru \fI<n> -Set the MRU [Maximum Receive Unit] value to <n> for negotiation. -.I pppd -will ask the peer to send packets of no more than <n> bytes. The +.B mru \fIn +Set the MRU [Maximum Receive Unit] value to \fIn\fR. Pppd +will ask the peer to send packets of no more than \fIn\fR bytes. The minimum MRU value is 128. The default MRU value is 1500. A value of 296 is recommended for slow links (40 bytes for TCP/IP header + 256 bytes of data). .TP -.B mtu \fI<n> -Set the MTU [Maximum Transmit Unit] value to \fI<n>\fR. Unless the -peer requests a smaller value via MRU negotiation, \fIpppd\fR will +.B mtu \fIn +Set the MTU [Maximum Transmit Unit] value to \fIn\fR. Unless the +peer requests a smaller value via MRU negotiation, pppd will request that the kernel networking code send data packets of no more than \fIn\fR bytes through the PPP network interface. .TP .B passive -Enables the "passive" option in the LCP. With this option, -.I pppd -will attempt to initiate a connection; if no reply is received from -the peer, -.I pppd -will then just wait passively for a valid LCP packet from the peer -(instead of exiting, as it does without this option). +Enables the "passive" option in the LCP. With this option, pppd will +attempt to initiate a connection; if no reply is received from the +peer, pppd will then just wait passively for a valid LCP packet from +the peer, instead of exiting, as it would without this option. .SH OPTIONS .TP .I <local_IP_address>\fB:\fI<remote_IP_address> @@ -151,11 +159,10 @@ address is the (first) IP address of the system (unless the option is given). The remote address will be obtained from the peer if not specified in any option. Thus, in simple cases, this option is not required. If a local and/or remote IP address is specified with -this option, -.I pppd +this option, pppd will not accept a different value from the peer in the IPCP -negotiation, unless the \fBipcp-accept-local\fR and/or -\fBipcp-accept-remote\fR options are given, respectively. +negotiation, unless the \fIipcp-accept-local\fR and/or +\fIipcp-accept-remote\fR options are given, respectively. .TP .B bsdcomp \fInr,nt Request that the peer compress packets that it sends, using the @@ -166,24 +173,24 @@ given for \fInr\fR. Values in the range 9 to 15 may be used for \fInr\fR and \fInt\fR; larger values give better compression but consume more kernel memory for compression dictionaries. Alternatively, a value of 0 for \fInr\fR or \fInt\fR disables -compression in the corresponding direction. +compression in the corresponding direction. Use \fInobsdcomp\fR or +\fIbsdcomp 0\fR to disable BSD-Compress compression entirely. .TP -.B chap-interval \fI<n> -If this option is given, -.I pppd -will rechallenge the peer every <n> seconds. +.B chap-interval \fIn +If this option is given, pppd will rechallenge the peer every \fIn\fR +seconds. .TP -.B chap-max-challenge \fI<n> -Set the maximum number of CHAP challenge transmissions to <n> (default -10). +.B chap-max-challenge \fIn +Set the maximum number of CHAP challenge transmissions to \fIn\fR +(default 10). .TP -.B chap-restart \fI<n> +.B chap-restart \fIn Set the CHAP restart interval (retransmission timeout for challenges) -to <n> seconds (default 3). +to \fIn\fR seconds (default 3). .TP .B debug -Increase debugging level (same as \fB\-d\fR). -If this option is given, \fIpppd\fR will log the contents of all +Enables connection debugging facilities. +If this option is given, pppd will log the contents of all control packets sent or received in a readable form. The packets are logged through syslog with facility \fIdaemon\fR and level \fIdebug\fR. This information can be directed to a file by setting up @@ -200,76 +207,80 @@ transmit and receive direction. .TP .B deflate \fInr,nt Request that the peer compress packets that it sends, using the -Deflate scheme, with a maximum window size of \fI2**nr\fR bits, and -agree to compress packets sent to the peer with a maximum window size of -\fI2**nt\fR bits. If \fInt\fR is not specified, it defaults to the value -given for \fInr\fR. Values in the range 8 to 15 may be used for -\fInr\fR and \fInt\fR; larger values give better compression but +Deflate scheme, with a maximum window size of \fI2**nr\fR bytes, and +agree to compress packets sent to the peer with a maximum window size +of \fI2**nt\fR bytes. If \fInt\fR is not specified, it defaults to +the value given for \fInr\fR. Values in the range 8 to 15 may be used +for \fInr\fR and \fInt\fR; larger values give better compression but consume more kernel memory for compression dictionaries. Alternatively, a value of 0 for \fInr\fR or \fInt\fR disables -compression in the corresponding direction. (Note: \fBpppd\fR -requests Deflate compression in preference to BSD-Compress -if the peer can do either.) +compression in the corresponding direction. Use \fInodeflate\fR or +\fIdeflate 0\fR to disable Deflate compression entirely. (Note: pppd +requests Deflate compression in preference to BSD-Compress if the peer +can do either.) .TP .B demand Initiate the link only on demand, i.e. when data traffic is present. -With this option, the remote IP address must be specific by the user -on the command line or in an options file. \fBpppd\fR will initially +With this option, the remote IP address must be specified by the user +on the command line or in an options file. Pppd will initially configure the interface and enable it for IP traffic without -connecting to the peer. When traffic is available, \fBpppd\fR will +connecting to the peer. When traffic is available, pppd will connect to the peer and perform negotiation, authentication, etc. -When this is completed, \fBpppd\fR will commence passing data packets -(i.e., IP packets) across the link. The persist, idle and holdoff -options are often useful in conjuction with this option. -.TP -.B domain \fI<d> -Append the domain name <d> to the local host name for authentication -purposes. For example, if gethostname() returns the name porsche, but the -fully qualified domain name is porsche.Quotron.COM, you could use the +When this is completed, pppd will commence passing data packets +(i.e., IP packets) across the link. + +The \fIdemand\fR option implies the \fIpersist\fR option. If this +behaviour is not desired, use the \fInopersist\fR option after the +\fIdemand\fR option. The \fIidle\fR and \fIholdoff\fR +options are also useful in conjuction with the \fIdemand\fR option. +.TP +.B domain \fId +Append the domain name \fId\fR to the local host name for authentication +purposes. For example, if gethostname() returns the name porsche, but +the fully qualified domain name is porsche.Quotron.COM, you could specify \fIdomain Quotron.COM\fR. Pppd would then use the name \fIporsche.Quotron.COM\fR for looking up secrets in the secrets file, and as the default name to send to the peer when authenticating itself to the peer. This option is privileged. .TP -.B holdoff \fI<n> +.B holdoff \fIn Specifies how many seconds to wait before re-initiating the link after -it terminates. This option only has effect if the persist option is -used. -.TP -.B idle \fI<n> -Specifies that \fBpppd\fR should disconnect if it is idle for -\fI<n>\fR seconds. The link is idle when no data packets (i.e. IP -packets) are being sent or received. If the \fBactive-filter\fR +it terminates. This option only has any effect if the \fIpersist\fR +or \fIdemand\fR option is used. The holdoff period is not applied if +the link was terminated because it was idle. +.TP +.B idle \fIn +Specifies that pppd should disconnect if the link is idle for \fIn\fR +seconds. The link is idle when no data packets (i.e. IP packets) are +being sent or received. Note: it is not advisable to use this option +with the \fIpersist\fR option without the \fIdemand\fR option. +If the \fBactive-filter\fR option is given, data packets which are rejected by the specified activity filter also count as the link being idle. .TP .B ipcp-accept-local -With this option, -.I pppd -will accept the peer's idea of our local IP address, even if the -local IP address was specified in an option. +With this option, pppd will accept the peer's idea of our local IP +address, even if the local IP address was specified in an option. .TP .B ipcp-accept-remote -With this option, -.I pppd -will accept the peer's idea of its (remote) IP address, even if the -remote IP address was specified in an option. +With this option, pppd will accept the peer's idea of its (remote) IP +address, even if the remote IP address was specified in an option. .TP -.B ipcp-max-configure \fI<n> -Set the maximum number of IPCP configure-request transmissions to <n> -(default 10). +.B ipcp-max-configure \fIn +Set the maximum number of IPCP configure-request transmissions to +\fIn\fR (default 10). .TP -.B ipcp-max-failure \fI<n> +.B ipcp-max-failure \fIn Set the maximum number of IPCP configure-NAKs returned before starting -to send configure-Rejects instead to <n> (default 10). +to send configure-Rejects instead to \fIn\fR (default 10). .TP -.B ipcp-max-terminate \fI<n> -Set the maximum number of IPCP terminate-request transmissions to <n> -(default 3). +.B ipcp-max-terminate \fIn +Set the maximum number of IPCP terminate-request transmissions to +\fIn\fR (default 3). .TP -.B ipcp-restart \fI<n> -Set the IPCP restart interval (retransmission timeout) to <n> seconds -(default 3). +.B ipcp-restart \fIn +Set the IPCP restart interval (retransmission timeout) to \fIn\fR +seconds (default 3). .TP .B ipparam \fIstring Provides an extra parameter to the ip-up and ip-down scripts. If this @@ -277,21 +288,21 @@ option is given, the \fIstring\fR supplied is given as the 6th parameter to those scripts. .TP .B ipx -Enable the IPXCP and IPX protocols. Under Linux, this is the default -condition if your kernel supports IPX. This option is presently only -supported under Linux and OpenBSD. +Enable the IPXCP and IPX protocols. This option is presently only +supported under Linux, and only if your kernel has been configured to +include IPX support. .TP -.B ipx-network \fI<n> +.B ipx-network \fIn Set the IPX network number in the IPXCP configure request frame to -\fI<n>\fR, a hexadecimal number (without a leading 0x). There is no +\fIn\fR, a hexadecimal number (without a leading 0x). There is no valid default. If this option is not specified, the network number is obtained from the peer. If the peer does not have the network number, the IPX protocol will not be started. .TP -.B ipx-node \fI<n>\fB:\fI<m> +.B ipx-node \fIn\fB:\fIm Set the IPX node numbers. The two node numbers are separated from each -other with a colon character. The first number \fI<n>\fR is the local -node number. The second number \fI<m>\fR is the peer's node number. Each +other with a colon character. The first number \fIn\fR is the local +node number. The second number \fIm\fR is the peer's node number. Each node number is a hexadecimal number, at most 10 digits long. The node numbers on the ipx-network must be unique. There is no valid default. If this option is not specified then the node numbers are @@ -301,7 +312,7 @@ obtained from the peer. Set the name of the router. This is a string and is sent to the peer as information data. .TP -.B ipx-routing \fI<n> +.B ipx-routing \fIn Set the routing protocol to be received by this option. More than one instance of \fIipx-routing\fR may be specified. The '\fInone\fR' option (0) may be specified as the only instance of ipx-routing. The @@ -327,84 +338,85 @@ frame. If a node number was specified for the peer and this option was not specified, the peer will be forced to use the value which you have specified. .TP -.B ipxcp-max-configure \fI<n> +.B ipxcp-max-configure \fIn Set the maximum number of IPXCP configure request frames which the -system will send to \fI<n>\fR. The default is 10. +system will send to \fIn\fR. The default is 10. .TP -.B ipxcp-max-failure \fI<n> +.B ipxcp-max-failure \fIn Set the maximum number of IPXCP NAK frames which the local system will send before it rejects the options. The default value is 3. .TP -.B ipxcp-max-terminate \fI<n> +.B ipxcp-max-terminate \fIn Set the maximum nuber of IPXCP terminate request frames before the local system considers that the peer is not listening to them. The default value is 3. .TP -.B kdebug \fI<n> +.B kdebug \fIn Enable debugging code in the kernel-level PPP driver. The argument -\fI<n>\fR is a number which is the sum of the following values: 1 to +\fIn\fR is a number which is the sum of the following values: 1 to enable general debug messages, 2 to request that the contents of received packets be printed, and 4 to request that the contents of transmitted packets be printed. On most systems, messages printed by the kernel are logged by syslog(1) to a file as directed in the /etc/syslog.conf configuration file. .TP -.B lcp-echo-failure \fI<n> -If this option is given, \fIpppd\fR will presume the peer to be dead +.B lcp-echo-failure \fIn +If this option is given, pppd will presume the peer to be dead if \fIn\fR LCP echo-requests are sent without receiving a valid LCP -echo-reply. If this happens, \fIpppd\fR will terminate the +echo-reply. If this happens, pppd will terminate the connection. Use of this option requires a non-zero value for the \fIlcp-echo-interval\fR parameter. This option can be used to enable -\fIpppd\fR to terminate after the physical connection has been broken +pppd to terminate after the physical connection has been broken (e.g., the modem has hung up) in situations where no hardware modem control lines are available. .TP -.B lcp-echo-interval \fI<n> -If this option is given, \fIpppd\fR will send an LCP echo-request -frame to the peer every \fIn\fR seconds. Under Linux, the -echo-request is sent when no packets have been received from the peer -for \fIn\fR seconds. Normally the peer should respond to the -echo-request by sending an echo-reply. This option can be used with -the \fIlcp-echo-failure\fR option to detect that the peer is no longer -connected. -.TP -.B lcp-max-configure \fI<n> -Set the maximum number of LCP configure-request transmissions to <n> -(default 10). +.B lcp-echo-interval \fIn +If this option is given, pppd will send an LCP echo-request frame to +the peer every \fIn\fR seconds. Normally the peer should respond to +the echo-request by sending an echo-reply. This option can be used +with the \fIlcp-echo-failure\fR option to detect that the peer is no +longer connected. +.TP +.B lcp-max-configure \fIn +Set the maximum number of LCP configure-request transmissions to +\fIn\fR (default 10). .TP -.B lcp-max-failure \fI<n> +.B lcp-max-failure \fIn Set the maximum number of LCP configure-NAKs returned before starting -to send configure-Rejects instead to <n> (default 10). +to send configure-Rejects instead to \fIn\fR (default 10). .TP -.B lcp-max-terminate \fI<n> -Set the maximum number of LCP terminate-request transmissions to <n> -(default 3). +.B lcp-max-terminate \fIn +Set the maximum number of LCP terminate-request transmissions to +\fIn\fR (default 3). .TP -.B lcp-restart \fI<n> -Set the LCP restart interval (retransmission timeout) to <n> seconds -(default 3). +.B lcp-restart \fIn +Set the LCP restart interval (retransmission timeout) to \fIn\fR +seconds (default 3). .TP .B local -Don't use the modem control lines. With this option, -.B pppd -will ignore the state of the CD (Carrier Detect) signal from the modem and -will not change the state of the DTR (Data Terminal Ready) signal. +Don't use the modem control lines. With this option, pppd will ignore +the state of the CD (Carrier Detect) signal from the modem and will +not change the state of the DTR (Data Terminal Ready) signal. .TP .B login Use the system password database for authenticating the peer using -PAP, and record the user in the system wtmp file. +PAP, and record the user in the system wtmp file. Note that the peer +must have an entry in the /etc/ppp/pap-secrets file as well as the +system password database to be allowed access. +.TP +.B maxconnect \fIn +Terminate the connection when it has been available for network +traffic for \fIn\fR seconds (i.e. \fIn\fR seconds after the first +network control protocol comes up). .TP .B modem Use the modem control lines. This option is the default. With this -option, -.B pppd -will wait for the CD (Carrier Detect) signal from the modem to be asserted -when opening the serial device -(unless a connect script is specified), and it will drop the DTR (Data -Terminal Ready) signal briefly when the connection is terminated and before -executing the connect script. -On Ultrix, this option implies hardware -flow control, as for the \fBcrtscts\fR option. +option, pppd will wait for the CD (Carrier Detect) signal from the +modem to be asserted when opening the serial device (unless a connect +script is specified), and it will drop the DTR (Data Terminal Ready) +signal briefly when the connection is terminated and before executing +the connect script. On Ultrix, this option implies hardware flow +control, as for the \fIcrtscts\fR option. .TP .B modem_chat Use the modem control lines during the chat script. The default is @@ -413,21 +425,32 @@ during the chat script. If you are using a cua device (as opposed to a tty device) you should set this option. .TP .B ms-dns \fI<addr> -If -.I pppd -is acting as a server for Microsoft Windows clients, this option -allows -.I pppd -to supply one or two DNS (Domain Name Server) addresses to the -clients. The first instance of this option specifies the primary DNS -address; the second instance (if given) specifies the secondary DNS -address. -.TP -.B name \fI<n> -Set the name of the local system for authentication purposes to <n>. -.TP -.B netmask \fI<n> -Set the interface netmask to \fI<n>\fR, a 32 bit netmask in "decimal dot" +If pppd is acting as a server for Microsoft Windows clients, this +option allows pppd to supply one or two DNS (Domain Name Server) +addresses to the clients. The first instance of this option specifies +the primary DNS address; the second instance (if given) specifies the +secondary DNS address. (This option was present in some older +versions of pppd under the name \fBdns-addr\fR.) +.TP +.B ms-wins \fI<addr> +If pppd is acting as a server for Microsoft Windows or "Samba" +clients, this option allows pppd to supply one or two WINS (Windows +Internet Name Services) server addresses to the clients. The first +instance of this option specifies the primary WINS address; the second +instance (if given) specifies the secondary WINS address. +.TP +.B name \fIname +Set the name of the local system for authentication purposes to +\fIname\fR. This is a privileged option. With this option, pppd will +use lines in the secrets files which have \fIname\fR as the second +field when looking for a secret to use in authenticating the peer. In +addition, unless overridden with the \fIuser\fR option, \fIname\fR +will be used as the name to send to the peer when authenticating the +local system to the peer. (Note that pppd does not append the domain +name to \fIname\fR.) +.TP +.B netmask \fIn +Set the interface netmask to \fIn\fR, a 32 bit netmask in "decimal dot" notation (e.g. 255.255.255.0). If this option is given, the value specified is ORed with the default netmask. The default netmask is chosen based on the negotiated remote IP address; it is the @@ -441,28 +464,25 @@ receive). .TP .B noauth Do not require the peer to authenticate itself. This option is -privileged if the \fBauth\fR option is specified in /etc/ppp/options. +privileged if the \fIauth\fR option is specified in /etc/ppp/options. .TP .B nobsdcomp -Disables BSD-Compress compression; -.I pppd -will not request or agree to compress packets using the BSD-Compress scheme. +Disables BSD-Compress compression; \fBpppd\fR will not request or +agree to compress packets using the BSD-Compress scheme. .TP .B noccp Disable CCP (Compression Control Protocol) negotiation. This option should only be required if the peer is buggy and gets confused by -requests from -.I pppd -for CCP negotiation. +requests from pppd for CCP negotiation. .TP .B nocrtscts Disable hardware flow control (i.e. RTS/CTS) on the serial port. If -neither the \fBcrtscts\fR nor the \fB\nocrtscts\fR option is given, +neither the \fIcrtscts\fR nor the \fInocrtscts\fR option is given, the hardware flow control setting for the serial port is left unchanged. .TP .B nodefaultroute -Disable the \fBdefaultroute\fR option. The system administrator who +Disable the \fIdefaultroute\fR option. The system administrator who wishes to prevent users from creating default routes with pppd can do so by placing this option in the /etc/ppp/options file. .TP @@ -489,8 +509,7 @@ command line or in an options file). .TP .B noipx Disable the IPXCP and IPX protocols. This option should only be -required if the peer is buggy and gets confused by requests from -.I pppd +required if the peer is buggy and gets confused by requests from pppd for IPXCP negotiation. .TP .B nomagic @@ -511,7 +530,7 @@ specified. Do not accept or agree to Predictor-1 comprssion. .TP .B noproxyarp -Disable the \fBproxyarp\fR option. The system administrator who +Disable the \fIproxyarp\fR option. The system administrator who wishes to prevent users from creating proxy ARP entries with pppd can do so by placing this option in the /etc/ppp/options file. .TP @@ -526,24 +545,39 @@ connection-ID byte from Van Jacobson compressed TCP/IP headers, nor ask the peer to do so. .TP .B papcrypt -Indicates that all secrets in the /etc/ppp/pap-secrets file which -are used for checking the identity of the peer are encrypted, and thus -pppd should not accept a password which (before encryption) is +Indicates that all secrets in the /etc/ppp/pap-secrets file which are +used for checking the identity of the peer are encrypted, and thus +pppd should not accept a password which, before encryption, is identical to the secret from the /etc/ppp/pap-secrets file. .TP -.B pap-max-authreq \fI<n> +.B pap-max-authreq \fIn Set the maximum number of PAP authenticate-request transmissions to -<n> (default 10). -.TP -.B pap-restart \fI<n> -Set the PAP restart interval (retransmission timeout) to <n> seconds -(default 3). -.TP -.B pap-timeout \fI<n> -Set the maximum time that -.I pppd -will wait for the peer to authenticate itself with PAP to -<n> seconds (0 means no limit). +\fIn\fR (default 10). +.TP +.B pap-restart \fIn +Set the PAP restart interval (retransmission timeout) to \fIn\fR +seconds (default 3). +.TP +.B pap-timeout \fIn +Set the maximum time that pppd will wait for the peer to authenticate +itself with PAP to \fIn\fR seconds (0 means no limit). +.TP +.B pass-filter \fIfilter-expression +Specifies a packet filter to applied to data packets being sent or +received to determine which packets should be allowed to pass. +Packets which are rejected by the filter are silently discarded. This +option can be used to prevent specific network daemons (such as +routed) using up link bandwidth, or to provide a basic firewall +capability. +The \fIfilter-expression\fR syntax is as described for tcpdump(1), +except that qualifiers which are inappropriate for a PPP link, such as +\fBether\fR and \fBarp\fR, are not permitted. Generally the filter +expression should be enclosed in single-quotes to prevent whitespace +in the expression from being interpreted by the shell. Note that it +is possible to apply different constraints to incoming and outgoing +packets using the \fBinbound\fR and \fBoutbound\fR qualifiers. This +option is currently only available under OpenBSD, and then only if both +the kernel and pppd were compiled with PPP_FILTER defined. .TP .B persist Do not exit after a connection is terminated; instead try to reopen @@ -558,11 +592,12 @@ supports Predictor-1 compression. .B proxyarp Add an entry to this system's ARP [Address Resolution Protocol] table with the IP address of the peer and the Ethernet address of this -system. +system. This will have the effect of making the peer appear to other +systems to be on the local ethernet. .TP -.B remotename \fI<n> +.B remotename \fIname Set the assumed name of the remote system for authentication purposes -to <n>. +to \fIname\fR. .TP .B refuse-chap With this option, pppd will not agree to authenticate itself to the @@ -574,28 +609,25 @@ peer using PAP. .TP .B require-chap Require the peer to authenticate itself using CHAP [Challenge -Handshake Authentication Protocol] authentication +Handshake Authentication Protocol] authentication. .TP .B require-pap Require the peer to authenticate itself using PAP [Password Authentication Protocol] authentication. .TP .B silent -With this option, -.I pppd -will not transmit LCP packets to initiate a connection until a valid -LCP packet is received from the peer (as for the `passive' option with -ancient versions of \fIpppd\fR). +With this option, pppd will not transmit LCP packets to initiate a +connection until a valid LCP packet is received from the peer (as for +the `passive' option with ancient versions of pppd). .TP .B usehostname -Enforce the use of the hostname as the name of the local system for -authentication purposes (overrides the -.B name -option). +Enforce the use of the hostname (with domain name appended, if given) +as the name of the local system for authentication purposes (overrides +the \fIname\fR option). .TP -.B user \fI<u> -Set the user name to use for authenticating this machine with the peer -using PAP to <u>. +.B user \fIname +Sets the name used for authenticating the local system to the peer to +\fIname\fR. .TP .B vj-max-slots \fIn Sets the number of connection slots to be used by the Van Jacobson @@ -605,19 +637,17 @@ must be between 2 and 16 (inclusive). .B welcome \fIscript Run the executable or shell command specified by \fIscript\fR before initiating PPP negotiation, after the connect script (if any) has -completed. This option is privileged if the \fBnoauth\fR option is +completed. This option is privileged if the \fInoauth\fR option is used. .TP .B xonxoff Use software flow control (i.e. XON/XOFF) to control the flow of data on -the serial port. This option is only implemented on Linux systems -at present. +the serial port. .SH OPTIONS FILES -Options can be taken from files as well as the command line. -.I pppd +Options can be taken from files as well as the command line. Pppd reads options from the files /etc/ppp/options, ~/.ppprc and -/etc/ppp/options.\fBttyname\fR (in that order) before processing the -option on the command line. (In fact, the command-line options are +/etc/ppp/options.\fIttyname\fR (in that order) before processing the +options on the command line. (In fact, the command-line options are scanned to find the terminal name before the options.\fIttyname\fR file is read.) In forming the name of the options.\fIttyname\fR file, the initial /dev/ is removed from the terminal name, and any remaining @@ -627,249 +657,310 @@ An options file is parsed into a series of words, delimited by whitespace. Whitespace can be included in a word by enclosing the word in quotes ("). A backslash (\\) quotes the following character. A hash (#) starts a comment, which continues until the end of the -line. There is no restriction on using the \fBfile\fR or \fBcall\fR +line. There is no restriction on using the \fIfile\fR or \fIcall\fR options within an options file. -.SH PRIVILEGED OPTIONS -As indicated above, some security-sensitive options are privileged, -which means that they may not be used by an ordinary non-privileged -user running a setuid-root pppd, either on the command line, in the -user's ~/.ppprc file, or in an options file read using the \fBfile\fR -option. Privileged options may be used in /etc/ppp/options file or in -an options file read using the \fBcall\fR option. If pppd is being -run by the root user, privileged options can be used without -restriction. +.SH SECURITY +.I pppd +provides system administrators with sufficient access control that PPP +access to a server machine can be provided to legitimate users without +fear of compromising the security of the server or the network it's +on. In part this is provided by the /etc/ppp/options file, where the +administrator can place options to restrict the ways in which pppd can +be used, and in part by the PAP and CHAP secrets files, where the +administrator can restrict the set of IP addresses which individual +users may use. .PP -The normal way that pppd should be set up is to have the \fBauth\fR +The normal way that pppd should be set up is to have the \fIauth\fR option in the /etc/ppp/options file. (This may become the default in later releases.) If users wish to use pppd to dial out to a peer which will refuse to authenticate itself (such as an internet service provider), the system administrator should create an options file -under /etc/ppp/peers containing the \fBnoauth\fR option, the name of -the serial port to use, and the \fBconnect\fR option (if required), +under /etc/ppp/peers containing the \fInoauth\fR option, the name of +the serial port to use, and the \fIconnect\fR option (if required), plus any other appropriate options. In this way, pppd can be set up to allow non-privileged users to make unauthenticated connections only to trusted peers. +.PP +As indicated above, some security-sensitive options are privileged, +which means that they may not be used by an ordinary non-privileged +user running a setuid-root pppd, either on the command line, in the +user's ~/.ppprc file, or in an options file read using the \fIfile\fR +option. Privileged options may be used in /etc/ppp/options file or in +an options file read using the \fIcall\fR option. If pppd is being +run by the root user, privileged options can be used without +restriction. .SH AUTHENTICATION -.I pppd -provides system administrators with sufficient access control that PPP -access to a server machine can be provided to legitimate users without -fear of compromising the security of the server or the network it's -on. In part this is provided by the /etc/ppp/options file, where the -administrator can place options to require authentication whenever -.I pppd -is run, and in part by the PAP and CHAP secrets files, where the -administrator can restrict the set of IP addresses which individual -users may use. +Authentication is the process whereby one peer convinces the other of +its identity. This involves the first peer sending its name to the +other, together with some kind of secret information which could only +come from the genuine authorized user of that name. In such an +exchange, we will call the first peer the "client" and the other the +"server". The client has a name by which it identifies itself to the +server, and the server also has a name by which it identifies itself +to the client. Generally the genuine client shares some secret (or +password) with the server, and authenticates itself by proving that it +knows that secret. Very often, the names used for authentication +correspond to the internet hostnames of the peers, but this is not +essential. .LP -The default behaviour of -.I pppd -is to agree to authenticate if requested, and to not -require authentication from the peer. However, -.I pppd -will not agree to -authenticate itself with a particular protocol if it has no secrets -which could be used to do so. +At present, pppd supports two authentication protocols: the Password +Authentication Protocol (PAP) and the Challenge Handshake +Authentication Protocol (CHAP). PAP involves the client sending its +name and a cleartext password to the server to authenticate itself. +In contrast, the server initiates the CHAP authentication exchange by +sending a challenge to the client (the challenge packet includes the +server's name). The client must respond with a response which +includes its name plus a hash value derived from the shared secret and +the challenge, in order to prove that it knows the secret. +.LP +The PPP protocol, being symmetrical, allows both peers to require the +other to authenticate itself. In that case, two separate and +independent authentication exchanges will occur. The two exchanges +could use different authentication protocols, and in principle, +different names could be used in the two exchanges. +.LP +The default behaviour of pppd is to agree to authenticate if +requested, and to not require authentication from the peer. However, +pppd will not agree to authenticate itself with a particular protocol +if it has no secrets which could be used to do so. .LP -Authentication is based on secrets, which are selected from secrets +Pppd stores secrets for use in authentication in secrets files (/etc/ppp/pap-secrets for PAP, /etc/ppp/chap-secrets for CHAP). -Both secrets files have the same format, and both can store secrets -for several combinations of server (authenticating peer) and client -(peer being authenticated). Note that -.I pppd -can be both a server -and client, and that different protocols can be used in the two -directions if desired. +Both secrets files have the same format. The secrets files can +contain secrets for pppd to use in authenticating itself to other +systems, as well as secrets for pppd to use when authenticating other +systems to itself. +.LP +Each line in a secrets file contains one secret. A given secret is +specific to a particular combination of client and server - it can +only be used by that client to authenticate itself to that server. +Thus each line in a secrets file has at least 3 fields: the name of +the client, the name of the server, and the secret. These fields may +be followed by a list of the IP addresses that the specified client +may use when connecting to the specified server. .LP -A secrets file is parsed into words as for a options file. A secret -is specified by a line containing at least 3 words, in the order -client name, server name, secret. Any following words on the same -line are taken to be a list of acceptable IP addresses for that -client. If there are only 3 words on the line, it is assumed that any -IP address is OK; to disallow all IP addresses, use "-". A word -starting with "!" indicates that the specified address is \fInot\fR -acceptable. An address may be followed by "/" and a number \fIn\fR, -to indicate a whole subnet, i.e. all addresses which have the same -value in the most significant \fIn\fR bits. Note that case is -significant in the client and server names and in the secret. +A secrets file is parsed into words as for a options file, so the +client name, server name and secrets fields must each be one word, +with any embedded spaces or other special characters quoted or +escaped. Any following words on the same line are taken to be a list +of acceptable IP addresses for that client. If there are only 3 words +on the line, or if the first word is "-", then all IP addresses are +disallowed. To allow any address, use "*". +A word starting with "!" indicates that the +specified address is \fInot\fR acceptable. An address may be followed +by "/" and a number \fIn\fR, to indicate a whole subnet, i.e. all +addresses which have the same value in the most significant \fIn\fR +bits. Note that case is significant in the client and server names +and in the secret. .LP If the secret starts with an `@', what follows is assumed to be the name of a file from which to read the secret. A "*" as the client or -server name matches any name. When selecting a secret, \fIpppd\fR takes the -best match, i.e. the match with the fewest wildcards. +server name matches any name. When selecting a secret, pppd takes the +best match, i.e. the match with the fewest wildcards. .LP Thus a secrets file contains both secrets for use in authenticating other hosts, plus secrets which we use for authenticating ourselves to -others. Which secret to use is chosen based on the names of the host -(the `local name') and its peer (the `remote name'). The local name -is set as follows: -.TP 3 -if the \fBusehostname\fR option is given, -then the local name is the hostname of this machine -(with the domain appended, if given) -.TP 3 -else if the \fBname\fR option is given, -then use the argument of the first \fBname\fR option seen -.TP 3 -else if the local IP address is specified with a hostname, -then use that name -.TP 3 -else use the hostname of this machine (with the domain appended, if given) -.LP -When authenticating ourselves using PAP, there is also a `username' -which is the local name by default, but can be set with the \fBuser\fR -option or the \fB+ua\fR option. +others. When pppd is authenticating the peer (checking the peer's +identity), it chooses a secret with the peer's name in the first +field and the name of the local system in the second field. The +name of the local system defaults to the hostname, with the domain +name appended if the \fIdomain\fR option is used. This default can be +overridden with the \fIname\fR option, except when the +\fIusehostname\fR option is used. .LP -The remote name is set as follows: -.TP 3 -if the \fBremotename\fR option is given, -then use the argument of the last \fBremotename\fR option seen -.TP 3 -else if the remote IP address is specified with a hostname, -then use that host name -.TP 3 -else the remote name is the null string "". +When pppd is choosing a secret to use in authenticating itself to the +peer, it first determines what name it is going to use to identify +itself to the peer. This name can be specified by the user with the +\fIuser\fR option. If this option is not used, the name defaults to +the name of the local system, determined as described in the previous +paragraph. Then pppd looks for a secret with this name in the first +field and the peer's name in the second field. Pppd will know the +name of the peer if CHAP authentication is being used, because the +peer will have sent it in the challenge packet. However, if PAP is being +used, pppd will have to determine the peer's name from the options +specified by the user. The user can specify the peer's name directly +with the \fIremotename\fR option. Otherwise, if the remote IP address +was specified by a name (rather than in numeric form), that name will +be used as the peer's name. Failing that, pppd will use the null +string as the peer's name. .LP -Secrets are selected from the PAP secrets file as follows: -.TP 2 -* -For authenticating the peer, look for a secret with client == -username specified in the PAP authenticate-request, and server == -local name. -.TP 2 -* -For authenticating ourselves to the peer, look for a secret with -client == our username, server == remote name. +When authenticating the peer with PAP, the supplied password is first +compared with the secret from the secrets file. If the password +doesn't match the secret, the password is encrypted using crypt() and +checked against the secret again. Thus secrets for authenticating the +peer can be stored in encrypted form if desired. If the +\fIpapcrypt\fR option is given, the first (unencrypted) comparison is +omitted, for better security. .LP -When authenticating the peer with PAP, a secret of "" matches any -password supplied by the peer. If the password doesn't match the -secret, the password is encrypted using crypt() and checked against -the secret again; thus secrets for authenticating the peer can be -stored in encrypted form. If the \fBpapcrypt\fR option is given, the -first (unencrypted) comparison is omitted, for better security. -.LP -If the \fBlogin\fR option was specified, the -username and password are also checked against the system password -database. Thus, the system administrator can set up the pap-secrets -file to allow PPP access only to certain users, and to restrict the -set of IP addresses that each user can use. Typically, when using the -\fBlogin\fR option, the secret in /etc/ppp/pap-secrets would be "", to -avoid the need to have the same secret in two places. -.LP -Secrets are selected from the CHAP secrets file as follows: -.TP 2 -* -For authenticating the peer, look for a secret with client == name -specified in the CHAP-Response message, and server == local name. -.TP 2 -* -For authenticating ourselves to the peer, look for a secret with -client == local name, and server == name specified in the -CHAP-Challenge message. +Furthermore, if the \fIlogin\fR option was specified, the username and +password are also checked against the system password database. Thus, +the system administrator can set up the pap-secrets file to allow PPP +access only to certain users, and to restrict the set of IP addresses +that each user can use. Typically, when using the \fIlogin\fR option, +the secret in /etc/ppp/pap-secrets would be "", which will match any +password supplied by the peer. This avoids the need to have the same +secret in two places. .LP Authentication must be satisfactorily completed before IPCP (or any -other Network Control Protocol) can be started. If authentication -fails, \fIpppd\fR will terminated the link (by closing LCP). If IPCP -negotiates an unacceptable IP address for the remote host, IPCP will -be closed. IP packets can only be sent or received when IPCP is open. +other Network Control Protocol) can be started. If the peer is +required to authenticate itself, and fails to do so, pppd will +terminated the link (by closing LCP). If IPCP negotiates an +unacceptable IP address for the remote host, IPCP will be closed. IP +packets can only be sent or received when IPCP is open. .LP In some cases it is desirable to allow some hosts which can't authenticate themselves to connect and use one of a restricted set of IP addresses, even when the local host generally requires authentication. If the peer refuses to authenticate itself when -requested, \fIpppd\fR takes that as equivalent to authenticating with -PAP using the empty string for the username and password. Thus, by -adding a line to the pap-secrets file which specifies the empty string -for the client and password, it is possible to allow restricted access -to hosts which refuse to authenticate themselves. +requested, pppd takes that as equivalent to authenticating with PAP +using the empty string for the username and password. Thus, by adding +a line to the pap-secrets file which specifies the empty string for +the client and password, it is possible to allow restricted access to +hosts which refuse to authenticate themselves. .SH ROUTING .LP -When IPCP negotiation is completed successfully, -.I pppd -will inform the kernel of the local and remote IP addresses for the -ppp interface. This is sufficient to create a -host route to the remote end of the link, which will enable the peers -to exchange IP packets. Communication with other machines generally -requires further modification to routing tables and/or ARP (Address -Resolution Protocol) tables. In some cases this will be done -automatically through the actions of the \fIrouted\fR or \fIgated\fR -daemons, but in most cases some further intervention is required. +When IPCP negotiation is completed successfully, pppd will inform the +kernel of the local and remote IP addresses for the ppp interface. +This is sufficient to create a host route to the remote end of the +link, which will enable the peers to exchange IP packets. +Communication with other machines generally requires further +modification to routing tables and/or ARP (Address Resolution +Protocol) tables. In most cases the \fIdefaultroute\fR and/or +\fIproxyarp\fR options are sufficient for this, but in some cases +further intervention is required. The /etc/ppp/ip-up script can be +used for this. .LP -Sometimes it is desirable -to add a default route through the remote host, as in the case of a -machine whose only connection to the Internet is through the ppp -interface. The \fBdefaultroute\fR option causes \fIpppd\fR to create such a -default route when IPCP comes up, and delete it when the link is -terminated. +Sometimes it is desirable to add a default route through the remote +host, as in the case of a machine whose only connection to the +Internet is through the ppp interface. The \fIdefaultroute\fR option +causes pppd to create such a default route when IPCP comes up, and +delete it when the link is terminated. .LP In some cases it is desirable to use proxy ARP, for example on a server machine connected to a LAN, in order to allow other hosts to -communicate with the remote host. The \fBproxyarp\fR option causes \fIpppd\fR -to look for a network interface on the same subnet as the remote host -(an interface supporting broadcast and ARP, which is up and not a -point-to-point or loopback interface). If found, \fIpppd\fR creates a +communicate with the remote host. The \fIproxyarp\fR option causes +pppd to look for a network interface on the same subnet as the remote +host (an interface supporting broadcast and ARP, which is up and not a +point-to-point or loopback interface). If found, pppd creates a permanent, published ARP entry with the IP address of the remote host and the hardware address of the network interface found. +.LP +When the \fIdemand\fR option is used, the interface IP addresses have +already been set at the point when IPCP comes up. If pppd has not +been able to negotiate the same addresses that it used to configure +the interface (for example when the peer is an ISP that uses dynamic +IP address assignment), pppd has to change the interface IP addresses +to the negotiated addresses. This may disrupt existing connections, +and the use of demand dialling with peers that do dynamic IP address +assignment is not recommended. .SH EXAMPLES .LP -In the simplest case, you can connect the serial ports of two machines -and issue a command like +The following examples assume that the /etc/ppp/options file contains +the \fIauth\fR option (as in the default /etc/ppp/options file in the +ppp distribution). +.LP +Probably the most common use of pppd is to dial out to an ISP. This +can be done with a command such as .IP -pppd /dev/ttya 9600 passive +pppd call isp .LP -to each machine, assuming there is no \fIgetty\fR running on the -serial ports. If one machine has a \fIgetty\fR running, you can use -\fIkermit\fR or \fItip\fR on the other machine to log in to the first -machine and issue a command like +where the /etc/ppp/peers/isp file is set up by the system +administrator to contain something like this: .IP -pppd passive +ttyS0 19200 crtscts +.br +connect '/usr/sbin/chat -v -f /etc/ppp/chat-isp' +.br +noauth +.LP +In this example, we are using chat to dial the ISP's modem and go +through any logon sequence required. The /etc/ppp/chat-isp file +contains the script used by chat; it could for example contain +something like this: +.IP +ABORT "NO CARRIER" +.br +ABORT "NO DIALTONE" +.br +ABORT "ERROR" +.br +ABORT "NO ANSWER" +.br +ABORT "BUSY" +.br +ABORT "Username/Password Incorrect" +.br +"" "at" +.br +OK "at&d0&c1" +.br +OK "atdt2468135" +.br +"name:" "^Umyuserid" +.br +"word:" "\\qmypassword" +.br +"ispts" "\\q^Uppp" +.br +"~-^Uppp-~" .LP -Then exit from the communications program (making sure the connection -isn't dropped), and issue a command like +See the chat(8) man page for details of chat scripts. +.LP +Pppd can also be used to provide a dial-in ppp service for users. If +the users already have login accounts, the simplest way to set up the +ppp service is to let the users log in to their accounts and run pppd +(installed setuid-root) with a command such as .IP -pppd /dev/ttya 9600 +pppd proxyarp .LP -The process of logging in to the other machine and starting \fIpppd\fR -can be automated by using the \fBconnect\fR option to run \fIchat\fR, -for example: +To allow a user to use the PPP facilities, you need to allocate an IP +address for that user's machine and create an entry in +/etc/ppp/pap-secrets or /etc/ppp/chap-secrets (depending on which +authentication method the PPP implementation on the user's machine +supports), so that the user's +machine can authenticate itself. For example, if Joe has a machine +called "joespc" which is to be allowed to dial in to the machine +called "server" and use the IP address joespc.my.net, you would add an +entry like this to /etc/ppp/pap-secrets or /etc/ppp/chap-secrets: .IP -pppd /dev/ttya 38400 connect 'chat "" "" "login:" "username" -"Password:" "password" "% " "exec pppd passive"' +joespc server "joe's secret" joespc.my.net .LP -(Note however that running chat like this will leave the password -visible in the parameter list of pppd and chat.) +Alternatively, you can create a username called (for example) "ppp", +whose login shell is pppd and whose home directory is /etc/ppp. +Options to be used when pppd is run this way can be put in +/etc/ppp/.ppprc. .LP If your serial connection is any more complicated than a piece of wire, you may need to arrange for some control characters to be escaped. In particular, it is often useful to escape XON (^Q) and -XOFF (^S), using \fBasyncmap a0000\fR. If the path includes a telnet, -you probably should escape ^] as well (\fBasyncmap 200a0000\fR). -If the path includes an rlogin, you will need to use the \fBescape -ff\fR option on the end which is running the rlogin client, since many -rlogin implementations are not -transparent; they will remove the sequence [0xff, 0xff, 0x73, 0x73, -followed by any 8 bytes] from the stream. +XOFF (^S), using \fIasyncmap a0000\fR. If the path includes a telnet, +you probably should escape ^] as well (\fIasyncmap 200a0000\fR). If +the path includes an rlogin, you will need to use the \fIescape ff\fR +option on the end which is running the rlogin client, since many +rlogin implementations are not transparent; they will remove the +sequence [0xff, 0xff, 0x73, 0x73, followed by any 8 bytes] from the +stream. .SH DIAGNOSTICS .LP Messages are sent to the syslog daemon using facility LOG_DAEMON. -(This can be overriden by recompiling \fIpppd\fR with the macro +(This can be overriden by recompiling pppd with the macro LOG_PPP defined as the desired facility.) In order to see the error and debug messages, you will need to edit your /etc/syslog.conf file to direct the messages to the desired output device or file. .LP -The \fBdebug\fR option causes the contents of all control packets sent +The \fIdebug\fR option causes the contents of all control packets sent or received to be logged, that is, all LCP, PAP, CHAP or IPCP packets. -This can be useful if the PPP negotiation does not succeed. -If debugging is enabled at compile time, the \fBdebug\fR option also +This can be useful if the PPP negotiation does not succeed or if +authentication fails. +If debugging is enabled at compile time, the \fIdebug\fR option also causes other debugging messages to be logged. .LP -Debugging can also be enabled or disabled by sending a -SIGUSR1 to the -.I pppd -process. This signal acts as a toggle. +Debugging can also be enabled or disabled by sending a SIGUSR1 signal +to the pppd process. This signal acts as a toggle. .SH FILES .TP .B /var/run/ppp\fIn\fB.pid \fR(BSD or Linux), \fB/etc/ppp/ppp\fIn\fB.pid \fR(others) -Process-ID for \fIpppd\fR process on ppp interface unit \fIn\fR. +Process-ID for pppd process on ppp interface unit \fIn\fR. .TP .B /etc/ppp/auth-up A program or script which is executed after the remote system @@ -894,30 +985,26 @@ sending and receiving IP packets (that is, IPCP has come up). It is executed with the parameters .IP \fIinterface-name tty-device speed local-IP-address -remote-IP-address\fR +remote-IP-address ipparam\fR .IP and with its standard input, -output and error streams redirected to \fB/dev/null\fR. +output and error streams redirected to /dev/null. .IP -This program or script is executed with the same real and effective -user-ID as \fIpppd\fR, that is, at least the effective user-ID and -possibly the real user-ID will be \fBroot\fR. This is so that it can -be used to manipulate routes, run privileged daemons (e.g. -\fBsendmail\fR), etc. Be careful that the contents of the -/etc/ppp/ip-up and /etc/ppp/ip-down scripts do not compromise your -system's security. +This program or script is executed with the real and effective +user-IDs set to root. This is so that it can be used to manipulate +routes, run privileged daemons (e.g. \fIsendmail\fR), etc. Be +careful that the contents of the /etc/ppp/ip-up and /etc/ppp/ip-down +scripts do not compromise your system's security. .IP -This program or script is executed without an environment, so you -must either specify a PATH or use full pathnames (e.g. \fI/sbin/route\fR, -as opposed to \fIroute\fR). +This program or script is executed with an empty environment, so you +must either specify a PATH or use full pathnames. .TP .B /etc/ppp/ip-down A program or script which is executed when the link is no longer available for sending and receiving IP packets. This script can be used for undoing the effects of the /etc/ppp/ip-up script. It is -invoked with the same parameters as the ip-up script, and the same -security considerations apply, since it is executed with the same -effective and real user-IDs as \fIpppd\fR. +invoked in the same manner and with the same parameters as the ip-up +script, and the same security considerations apply. .TP .B /etc/ppp/ipx-up A program or script which is executed when the link is available for @@ -926,7 +1013,7 @@ executed with the parameters .IP \fIinterface-name tty-device speed network-number local-IPX-node-address remote-IPX-node-address local-IPX-routing-protocol remote-IPX-routing-protocol -local-IPX-router-name remote-IPX-router-name ipparam pppd-pid\fR +local-IPX-router-name remote-IPX-router-name ipparam pppd-pid\fR .IP and with its standard input, output and error streams redirected to /dev/null. @@ -959,30 +1046,41 @@ invoked in the same manner and with the same parameters as the ipx-up script, and the same security considerations apply. .TP .B /etc/ppp/pap-secrets -Usernames, passwords and IP addresses for PAP authentication. +Usernames, passwords and IP addresses for PAP authentication. This +file should be owned by root and not readable or writable by any other +user. Pppd will log a warning if this is not the case. .TP .B /etc/ppp/chap-secrets -Names, secrets and IP addresses for CHAP authentication. +Names, secrets and IP addresses for CHAP authentication. As for +/etc/ppp/pap-secrets, this file should be owned by root and not +readable or writable by any other user. Pppd will log a warning if +this is not the case. .TP .B /etc/ppp/options -System default options for -.I pppd, -read before user default options or command-line options. +System default options for pppd, read before user default options or +command-line options. .TP .B ~/.ppprc -User default options, read before command-line options. +User default options, read before /etc/ppp/options.\fIttyname\fR. .TP .B /etc/ppp/options.\fIttyname System default options for the serial port being used, read after -command-line options. In forming the \fIttyname\fR part of this +~/.ppprc. In forming the \fIttyname\fR part of this filename, an initial /dev/ is stripped from the port name (if present), and any slashes in the remaining part are converted to dots. +.TP +.B /etc/ppp/peers +A directory containing options files which may contain privileged +options, even if pppd was invoked by a user other than root. The +system administrator can create options files in this directory to +permit non-privileged users to dial out without requiring the peer to +authenticate, but only to certain trusted peers. .SH SEE ALSO .TP .B RFC1144 Jacobson, V. -.I Compressing TCP/IP headers for low-speed serial links. +\fICompressing TCP/IP headers for low-speed serial links.\fR February 1990. .TP .B RFC1321 @@ -1010,37 +1108,31 @@ Simpson, W.A. .I PPP in HDLC-like Framing. July 1994. .SH NOTES -The following signals have the specified effect when sent to the -.I pppd -process. +The following signals have the specified effect when sent to pppd. .TP .B SIGINT, SIGTERM -These signals cause \fBpppd\fR to terminate the link (by closing LCP), +These signals cause pppd to terminate the link (by closing LCP), restore the serial device settings, and exit. .TP .B SIGHUP -This signal causes \fBpppd\fR to terminate the link, restore the -serial device settings, and close the serial device. If the -\fBpersist\fR option has been specified, \fBpppd\fR will try to reopen -the serial device and start another connection. Otherwise \fBpppd\fR -will exit. +This signal causes pppd to terminate the link, restore the serial +device settings, and close the serial device. If the \fIpersist\fR or +\fIdemand\fR option has been specified, pppd will try to reopen the +serial device and start another connection (after the holdoff period). +Otherwise pppd will exit. If this signal is received during the +holdoff period, it causes pppd to end the holdoff period immediately. .TP .B SIGUSR1 -This signal causes -.B pppd -to toggle debugging on or off. +This signal toggles the state of the \fIdebug\fR option. .TP .B SIGUSR2 -This signal causes -.B pppd -to renegotiate compression. This can be useful to re-enable -compression after it has been disabled as a result of a fatal -decompression error. With the BSD Compress scheme, fatal -decompression errors generally indicate a bug in one or other -implementation. +This signal causes pppd to renegotiate compression. This can be +useful to re-enable compression after it has been disabled as a result +of a fatal decompression error. (Fatal decompression errors generally +indicate a bug in one or other implementation.) .SH AUTHORS -Paul Mackerras (paulus@cs.anu.edu.au), based on earlier work by +Paul Mackerras (Paul.Mackerras@cs.anu.edu.au), based on earlier work by Drew Perkins, Brad Clements, Karl Fox, diff --git a/usr.sbin/pppd/pppd.h b/usr.sbin/pppd/pppd.h index 5dd30475793..9400f09e003 100644 --- a/usr.sbin/pppd/pppd.h +++ b/usr.sbin/pppd/pppd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pppd.h,v 1.7 1997/10/25 05:09:56 millert Exp $ */ +/* $OpenBSD: pppd.h,v 1.8 1998/01/17 20:30:28 millert Exp $ */ /* * pppd.h - PPP daemon global declarations. @@ -180,9 +180,9 @@ extern struct protent *protocols[]; void die __P((int)); /* Cleanup and exit */ void quit __P((void)); /* like die(1) */ void novm __P((char *)); /* Say we ran out of memory, and die */ -void timeout __P((void (*func)(caddr_t), caddr_t arg, int t)); +void timeout __P((void (*func)(void *), void *arg, int t)); /* Call func(arg) after t seconds */ -void untimeout __P((void (*func)(caddr_t), caddr_t arg)); +void untimeout __P((void (*func)(void *), void *arg)); /* Cancel call to func(arg) */ int run_program __P((char *prog, char **args, int must_exist)); /* Run program prog with args in child */ diff --git a/usr.sbin/pppd/sys-bsd.c b/usr.sbin/pppd/sys-bsd.c index e48d71b47b8..bc02bff9b32 100644 --- a/usr.sbin/pppd/sys-bsd.c +++ b/usr.sbin/pppd/sys-bsd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sys-bsd.c,v 1.11 1997/12/17 08:49:46 deraadt Exp $ */ +/* $OpenBSD: sys-bsd.c,v 1.12 1998/01/17 20:30:29 millert Exp $ */ /* * sys-bsd.c - System-dependent procedures for setting up @@ -24,9 +24,9 @@ #ifndef lint #if 0 -static char rcsid[] = "Id: sys-bsd.c,v 1.28 1997/04/30 05:57:46 paulus Exp"; +static char rcsid[] = "Id: sys-bsd.c,v 1.29 1997/11/27 06:10:04 paulus Exp $"; #else -static char rcsid[] = "$OpenBSD: sys-bsd.c,v 1.11 1997/12/17 08:49:46 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: sys-bsd.c,v 1.12 1998/01/17 20:30:29 millert Exp $"; #endif #endif @@ -39,6 +39,7 @@ static char rcsid[] = "$OpenBSD: sys-bsd.c,v 1.11 1997/12/17 08:49:46 deraadt Ex #include <string.h> #include <stdlib.h> #include <unistd.h> +#include <err.h> #include <errno.h> #include <fcntl.h> #include <termios.h> @@ -323,7 +324,6 @@ sipxfaddr(unit, network, node) { int skfd; int result = 1; - struct sockaddr_ipx ipx_addr; struct ifreq ifr; struct sockaddr_ipx *sipx = (struct sockaddr_ipx *) &ifr.ifr_addr; @@ -375,7 +375,6 @@ cipxfaddr(unit) { int skfd; int result = 1; - struct sockaddr_ipx ipx_addr; struct ifreq ifr; struct sockaddr_ipx *sipx = (struct sockaddr_ipx *) &ifr.ifr_addr; diff --git a/usr.sbin/pppd/upap.c b/usr.sbin/pppd/upap.c index 2e1b57b2d4b..20deee29f38 100644 --- a/usr.sbin/pppd/upap.c +++ b/usr.sbin/pppd/upap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: upap.c,v 1.5 1997/09/05 04:32:46 millert Exp $ */ +/* $OpenBSD: upap.c,v 1.6 1998/01/17 20:30:30 millert Exp $ */ /* * upap.c - User/Password Authentication Protocol. @@ -23,7 +23,7 @@ #if 0 static char rcsid[] = "Id: upap.c,v 1.11 1997/04/30 05:59:56 paulus Exp"; #else -static char rcsid[] = "$OpenBSD: upap.c,v 1.5 1997/09/05 04:32:46 millert Exp $"; +static char rcsid[] = "$OpenBSD: upap.c,v 1.6 1998/01/17 20:30:30 millert Exp $"; #endif #endif @@ -71,8 +71,8 @@ struct protent pap_protent = { upap_state upap[NUM_PPP]; /* UPAP state; one for each unit */ -static void upap_timeout __P((caddr_t)); -static void upap_reqtimeout __P((caddr_t)); +static void upap_timeout __P((void *)); +static void upap_reqtimeout __P((void *)); static void upap_rauthreq __P((upap_state *, u_char *, int, int)); static void upap_rauthack __P((upap_state *, u_char *, int, int)); static void upap_rauthnak __P((upap_state *, u_char *, int, int)); @@ -153,7 +153,7 @@ upap_authpeer(unit) u->us_serverstate = UPAPSS_LISTEN; if (u->us_reqtimeout > 0) - TIMEOUT(upap_reqtimeout, (caddr_t) u, u->us_reqtimeout); + TIMEOUT(upap_reqtimeout, u, u->us_reqtimeout); } @@ -162,7 +162,7 @@ upap_authpeer(unit) */ static void upap_timeout(arg) - caddr_t arg; + void *arg; { upap_state *u = (upap_state *) arg; @@ -186,7 +186,7 @@ upap_timeout(arg) */ static void upap_reqtimeout(arg) - caddr_t arg; + void *arg; { upap_state *u = (upap_state *) arg; @@ -220,7 +220,7 @@ upap_lowerup(unit) else if (u->us_serverstate == UPAPSS_PENDING) { u->us_serverstate = UPAPSS_LISTEN; if (u->us_reqtimeout > 0) - TIMEOUT(upap_reqtimeout, (caddr_t) u, u->us_reqtimeout); + TIMEOUT(upap_reqtimeout, u, u->us_reqtimeout); } } @@ -237,9 +237,9 @@ upap_lowerdown(unit) upap_state *u = &upap[unit]; if (u->us_clientstate == UPAPCS_AUTHREQ) /* Timeout pending? */ - UNTIMEOUT(upap_timeout, (caddr_t) u); /* Cancel timeout */ + UNTIMEOUT(upap_timeout, u); /* Cancel timeout */ if (u->us_serverstate == UPAPSS_LISTEN && u->us_reqtimeout > 0) - UNTIMEOUT(upap_reqtimeout, (caddr_t) u); + UNTIMEOUT(upap_reqtimeout, u); u->us_clientstate = UPAPCS_INITIAL; u->us_serverstate = UPAPSS_INITIAL; @@ -401,7 +401,7 @@ upap_rauthreq(u, inp, id, len) } if (u->us_reqtimeout > 0) - UNTIMEOUT(upap_reqtimeout, (caddr_t) u); + UNTIMEOUT(upap_reqtimeout, u); } @@ -513,7 +513,7 @@ upap_sauthreq(u) UPAPDEBUG((LOG_INFO, "pap_sauth: Sent id %d.", u->us_id)); - TIMEOUT(upap_timeout, (caddr_t) u, u->us_timeouttime); + TIMEOUT(upap_timeout, u, u->us_timeouttime); ++u->us_transmits; u->us_clientstate = UPAPCS_AUTHREQ; } |