diff --git a/usr.sbin/ppp/Makefile b/usr.sbin/ppp/Makefile index 33a2b9f23f86..685941deaba3 100644 --- a/usr.sbin/ppp/Makefile +++ b/usr.sbin/ppp/Makefile @@ -1,13 +1,13 @@ -# $Id: Makefile,v 1.5 1996/01/30 20:04:20 phk Exp $ +# $Id: Makefile,v 1.6 1996/03/04 10:38:41 ache Exp $ PROG= ppp SRCS= async.c auth.c ccp.c chap.c chat.c command.c filter.c fsm.c hdlc.c \ ip.c ipcp.c lcp.c lqr.c log.c main.c mbuf.c modem.c os.c \ pap.c pred.c route.c slcompress.c timer.c systems.c uucplock.c vars.c \ - vjcomp.c arp.c + vjcomp.c arp.c passwdauth.c #CFLAGS+= -DHAVE_SHELL_CMD_WITH_ANY_MODE -CFLAGS += -Wall -DUSE_PERROR -LDADD += -lmd +CFLAGS += -Wall -DUSE_PERROR -DMSEXT -DPASSWDAUTH -DLOCALHACK +LDADD += -lmd -lcrypt -lutil DPADD += ${LIBMD} MAN8= ppp.8 BINMODE=4555 diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c index da39f6b858b0..62aa0d0016dd 100644 --- a/usr.sbin/ppp/command.c +++ b/usr.sbin/ppp/command.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: command.c,v 1.18 1996/06/09 20:40:58 ache Exp $ + * $Id: command.c,v 1.19 1996/09/28 11:25:47 bde Exp $ * */ #include @@ -361,6 +361,18 @@ static int ShowRedial() return(1); } +#ifdef MSEXT +static int ShowMSExt() +{ + printf(" MS PPP extention values \n" ); + printf(" Primary NS : %s\n", inet_ntoa( ns_entries[0] )); + printf(" Secondary NS : %s\n", inet_ntoa( ns_entries[1] )); + printf(" Primary NBNS : %s\n", inet_ntoa( nbns_entries[0] )); + printf(" Secondary NBNS : %s\n", inet_ntoa( nbns_entries[1] )); + + return(1); +} +#endif /* MSEXT */ extern int ShowIfilter(), ShowOfilter(), ShowDfilter(), ShowAfilter(); @@ -403,6 +415,10 @@ struct cmdtab const ShowCommands[] = { "Show Idle timeout value", StrNull}, { "redial", NULL, ShowRedial, LOCAL_AUTH, "Show Redial timeout value", StrNull}, +#ifdef MSEXT + { "msext", NULL, ShowMSExt, LOCAL_AUTH, + "Show MS PPP extention values", StrNull}, +#endif /* MSEXT */ { "version", NULL, ShowVersion, LOCAL_NO_AUTH | LOCAL_AUTH, "Show version string", StrNull}, { "help", "?", HelpCommand, LOCAL_NO_AUTH | LOCAL_AUTH, @@ -808,6 +824,59 @@ char **argv; return(1); } +#ifdef MSEXT + +void +SetMSEXT(pri_addr, sec_addr, argc, argv) +struct in_addr *pri_addr; +struct in_addr *sec_addr; +int argc; +char **argv; +{ + int dummyint; + struct in_addr dummyaddr; + + pri_addr->s_addr = sec_addr->s_addr = 0L; + + if( argc > 0 ) { + ParseAddr(argc, argv++, pri_addr, &dummyaddr, &dummyint); + if( --argc > 0 ) + ParseAddr(argc, argv++, sec_addr, &dummyaddr, &dummyint); + else + sec_addr->s_addr = pri_addr->s_addr; + } + + /* + * if the primary/secondary ns entries are 0.0.0.0 we should + * set them to either the localhost's ip, or the values in + * /etc/resolv.conf ?? + * + * up to you if you want to implement this... + */ + +} + +static int +SetNS(list, argc, argv) +struct cmdtab *list; +int argc; +char **argv; +{ + SetMSEXT(&ns_entries[0], &ns_entries[1], argc, argv); + return(1); +} + +static int +SetNBNS(list, argc, argv) +struct cmdtab *list; +int argc; +char **argv; +{ + SetMSEXT(&nbns_entries[0], &nbns_entries[1], argc, argv); + return(1); +} + +#endif /* MS_EXT */ #define VAR_AUTHKEY 0 #define VAR_DIAL 1 @@ -919,6 +988,12 @@ struct cmdtab const SetCommands[] = { "Set Idle timeout", StrValue}, { "redial", NULL, SetRedialTimeout, LOCAL_AUTH, "Set Redial timeout", "value|random [dial_attempts]"}, +#ifdef MSEXT + { "ns", NULL, SetNS, LOCAL_AUTH, + "Set NameServer", "pri-addr [sec-addr]"}, + { "nbns", NULL, SetNBNS, LOCAL_AUTH, + "Set NetBIOS NameServer", "pri-addr [sec-addr]"}, +#endif /* MSEXT */ { "help", "?", HelpCommand, LOCAL_AUTH | LOCAL_NO_AUTH, "Display this message", StrNull, (void *)SetCommands}, { NULL, NULL, NULL }, diff --git a/usr.sbin/ppp/ipcp.c b/usr.sbin/ppp/ipcp.c index 5b9278595387..6df1d4dc8bfc 100644 --- a/usr.sbin/ppp/ipcp.c +++ b/usr.sbin/ppp/ipcp.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: ipcp.c,v 1.7 1996/01/11 17:48:50 phk Exp $ + * $Id: ipcp.c,v 1.8 1996/05/11 20:48:26 phk Exp $ * * TODO: * o More RFC1772 backwoard compatibility @@ -43,6 +43,10 @@ extern struct in_addr ifnetmask; struct ipcpstate IpcpInfo; struct in_range DefMyAddress, DefHisAddress, DefTriggerAddress; +#ifdef MSEXT +struct in_addr ns_entries[2], nbns_entries[2]; +#endif /* MSEXT */ + static void IpcpSendConfigReq __P((struct fsm *)); static void IpcpSendTerminateAck __P((struct fsm *)); static void IpcpSendTerminateReq __P((struct fsm *)); @@ -310,7 +314,7 @@ int mode; int type, length; u_long *lp, compproto; struct compreq *pcomp; - struct in_addr ipaddr, dstipaddr; + struct in_addr ipaddr, dstipaddr, dnsstuff, ms_info_req; char tbuff[100]; ackp = AckBuff; @@ -452,6 +456,102 @@ int mode; break; } break; + + /* + * MS extensions for MS's PPP + */ + +#ifdef MSEXT + case TY_PRIMARY_DNS: /* MS PPP DNS negotiation hack */ + case TY_SECONDARY_DNS: + if( !Enabled( ConfMSExt ) ) { + LogPrintf( LOG_LCP, "MS NS req - rejected - msext disabled\n" ); + IpcpInfo.my_reject |= ( 1 << type ); + bcopy(cp, rejp, length); + rejp += length; + break; + } + switch( mode ){ + case MODE_REQ: + lp = (u_long *)(cp + 2); + dnsstuff.s_addr = *lp; + ms_info_req.s_addr = ns_entries[((type - TY_PRIMARY_DNS)?1:0)].s_addr; + if( dnsstuff.s_addr != ms_info_req.s_addr ) + { + /* + So the client has got the DNS stuff wrong (first request) + so well tell 'em how it is + */ + bcopy( cp, nakp, 2 ); /* copy first two (type/length) */ + LogPrintf( LOG_LCP, "MS NS req %d:%s->%s - nak\n", + type, + inet_ntoa( dnsstuff ), + inet_ntoa( ms_info_req )); + bcopy( &ms_info_req, nakp+2, length ); + nakp += length; + break; + } + /* + Otherwise they have it right (this time) so we send + a ack packet back confirming it... end of story + */ + LogPrintf( LOG_LCP, "MS NS req %d:%s ok - ack\n", + type, + inet_ntoa( ms_info_req )); + bcopy( cp, ackp, length ); + ackp += length; + break; + case MODE_NAK: /* what does this mean?? */ + LogPrintf(LOG_LCP, "MS NS req %d - NAK??\n", type ); + break; + case MODE_REJ: /* confused?? me to :) */ + LogPrintf(LOG_LCP, "MS NS req %d - REJ??\n", type ); + break; + } + break; + + case TY_PRIMARY_NBNS: /* MS PPP NetBIOS nameserver hack */ + case TY_SECONDARY_NBNS: + if( !Enabled( ConfMSExt ) ) { + LogPrintf( LOG_LCP, "MS NBNS req - rejected - msext disabled\n" ); + IpcpInfo.my_reject |= ( 1 << type ); + bcopy( cp, rejp, length ); + rejp += length; + break; + } + switch( mode ){ + case MODE_REQ: + lp = (u_long *)(cp + 2); + dnsstuff.s_addr = *lp; + ms_info_req.s_addr = nbns_entries[((type - TY_PRIMARY_NBNS)?1:0)].s_addr; + if( dnsstuff.s_addr != ms_info_req.s_addr ) + { + bcopy( cp, nakp, 2 ); + bcopy( &ms_info_req.s_addr , nakp+2, length ); + LogPrintf( LOG_LCP, "MS NBNS req %d:%s->%s - nak\n", + type, + inet_ntoa( dnsstuff ), + inet_ntoa( ms_info_req )); + nakp += length; + break; + } + LogPrintf( LOG_LCP, "MS NBNS req %d:%s ok - ack\n", + type, + inet_ntoa( ms_info_req )); + bcopy( cp, ackp, length ); + ackp += length; + break; + case MODE_NAK: + LogPrintf( LOG_LCP, "MS NBNS req %d - NAK??\n", type ); + break; + case MODE_REJ: + LogPrintf( LOG_LCP, "MS NBNS req %d - REJ??\n", type ); + break; + } + break; + +#endif /* MSEXT */ + default: IpcpInfo.my_reject |= (1 << type); bcopy(cp, rejp, length); diff --git a/usr.sbin/ppp/ipcp.h b/usr.sbin/ppp/ipcp.h index 220381fa2e8d..053ca57aca63 100644 --- a/usr.sbin/ppp/ipcp.h +++ b/usr.sbin/ppp/ipcp.h @@ -15,7 +15,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: ipcp.h,v 1.2 1995/02/26 12:17:34 amurai Exp $ + * $Id: ipcp.h,v 1.3 1995/07/08 08:28:10 amurai Exp $ * * TODO: */ @@ -29,6 +29,17 @@ #define TY_COMPPROTO 2 #define TY_IPADDR 3 +/* MS PPP NameServer and NetBIOS NameServer stuff */ + +#ifdef MSEXT + +#define TY_PRIMARY_DNS 129 +#define TY_PRIMARY_NBNS 130 +#define TY_SECONDARY_DNS 131 +#define TY_SECONDARY_NBNS 132 + +#endif /* MSEXT */ + struct ipcpstate { struct in_addr his_ipaddr; /* IP address he is willing to use */ u_long his_compproto; @@ -58,6 +69,11 @@ extern struct in_range DefMyAddress; extern struct in_range DefHisAddress; extern struct in_range DefTriggerAddress; +#ifdef MSEXT +extern struct in_addr ns_entries[2]; +extern struct in_addr nbns_entries[2]; +#endif /* MSEXT */ + extern void IpcpInit __P((void)); extern void IpcpDefAddress __P((void)); #endif diff --git a/usr.sbin/ppp/pap.c b/usr.sbin/ppp/pap.c index 7e7bdc601ae1..0004d638279e 100644 --- a/usr.sbin/ppp/pap.c +++ b/usr.sbin/ppp/pap.c @@ -18,7 +18,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: pap.c,v 1.4 1996/01/30 11:08:45 dfr Exp $ + * $Id: pap.c,v 1.5 1996/05/11 20:48:38 phk Exp $ * * TODO: */ @@ -111,6 +111,15 @@ u_char *name, *key; #ifdef DEBUG logprintf("name: %s (%d), key: %s (%d)\n", name, nlen, key, klen); #endif + +#ifdef PASSWDAUTH + if( Enabled( ConfPasswdAuth ) ) + { + LogPrintf( LOG_LCP, "PasswdAuth enabled - calling\n" ); + return PasswdAuth( name, key ); + } +#endif /* PASSWDAUTH */ + return(AuthValidate(SECRETFILE, name, key)); } diff --git a/usr.sbin/ppp/passwdauth.c b/usr.sbin/ppp/passwdauth.c new file mode 100644 index 000000000000..eeed42066a7c --- /dev/null +++ b/usr.sbin/ppp/passwdauth.c @@ -0,0 +1,112 @@ +/* + * + * passwdauth.c - pjchilds@imforei.apana.org.au + * + * authenticate user via the password file + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the Peter Childs. The name of the author may not be used to + * endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + */ + +#include +#include +#include +#include +#include +#include "fsm.h" +#include "passwdauth.h" + +int +PasswdAuth(name, key) +char *name, *key; +{ + static int logged_in = 0; + struct passwd *pwd; + char *salt, *ep; + struct utmp utmp; + +#ifdef DEBUG + logprintf( "passwdauth called with name= %s, key= %s\n", name, key ); +#endif /* DEBUG */ + + if(( pwd = getpwnam( name ) )) + salt = pwd->pw_passwd; + else + { + endpwent(); + LogPrintf( LOG_LCP, "PasswdAuth - user (%s) not in passwd file\n", name ); + return 0; /* false - failed to authenticate (password not in file) */ + } + +#ifdef LOCALHACK + /* + * All our PPP usernames start with 'P' so i check that here... if you + * don't do this i suggest all your PPP users be members of a group + * and you check the guid + */ + + if( name[0] != 'P' ) + { + LogPrintf( LOG_LCP, "PasswdAuth - user (%s) not a PPP user\n", name ); + endpwent(); + return 0; + } + +#endif /* LOCALHACK */ + + ep = crypt( key, salt ); + + /* strcmp returns 0 if same */ + if( strcmp( ep, pwd->pw_passwd ) != 0 ) + { + LogPrintf( LOG_LCP, "PasswdAuth - user (%s,%s) authentication failed\n", + name, key ); + endpwent(); + return 0; /* false - failed to authenticate (didn't match up) */ + } + + /* + * now we log them in... we have a static login flag so we don't + * do it twice :) + */ + + if( ! logged_in ) + { + (void)time(&utmp.ut_time); + (void)strncpy(utmp.ut_name, name, sizeof(utmp.ut_name)); + +#ifdef LOCALHACK + + /* we trim the first three characters off here.. see sample.ppp.conf */ + (void)strncpy(utmp.ut_line, (char *)(dstsystem + 3), sizeof(utmp.ut_line)); + +#else + + (void)strncpy(utmp.ut_line, dstsystem, sizeof(utmp.ut_line)); + +#endif /* LOCALHACK */ + + (void)strcpy(utmp.ut_host, "auto-ppp" ); + login(&utmp); + (void)setlogin( pwd->pw_name ); + + LogPrintf( LOG_LCP, "PasswdAuth has logged in user %s\n", name ); + + logged_in = 1; + } + + endpwent(); + + return 1; +} diff --git a/usr.sbin/ppp/passwdauth.h b/usr.sbin/ppp/passwdauth.h new file mode 100644 index 000000000000..da34ccbb6307 --- /dev/null +++ b/usr.sbin/ppp/passwdauth.h @@ -0,0 +1,11 @@ +/* + * passwdauth.h + * + */ + +#ifndef _PASSWDAUTH_H_ +#define _PASSWDAUTH_H_ + +extern int PasswdAuth __P((char *, char *)); + +#endif diff --git a/usr.sbin/ppp/ppp.8 b/usr.sbin/ppp/ppp.8 index c3362f6f5db9..2c4a1d163761 100644 --- a/usr.sbin/ppp/ppp.8 +++ b/usr.sbin/ppp/ppp.8 @@ -1,12 +1,12 @@ .\" manual page [] for ppp 0.94 beta2 + alpha -.\" $Id: ppp.8,v 1.16 1996/05/02 19:18:47 mpp Exp $ +.\" $Id: ppp.8,v 1.17 1996/05/11 20:48:40 phk Exp $ .Dd 20 September 1995 .Os FreeBSD .Dt PPP 8 .Sh NAME .Nm ppp .Nd -Point to Point Protocol (aka iijppp) +Point to Point Protocol (aka iijppp) .Sh SYNOPSIS .Nm .Op Fl auto | Fl direct | Fl dedicated @@ -60,7 +60,6 @@ connections. .It Supports PAP and CHAP authentication. - .It Supports Proxy Arp. When .Em PPP @@ -101,6 +100,12 @@ compression pre-compresses .Em all data flowing through the link, thus reducing overhead to a minimum. +.It Supports Microsofts IPCP extentions. +Name Server Addresses and NetBIOS Name Server Addresses can be negotiated +with clients using the Microsoft +.Em PPP +stack (ie. Win95, WinNT) + .It Runs under BSDI-1.1 and FreeBSD. .El @@ -421,7 +426,7 @@ See .Pa /etc/ppp/ppp.conf.filter.example . -.Sh RECEIVING INCOMING PPP CONNECTIONS +.Sh RECEIVING INCOMING PPP CONNECTIONS (Method 1) To handle an incoming .Em PPP @@ -469,8 +474,6 @@ file with the following contents: (You can specify a label name for further control.) -.El - .Pp Direct mode ( .Fl direct ) @@ -478,7 +481,62 @@ lets .Nm work with stdin and stdout. You can also telnet to port 3000 to get command mode control in the same manner as client-side -.Nm . +.Nm. + +.It +Optional support for Microsoft's IPCP Name Server and NetBIOS +Name Server negotiation can be enabled use +.Dq enable msext +and +.Dq set ns pri-addr [sec-addr] +along with +.Dq set nbns pri-addr [sec-addr] +in your ppp.conf file + +.El + +.Sh RECEIVING INCOMING PPP CONNECTIONS (Method 2) + +This method differs in that it recommends the use of +.Em mgetty+sendfax +to handle the modem connections. The latest version 0.99 +can be compiled with the +.Dq AUTO_PPP +option to allow detection of clients speaking PPP to the login +prompt. + +Follow these steps: + +.Bl -enum +.It +Get, configure, and install mgetty+sendfax v0.99 or later (beta) +making sure you have used the AUTO_PPP option. +.It +Edit +.Pa /etc/ttys +to enable a mgetty on the port where the modem is attached. + +For example: + +.Dl cuaa1 "/usr/local/sbin/mgetty -s 57600" dialup on + +.It +Prepare an account for the incoming user. +.Bd -literal +Pfred:xxxx:66:66:Fred's PPP:/home/ppp:/etc/ppp/ppp-dialup +.Ed + +.It +Examine the files +.Pa /etc/ppp/sample.ppp-dialup +.Pa /etc/ppp/sample.ppp-pap-dialup +and +.Pa /etc/ppp/sample.ppp.conf +for ideas. ppp-pap-dialup is supposed to be called from +.Pa /usr/local/etc/mgetty+sendfax/login.conf +from a line like + +.Dl /AutoPPP/ - - /etc/ppp/ppp-pap-dialup .Sh SETTING IDLE, LINE QUALITY REQUEST, RETRY TIMER diff --git a/usr.sbin/ppp/ppp.8.m4 b/usr.sbin/ppp/ppp.8.m4 index c3362f6f5db9..2c4a1d163761 100644 --- a/usr.sbin/ppp/ppp.8.m4 +++ b/usr.sbin/ppp/ppp.8.m4 @@ -1,12 +1,12 @@ .\" manual page [] for ppp 0.94 beta2 + alpha -.\" $Id: ppp.8,v 1.16 1996/05/02 19:18:47 mpp Exp $ +.\" $Id: ppp.8,v 1.17 1996/05/11 20:48:40 phk Exp $ .Dd 20 September 1995 .Os FreeBSD .Dt PPP 8 .Sh NAME .Nm ppp .Nd -Point to Point Protocol (aka iijppp) +Point to Point Protocol (aka iijppp) .Sh SYNOPSIS .Nm .Op Fl auto | Fl direct | Fl dedicated @@ -60,7 +60,6 @@ connections. .It Supports PAP and CHAP authentication. - .It Supports Proxy Arp. When .Em PPP @@ -101,6 +100,12 @@ compression pre-compresses .Em all data flowing through the link, thus reducing overhead to a minimum. +.It Supports Microsofts IPCP extentions. +Name Server Addresses and NetBIOS Name Server Addresses can be negotiated +with clients using the Microsoft +.Em PPP +stack (ie. Win95, WinNT) + .It Runs under BSDI-1.1 and FreeBSD. .El @@ -421,7 +426,7 @@ See .Pa /etc/ppp/ppp.conf.filter.example . -.Sh RECEIVING INCOMING PPP CONNECTIONS +.Sh RECEIVING INCOMING PPP CONNECTIONS (Method 1) To handle an incoming .Em PPP @@ -469,8 +474,6 @@ file with the following contents: (You can specify a label name for further control.) -.El - .Pp Direct mode ( .Fl direct ) @@ -478,7 +481,62 @@ lets .Nm work with stdin and stdout. You can also telnet to port 3000 to get command mode control in the same manner as client-side -.Nm . +.Nm. + +.It +Optional support for Microsoft's IPCP Name Server and NetBIOS +Name Server negotiation can be enabled use +.Dq enable msext +and +.Dq set ns pri-addr [sec-addr] +along with +.Dq set nbns pri-addr [sec-addr] +in your ppp.conf file + +.El + +.Sh RECEIVING INCOMING PPP CONNECTIONS (Method 2) + +This method differs in that it recommends the use of +.Em mgetty+sendfax +to handle the modem connections. The latest version 0.99 +can be compiled with the +.Dq AUTO_PPP +option to allow detection of clients speaking PPP to the login +prompt. + +Follow these steps: + +.Bl -enum +.It +Get, configure, and install mgetty+sendfax v0.99 or later (beta) +making sure you have used the AUTO_PPP option. +.It +Edit +.Pa /etc/ttys +to enable a mgetty on the port where the modem is attached. + +For example: + +.Dl cuaa1 "/usr/local/sbin/mgetty -s 57600" dialup on + +.It +Prepare an account for the incoming user. +.Bd -literal +Pfred:xxxx:66:66:Fred's PPP:/home/ppp:/etc/ppp/ppp-dialup +.Ed + +.It +Examine the files +.Pa /etc/ppp/sample.ppp-dialup +.Pa /etc/ppp/sample.ppp-pap-dialup +and +.Pa /etc/ppp/sample.ppp.conf +for ideas. ppp-pap-dialup is supposed to be called from +.Pa /usr/local/etc/mgetty+sendfax/login.conf +from a line like + +.Dl /AutoPPP/ - - /etc/ppp/ppp-pap-dialup .Sh SETTING IDLE, LINE QUALITY REQUEST, RETRY TIMER diff --git a/usr.sbin/ppp/route.c b/usr.sbin/ppp/route.c index 23ad578f1aec..b9570fa25e6c 100644 --- a/usr.sbin/ppp/route.c +++ b/usr.sbin/ppp/route.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: route.c,v 1.6 1996/05/11 20:48:42 phk Exp $ + * $Id: route.c,v 1.7 1996/08/13 09:19:45 peter Exp $ * */ #include @@ -351,14 +351,20 @@ int all; free(sp); } + /* + * 960603 - Modified to use dynamic buffer allocator as in ifconfig + */ + int GetIfIndex(name) char *name; { + char *buffer; struct ifreq *ifrp; int s, len, elen, index; struct ifconf ifconfs; - struct ifreq reqbuf[32]; + /* struct ifreq reqbuf[256]; -- obsoleted :) */ + int oldbufsize, bufsize = sizeof(struct ifreq); s = socket(AF_INET, SOCK_DGRAM, 0); if (s < 0) { @@ -366,12 +372,27 @@ char *name; return(-1); } - ifconfs.ifc_len = sizeof(reqbuf); - ifconfs.ifc_buf = (caddr_t)reqbuf; - if (ioctl(s, SIOCGIFCONF, &ifconfs) < 0) { - perror("IFCONF"); - return(-1); - } + buffer = malloc(bufsize); /* allocate first buffer */ + ifconfs.ifc_len = bufsize; /* Initial setting */ + /* + * Iterate through here until we don't get many more data + */ + + do { + oldbufsize = ifconfs.ifc_len; + bufsize += 1+sizeof(struct ifreq); + buffer = realloc((void *)buffer, bufsize); /* Make it bigger */ +#ifdef DEBUG + logprintf ("Growing buffer to %d\n", bufsize); +#endif + ifconfs.ifc_len = bufsize; + ifconfs.ifc_buf = buffer; + if (ioctl(s, SIOCGIFCONF, &ifconfs) < 0) { + perror("IFCONF"); + free(buffer); + return(-1); + } + } while (ifconfs.ifc_len > oldbufsize); ifrp = ifconfs.ifc_req; @@ -385,6 +406,7 @@ char *name; #endif if (strcmp(ifrp->ifr_name, name) == 0) { IfIndex = index; + free(buffer); return(index); } index++; @@ -396,5 +418,6 @@ char *name; } close(s); + free(buffer); return(-1); } diff --git a/usr.sbin/ppp/vars.c b/usr.sbin/ppp/vars.c index 7f5a65134269..ec0c55d185c2 100644 --- a/usr.sbin/ppp/vars.c +++ b/usr.sbin/ppp/vars.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: vars.c,v 1.6 1995/10/08 14:57:31 amurai Exp $ + * $Id: vars.c,v 1.7 1996/01/10 21:28:04 phk Exp $ * */ #include "fsm.h" @@ -29,7 +29,7 @@ #include "defs.h" char VarVersion[] = "Version 0.94"; -char VarLocalVersion[] = "$Date: 1995/10/08 14:57:31 $"; +char VarLocalVersion[] = "$Date: 1996/01/10 21:28:04 $"; /* * Order of conf option is important. See vars.h. @@ -42,7 +42,9 @@ struct confdesc pppConfs[] = { { "acfcomp", CONF_ENABLE, CONF_ACCEPT }, { "protocomp", CONF_ENABLE, CONF_ACCEPT }, { "pred1", CONF_ENABLE, CONF_ACCEPT }, - { "proxy", CONF_DISABLE, CONF_DENY }, + { "proxy", CONF_DISABLE, CONF_DENY }, + { "msext", CONF_DISABLE, CONF_ACCEPT }, + { "passwdauth",CONF_ENABLE, CONF_DENY }, { NULL }, }; diff --git a/usr.sbin/ppp/vars.h b/usr.sbin/ppp/vars.h index cf28a06e314a..ef1dc98de287 100644 --- a/usr.sbin/ppp/vars.h +++ b/usr.sbin/ppp/vars.h @@ -15,7 +15,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: vars.h,v 1.5 1996/03/08 09:03:09 ache Exp $ + * $Id: vars.h,v 1.6 1996/03/08 13:22:23 ache Exp $ * * TODO: */ @@ -44,7 +44,9 @@ struct confdesc { #define ConfProtocomp 5 #define ConfPred1 6 #define ConfProxy 7 -#define MAXCONFS 8 +#define ConfMSExt 8 +#define ConfPasswdAuth 9 +#define MAXCONFS 10 #define Enabled(x) (pppConfs[x].myside & CONF_ENABLE) #define Acceptable(x) (pppConfs[x].hisside & CONF_ACCEPT)