2001-06-13 21:52:19 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
|
|
|
|
* based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
|
|
|
|
* Internet Initiative Japan, Inc (IIJ)
|
|
|
|
* All rights reserved.
|
1995-01-31 06:29:58 +00:00
|
|
|
*
|
2001-06-13 21:52:19 +00:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
1995-01-31 06:29:58 +00:00
|
|
|
*
|
2001-06-13 21:52:19 +00:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
1995-05-30 03:57:47 +00:00
|
|
|
*
|
1999-08-28 01:35:59 +00:00
|
|
|
* $FreeBSD$
|
1995-01-31 06:29:58 +00:00
|
|
|
*/
|
2001-06-13 21:52:19 +00:00
|
|
|
|
1999-01-28 01:56:34 +00:00
|
|
|
#include <sys/param.h>
|
1997-10-26 01:04:02 +00:00
|
|
|
#include <netinet/in.h>
|
1998-03-16 22:54:35 +00:00
|
|
|
#include <netinet/in_systm.h>
|
|
|
|
#include <netinet/ip.h>
|
2001-08-14 16:05:52 +00:00
|
|
|
#include <sys/socket.h>
|
1998-04-28 01:25:46 +00:00
|
|
|
#include <sys/un.h>
|
1997-10-26 01:04:02 +00:00
|
|
|
|
1998-03-09 19:25:35 +00:00
|
|
|
#include <pwd.h>
|
1997-10-26 01:04:02 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
1999-02-02 09:35:17 +00:00
|
|
|
#include <termios.h>
|
1997-10-26 01:04:02 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
|
1999-05-08 11:07:56 +00:00
|
|
|
#include "layer.h"
|
1997-10-26 01:04:02 +00:00
|
|
|
#include "mbuf.h"
|
|
|
|
#include "defs.h"
|
1999-02-02 09:35:17 +00:00
|
|
|
#include "log.h"
|
1997-10-26 01:04:02 +00:00
|
|
|
#include "timer.h"
|
1995-01-31 06:29:58 +00:00
|
|
|
#include "fsm.h"
|
1998-01-29 23:11:44 +00:00
|
|
|
#include "iplist.h"
|
|
|
|
#include "throughput.h"
|
1998-03-16 22:54:35 +00:00
|
|
|
#include "slcompress.h"
|
1998-08-26 17:39:37 +00:00
|
|
|
#include "lqr.h"
|
|
|
|
#include "hdlc.h"
|
2001-08-14 16:05:52 +00:00
|
|
|
#include "ncpaddr.h"
|
1995-01-31 06:29:58 +00:00
|
|
|
#include "ipcp.h"
|
1995-02-26 12:18:08 +00:00
|
|
|
#include "auth.h"
|
1997-10-26 01:04:02 +00:00
|
|
|
#include "systems.h"
|
1998-02-02 19:33:40 +00:00
|
|
|
#include "lcp.h"
|
1998-04-03 19:21:56 +00:00
|
|
|
#include "ccp.h"
|
1998-02-02 19:33:40 +00:00
|
|
|
#include "link.h"
|
1998-02-09 19:21:11 +00:00
|
|
|
#include "descriptor.h"
|
1998-02-13 05:10:26 +00:00
|
|
|
#include "chat.h"
|
1999-05-08 11:07:56 +00:00
|
|
|
#include "proto.h"
|
1998-03-16 22:52:54 +00:00
|
|
|
#include "filter.h"
|
1998-04-03 19:21:56 +00:00
|
|
|
#include "mp.h"
|
1999-01-28 01:56:34 +00:00
|
|
|
#ifndef NORADIUS
|
|
|
|
#include "radius.h"
|
|
|
|
#endif
|
1999-02-02 09:35:17 +00:00
|
|
|
#include "cbcp.h"
|
|
|
|
#include "chap.h"
|
|
|
|
#include "async.h"
|
|
|
|
#include "physical.h"
|
|
|
|
#include "datalink.h"
|
2001-08-14 16:05:52 +00:00
|
|
|
#include "ipv6cp.h"
|
|
|
|
#include "ncp.h"
|
1998-03-13 21:07:46 +00:00
|
|
|
#include "bundle.h"
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1998-02-07 20:50:08 +00:00
|
|
|
const char *
|
1999-02-18 00:52:15 +00:00
|
|
|
Auth2Nam(u_short auth, u_char type)
|
1996-01-11 17:48:59 +00:00
|
|
|
{
|
1999-02-18 00:52:15 +00:00
|
|
|
static char chap[10];
|
|
|
|
|
1998-02-07 20:50:08 +00:00
|
|
|
switch (auth) {
|
|
|
|
case PROTO_PAP:
|
|
|
|
return "PAP";
|
|
|
|
case PROTO_CHAP:
|
1999-02-18 00:52:15 +00:00
|
|
|
snprintf(chap, sizeof chap, "CHAP 0x%02x", type);
|
|
|
|
return chap;
|
1998-02-07 20:50:08 +00:00
|
|
|
case 0:
|
|
|
|
return "none";
|
|
|
|
}
|
|
|
|
return "unknown";
|
1995-02-26 12:18:08 +00:00
|
|
|
}
|
|
|
|
|
1998-03-09 19:25:35 +00:00
|
|
|
static int
|
|
|
|
auth_CheckPasswd(const char *name, const char *data, const char *key)
|
|
|
|
{
|
|
|
|
if (!strcmp(data, "*")) {
|
|
|
|
/* Then look up the real password database */
|
|
|
|
struct passwd *pw;
|
|
|
|
int result;
|
|
|
|
|
|
|
|
result = (pw = getpwnam(name)) &&
|
|
|
|
!strcmp(crypt(key, pw->pw_passwd), pw->pw_passwd);
|
|
|
|
endpwent();
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
return !strcmp(data, key);
|
|
|
|
}
|
|
|
|
|
1998-01-29 00:44:16 +00:00
|
|
|
int
|
1998-08-07 18:42:51 +00:00
|
|
|
auth_SetPhoneList(const char *name, char *phone, int phonelen)
|
|
|
|
{
|
|
|
|
FILE *fp;
|
1999-12-20 20:30:02 +00:00
|
|
|
int n, lineno;
|
2002-01-08 11:24:39 +00:00
|
|
|
char *vector[6], buff[LINE_LEN];
|
|
|
|
const char *slash;
|
1998-08-07 18:42:51 +00:00
|
|
|
|
|
|
|
fp = OpenSecret(SECRETFILE);
|
|
|
|
if (fp != NULL) {
|
2002-01-08 11:24:39 +00:00
|
|
|
again:
|
|
|
|
lineno = 0;
|
1998-08-07 18:42:51 +00:00
|
|
|
while (fgets(buff, sizeof buff, fp)) {
|
1999-12-20 20:30:02 +00:00
|
|
|
lineno++;
|
1998-08-07 18:42:51 +00:00
|
|
|
if (buff[0] == '#')
|
|
|
|
continue;
|
|
|
|
buff[strlen(buff) - 1] = '\0';
|
|
|
|
memset(vector, '\0', sizeof vector);
|
1999-12-27 11:43:31 +00:00
|
|
|
if ((n = MakeArgs(buff, vector, VECSIZE(vector), PARSE_REDUCE)) < 0)
|
1999-12-20 20:30:02 +00:00
|
|
|
log_Printf(LogWARN, "%s: %d: Invalid line\n", SECRETFILE, lineno);
|
1998-08-07 18:42:51 +00:00
|
|
|
if (n < 5)
|
|
|
|
continue;
|
|
|
|
if (strcmp(vector[0], name) == 0) {
|
1999-01-28 01:56:34 +00:00
|
|
|
CloseSecret(fp);
|
|
|
|
if (*vector[4] == '\0')
|
1998-08-07 18:42:51 +00:00
|
|
|
return 0;
|
|
|
|
strncpy(phone, vector[4], phonelen - 1);
|
|
|
|
phone[phonelen - 1] = '\0';
|
1999-01-28 01:56:34 +00:00
|
|
|
return 1; /* Valid */
|
1998-08-07 18:42:51 +00:00
|
|
|
}
|
|
|
|
}
|
2002-01-08 11:24:39 +00:00
|
|
|
|
|
|
|
if ((slash = strrchr(name, '\\')) != NULL && slash[1]) {
|
|
|
|
/* Look for the name without the leading domain */
|
|
|
|
name = slash + 1;
|
|
|
|
rewind(fp);
|
|
|
|
goto again;
|
|
|
|
}
|
|
|
|
|
1998-08-07 18:42:51 +00:00
|
|
|
CloseSecret(fp);
|
|
|
|
}
|
|
|
|
*phone = '\0';
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
auth_Select(struct bundle *bundle, const char *name)
|
1997-08-25 00:29:32 +00:00
|
|
|
{
|
1995-02-26 12:18:08 +00:00
|
|
|
FILE *fp;
|
1999-12-20 20:30:02 +00:00
|
|
|
int n, lineno;
|
2002-01-08 11:24:39 +00:00
|
|
|
char *vector[5], buff[LINE_LEN];
|
|
|
|
const char *slash;
|
1995-02-26 12:18:08 +00:00
|
|
|
|
1998-04-24 19:16:15 +00:00
|
|
|
if (*name == '\0') {
|
1999-01-28 01:56:34 +00:00
|
|
|
ipcp_Setup(&bundle->ncp.ipcp, INADDR_NONE);
|
1998-04-24 19:16:15 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
1999-01-28 01:56:34 +00:00
|
|
|
#ifndef NORADIUS
|
2002-04-04 08:43:00 +00:00
|
|
|
if (bundle->radius.valid && bundle->radius.ip.s_addr != INADDR_NONE &&
|
|
|
|
bundle->radius.ip.s_addr != RADIUS_INADDR_POOL) {
|
1999-01-28 01:56:34 +00:00
|
|
|
/* We've got a radius IP - it overrides everything */
|
|
|
|
if (!ipcp_UseHisIPaddr(bundle, bundle->radius.ip))
|
|
|
|
return 0;
|
|
|
|
ipcp_Setup(&bundle->ncp.ipcp, bundle->radius.mask.s_addr);
|
|
|
|
/* Continue with ppp.secret in case we've got a new label */
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1998-04-24 19:16:15 +00:00
|
|
|
fp = OpenSecret(SECRETFILE);
|
|
|
|
if (fp != NULL) {
|
2002-01-08 11:24:39 +00:00
|
|
|
again:
|
|
|
|
lineno = 0;
|
1998-04-24 19:16:15 +00:00
|
|
|
while (fgets(buff, sizeof buff, fp)) {
|
1999-12-20 20:30:02 +00:00
|
|
|
lineno++;
|
1998-04-24 19:16:15 +00:00
|
|
|
if (buff[0] == '#')
|
|
|
|
continue;
|
1998-07-19 21:07:24 +00:00
|
|
|
buff[strlen(buff) - 1] = '\0';
|
1998-04-24 19:16:15 +00:00
|
|
|
memset(vector, '\0', sizeof vector);
|
1999-12-27 11:43:31 +00:00
|
|
|
if ((n = MakeArgs(buff, vector, VECSIZE(vector), PARSE_REDUCE)) < 0)
|
1999-12-20 20:30:02 +00:00
|
|
|
log_Printf(LogWARN, "%s: %d: Invalid line\n", SECRETFILE, lineno);
|
1998-04-24 19:16:15 +00:00
|
|
|
if (n < 2)
|
|
|
|
continue;
|
1998-07-19 21:07:24 +00:00
|
|
|
if (strcmp(vector[0], name) == 0) {
|
1999-01-28 01:56:34 +00:00
|
|
|
CloseSecret(fp);
|
|
|
|
#ifndef NORADIUS
|
|
|
|
if (!bundle->radius.valid || bundle->radius.ip.s_addr == INADDR_NONE) {
|
|
|
|
#endif
|
|
|
|
if (n > 2 && *vector[2] && strcmp(vector[2], "*") &&
|
|
|
|
!ipcp_UseHisaddr(bundle, vector[2], 1))
|
|
|
|
return 0;
|
|
|
|
ipcp_Setup(&bundle->ncp.ipcp, INADDR_NONE);
|
|
|
|
#ifndef NORADIUS
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (n > 3 && *vector[3] && strcmp(vector[3], "*"))
|
|
|
|
bundle_SetLabel(bundle, vector[3]);
|
|
|
|
return 1; /* Valid */
|
1998-07-19 21:07:24 +00:00
|
|
|
}
|
1995-02-26 12:18:08 +00:00
|
|
|
}
|
2002-01-08 11:24:39 +00:00
|
|
|
|
|
|
|
if ((slash = strrchr(name, '\\')) != NULL && slash[1]) {
|
|
|
|
/* Look for the name without the leading domain */
|
|
|
|
name = slash + 1;
|
|
|
|
rewind(fp);
|
|
|
|
goto again;
|
|
|
|
}
|
|
|
|
|
1998-04-24 19:16:15 +00:00
|
|
|
CloseSecret(fp);
|
1995-02-26 12:18:08 +00:00
|
|
|
}
|
1998-04-24 19:16:15 +00:00
|
|
|
|
|
|
|
#ifndef NOPASSWDAUTH
|
|
|
|
/* Let 'em in anyway - they must have been in the passwd file */
|
1999-01-28 01:56:34 +00:00
|
|
|
ipcp_Setup(&bundle->ncp.ipcp, INADDR_NONE);
|
1998-04-24 19:16:15 +00:00
|
|
|
return 1;
|
|
|
|
#else
|
1999-01-28 01:56:34 +00:00
|
|
|
#ifndef NORADIUS
|
|
|
|
if (bundle->radius.valid)
|
|
|
|
return 1;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Disappeared from ppp.secret ??? */
|
1998-04-24 19:16:15 +00:00
|
|
|
return 0;
|
|
|
|
#endif
|
1995-02-26 12:18:08 +00:00
|
|
|
}
|
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
int
|
1999-01-28 01:56:34 +00:00
|
|
|
auth_Validate(struct bundle *bundle, const char *name,
|
1998-02-02 19:32:16 +00:00
|
|
|
const char *key, struct physical *physical)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-03-09 19:25:35 +00:00
|
|
|
/* Used by PAP routines */
|
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
FILE *fp;
|
1999-12-20 20:30:02 +00:00
|
|
|
int n, lineno;
|
2002-01-08 11:24:39 +00:00
|
|
|
char *vector[5], buff[LINE_LEN];
|
|
|
|
const char *slash;
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1998-04-24 19:16:15 +00:00
|
|
|
fp = OpenSecret(SECRETFILE);
|
2002-01-08 11:24:39 +00:00
|
|
|
again:
|
1999-12-20 20:30:02 +00:00
|
|
|
lineno = 0;
|
1998-03-09 19:25:35 +00:00
|
|
|
if (fp != NULL) {
|
|
|
|
while (fgets(buff, sizeof buff, fp)) {
|
1999-12-20 20:30:02 +00:00
|
|
|
lineno++;
|
1998-03-09 19:25:35 +00:00
|
|
|
if (buff[0] == '#')
|
|
|
|
continue;
|
|
|
|
buff[strlen(buff) - 1] = 0;
|
|
|
|
memset(vector, '\0', sizeof vector);
|
1999-12-27 11:43:31 +00:00
|
|
|
if ((n = MakeArgs(buff, vector, VECSIZE(vector), PARSE_REDUCE)) < 0)
|
1999-12-20 20:30:02 +00:00
|
|
|
log_Printf(LogWARN, "%s: %d: Invalid line\n", SECRETFILE, lineno);
|
1998-03-09 19:25:35 +00:00
|
|
|
if (n < 2)
|
|
|
|
continue;
|
1999-01-28 01:56:34 +00:00
|
|
|
if (strcmp(vector[0], name) == 0) {
|
|
|
|
CloseSecret(fp);
|
|
|
|
return auth_CheckPasswd(name, vector[1], key);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-03-09 19:25:35 +00:00
|
|
|
|
2002-01-08 11:24:39 +00:00
|
|
|
if ((slash = strrchr(name, '\\')) != NULL && slash[1]) {
|
|
|
|
/* Look for the name without the leading domain */
|
|
|
|
name = slash + 1;
|
|
|
|
if (fp != NULL) {
|
|
|
|
rewind(fp);
|
|
|
|
goto again;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fp != NULL)
|
|
|
|
CloseSecret(fp);
|
|
|
|
|
1998-03-09 19:25:35 +00:00
|
|
|
#ifndef NOPASSWDAUTH
|
1998-04-16 00:26:21 +00:00
|
|
|
if (Enabled(bundle, OPT_PASSWDAUTH))
|
1999-01-28 01:56:34 +00:00
|
|
|
return auth_CheckPasswd(name, "*", key);
|
1998-03-09 19:25:35 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return 0; /* Invalid */
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
1999-01-28 01:56:34 +00:00
|
|
|
auth_GetSecret(struct bundle *bundle, const char *name, int len,
|
1998-04-24 19:16:15 +00:00
|
|
|
struct physical *physical)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-03-09 19:25:35 +00:00
|
|
|
/* Used by CHAP routines */
|
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
FILE *fp;
|
1999-12-20 20:30:02 +00:00
|
|
|
int n, lineno;
|
1998-01-05 01:35:20 +00:00
|
|
|
char *vector[5];
|
2002-01-08 11:24:39 +00:00
|
|
|
const char *slash;
|
1999-06-08 20:11:53 +00:00
|
|
|
static char buff[LINE_LEN]; /* vector[] will point here when returned */
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1998-04-24 19:16:15 +00:00
|
|
|
fp = OpenSecret(SECRETFILE);
|
1995-01-31 06:29:58 +00:00
|
|
|
if (fp == NULL)
|
1997-08-25 00:29:32 +00:00
|
|
|
return (NULL);
|
1998-03-09 19:25:35 +00:00
|
|
|
|
2002-01-08 11:24:39 +00:00
|
|
|
again:
|
1999-12-20 20:30:02 +00:00
|
|
|
lineno = 0;
|
1997-12-24 09:29:17 +00:00
|
|
|
while (fgets(buff, sizeof buff, fp)) {
|
1999-12-20 20:30:02 +00:00
|
|
|
lineno++;
|
1995-01-31 06:29:58 +00:00
|
|
|
if (buff[0] == '#')
|
|
|
|
continue;
|
1999-06-08 20:11:53 +00:00
|
|
|
n = strlen(buff) - 1;
|
|
|
|
if (buff[n] == '\n')
|
|
|
|
buff[n] = '\0'; /* Trim the '\n' */
|
1997-12-24 09:29:17 +00:00
|
|
|
memset(vector, '\0', sizeof vector);
|
1999-12-27 11:43:31 +00:00
|
|
|
if ((n = MakeArgs(buff, vector, VECSIZE(vector), PARSE_REDUCE)) < 0)
|
1999-12-20 20:30:02 +00:00
|
|
|
log_Printf(LogWARN, "%s: %d: Invalid line\n", SECRETFILE, lineno);
|
1995-01-31 06:29:58 +00:00
|
|
|
if (n < 2)
|
|
|
|
continue;
|
1999-01-28 01:56:34 +00:00
|
|
|
if (strlen(vector[0]) == len && strncmp(vector[0], name, len) == 0) {
|
1998-04-24 19:16:15 +00:00
|
|
|
CloseSecret(fp);
|
1998-03-09 19:25:35 +00:00
|
|
|
return vector[1];
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
}
|
2002-01-08 11:24:39 +00:00
|
|
|
|
|
|
|
if ((slash = strrchr(name, '\\')) != NULL && slash[1]) {
|
|
|
|
/* Go back and look for the name without the leading domain */
|
|
|
|
len -= slash - name + 1;
|
|
|
|
name = slash + 1;
|
|
|
|
rewind(fp);
|
|
|
|
goto again;
|
|
|
|
}
|
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
CloseSecret(fp);
|
1997-08-25 00:29:32 +00:00
|
|
|
return (NULL); /* Invalid */
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
1995-02-26 12:18:08 +00:00
|
|
|
|
|
|
|
static void
|
1997-11-22 03:37:54 +00:00
|
|
|
AuthTimeout(void *vauthp)
|
1995-02-26 12:18:08 +00:00
|
|
|
{
|
1997-11-22 03:37:54 +00:00
|
|
|
struct authinfo *authp = (struct authinfo *)vauthp;
|
1995-02-26 12:18:08 +00:00
|
|
|
|
1998-05-01 19:26:12 +00:00
|
|
|
timer_Stop(&authp->authtimer);
|
1995-02-26 12:18:08 +00:00
|
|
|
if (--authp->retry > 0) {
|
1999-02-06 02:54:47 +00:00
|
|
|
authp->id++;
|
|
|
|
(*authp->fn.req)(authp);
|
1998-05-01 19:26:12 +00:00
|
|
|
timer_Start(&authp->authtimer);
|
1999-02-02 09:35:17 +00:00
|
|
|
} else {
|
|
|
|
log_Printf(LogPHASE, "Auth: No response from server\n");
|
|
|
|
datalink_AuthNotOk(authp->physical->dl);
|
|
|
|
}
|
1995-02-26 12:18:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-02-06 02:54:47 +00:00
|
|
|
auth_Init(struct authinfo *authp, struct physical *p, auth_func req,
|
|
|
|
auth_func success, auth_func failure)
|
1998-01-29 00:44:16 +00:00
|
|
|
{
|
1999-02-06 02:54:47 +00:00
|
|
|
memset(authp, '\0', sizeof(struct authinfo));
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
authp->cfg.fsm.timeout = DEF_FSMRETRY;
|
|
|
|
authp->cfg.fsm.maxreq = DEF_FSMAUTHTRIES;
|
|
|
|
authp->cfg.fsm.maxtrm = 0; /* not used */
|
1999-02-06 02:54:47 +00:00
|
|
|
authp->fn.req = req;
|
|
|
|
authp->fn.success = success;
|
|
|
|
authp->fn.failure = failure;
|
|
|
|
authp->physical = p;
|
1998-03-01 01:07:49 +00:00
|
|
|
}
|
1998-01-29 00:49:32 +00:00
|
|
|
|
1998-03-01 01:07:49 +00:00
|
|
|
void
|
1999-02-06 02:54:47 +00:00
|
|
|
auth_StartReq(struct authinfo *authp)
|
1995-02-26 12:18:08 +00:00
|
|
|
{
|
1998-05-01 19:26:12 +00:00
|
|
|
timer_Stop(&authp->authtimer);
|
1998-03-01 01:07:49 +00:00
|
|
|
authp->authtimer.func = AuthTimeout;
|
1998-04-03 19:21:56 +00:00
|
|
|
authp->authtimer.name = "auth";
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
authp->authtimer.load = authp->cfg.fsm.timeout * SECTICKS;
|
1999-02-06 02:54:47 +00:00
|
|
|
authp->authtimer.arg = (void *)authp;
|
Allow control over the number of ConfigREQ & TermREQ attempts
that are made in each of the FSMs (LCP, CCP & IPCP) and the
number of REQs/Challenges for PAP/CHAP by accepting more arguments
in the ``set {c,ip,l}cpretry'' and ``set {ch,p}apretry'' commands.
Change the non-convergence thresholds to 3 times the number of configured
REQ tries (rather than the previous fixed ``10''). We now notice
repeated NAKs and REJs rather than just REQs.
Don't suggest that CHAP 0x05 isn't supported when it's not configured.
Fix some bugs that expose themselves with smaller numbers of retries:
o Handle instantaneous disconnects (set device /dev/null) correctly
by stopping all fsm timers in fsm2initial.
o Don't forget to uu_unlock() devices that are files but are not
ttys (set device /dev/zero).
Fix a *HORRENDOUS* bug in RFC1661 (already fixed for an Open event in state
``Closed''):
According to the state transition table, a RCR+ or RCR- received in
the ``Stopped'' state are supposed to InitRestartCounter, SendConfigReq
and SendConfig{Ack,Nak}. However, in ``Stopped'', we haven't yet
done a TLS (or the last thing we did is a TLF). We must therefore
do the TLS at this point !
This was never noticed before because LCP and CCP used not use
LayerStart() for anything interesting, and IPCP tends to go into
Stopped then get a Down because of an LCP RTR rather than getting a
RCR again.
1999-02-26 21:28:14 +00:00
|
|
|
authp->retry = authp->cfg.fsm.maxreq;
|
1995-02-26 12:18:08 +00:00
|
|
|
authp->id = 1;
|
1999-02-06 02:54:47 +00:00
|
|
|
(*authp->fn.req)(authp);
|
1998-05-01 19:26:12 +00:00
|
|
|
timer_Start(&authp->authtimer);
|
1995-02-26 12:18:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1998-05-01 19:26:12 +00:00
|
|
|
auth_StopTimer(struct authinfo *authp)
|
1995-02-26 12:18:08 +00:00
|
|
|
{
|
1998-05-01 19:26:12 +00:00
|
|
|
timer_Stop(&authp->authtimer);
|
1999-02-06 02:54:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct mbuf *
|
|
|
|
auth_ReadHeader(struct authinfo *authp, struct mbuf *bp)
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
|
1999-12-20 20:29:47 +00:00
|
|
|
len = m_length(bp);
|
1999-02-06 02:54:47 +00:00
|
|
|
if (len >= sizeof authp->in.hdr) {
|
|
|
|
bp = mbuf_Read(bp, (u_char *)&authp->in.hdr, sizeof authp->in.hdr);
|
|
|
|
if (len >= ntohs(authp->in.hdr.length))
|
|
|
|
return bp;
|
1999-02-20 01:12:45 +00:00
|
|
|
authp->in.hdr.length = htons(0);
|
1999-02-19 10:48:42 +00:00
|
|
|
log_Printf(LogWARN, "auth_ReadHeader: Short packet (%d > %d) !\n",
|
|
|
|
ntohs(authp->in.hdr.length), len);
|
1999-02-20 01:12:45 +00:00
|
|
|
} else {
|
|
|
|
authp->in.hdr.length = htons(0);
|
1999-02-19 10:48:42 +00:00
|
|
|
log_Printf(LogWARN, "auth_ReadHeader: Short packet header (%d > %d) !\n",
|
1999-03-31 14:21:46 +00:00
|
|
|
(int)(sizeof authp->in.hdr), len);
|
1999-02-20 01:12:45 +00:00
|
|
|
}
|
1999-02-06 02:54:47 +00:00
|
|
|
|
1999-12-20 20:29:47 +00:00
|
|
|
m_freem(bp);
|
1999-02-06 02:54:47 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct mbuf *
|
|
|
|
auth_ReadName(struct authinfo *authp, struct mbuf *bp, int len)
|
|
|
|
{
|
|
|
|
if (len > sizeof authp->in.name - 1)
|
1999-02-19 10:48:42 +00:00
|
|
|
log_Printf(LogWARN, "auth_ReadName: Name too long (%d) !\n", len);
|
1999-02-06 02:54:47 +00:00
|
|
|
else {
|
1999-12-20 20:29:47 +00:00
|
|
|
int mlen = m_length(bp);
|
1999-02-06 02:54:47 +00:00
|
|
|
|
|
|
|
if (len > mlen)
|
1999-02-19 10:48:42 +00:00
|
|
|
log_Printf(LogWARN, "auth_ReadName: Short packet (%d > %d) !\n",
|
|
|
|
len, mlen);
|
1999-02-06 02:54:47 +00:00
|
|
|
else {
|
|
|
|
bp = mbuf_Read(bp, (u_char *)authp->in.name, len);
|
|
|
|
authp->in.name[len] = '\0';
|
|
|
|
return bp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*authp->in.name = '\0';
|
1999-12-20 20:29:47 +00:00
|
|
|
m_freem(bp);
|
1999-02-06 02:54:47 +00:00
|
|
|
return NULL;
|
1995-02-26 12:18:08 +00:00
|
|
|
}
|