1995-01-31 06:29:58 +00:00
|
|
|
/*
|
|
|
|
* PPP Secret Key Module
|
|
|
|
*
|
|
|
|
* Written by Toshiharu OHNO (tony-o@iij.ad.jp)
|
|
|
|
*
|
|
|
|
* Copyright (C) 1994, Internet Initiative Japan, Inc. All rights reserverd.
|
|
|
|
*
|
|
|
|
* 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 Internet Initiative Japan, Inc. The name of the
|
|
|
|
* IIJ 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.
|
1995-05-30 03:57:47 +00:00
|
|
|
*
|
1999-06-08 20:11:53 +00:00
|
|
|
* $Id: auth.c,v 1.44 1999/05/08 11:06:06 brian Exp $
|
1995-05-30 03:57:47 +00:00
|
|
|
*
|
1995-01-31 06:29:58 +00:00
|
|
|
* TODO:
|
1995-09-02 17:20:54 +00:00
|
|
|
* o Implement check against with registered IP addresses.
|
1995-01-31 06:29:58 +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-05-21 21:49:08 +00:00
|
|
|
#include <netinet/in_systm.h>
|
|
|
|
#include <netinet/ip.h>
|
|
|
|
#include <sys/un.h>
|
1997-10-26 01:04:02 +00:00
|
|
|
|
1998-05-21 21:49:08 +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-05-21 21:49:08 +00:00
|
|
|
#include "iplist.h"
|
|
|
|
#include "throughput.h"
|
|
|
|
#include "slcompress.h"
|
1998-08-26 17:39:37 +00:00
|
|
|
#include "lqr.h"
|
|
|
|
#include "hdlc.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-05-21 21:49:08 +00:00
|
|
|
#include "lcp.h"
|
|
|
|
#include "ccp.h"
|
|
|
|
#include "link.h"
|
|
|
|
#include "descriptor.h"
|
|
|
|
#include "chat.h"
|
1999-05-08 11:07:56 +00:00
|
|
|
#include "proto.h"
|
1998-05-21 21:49:08 +00:00
|
|
|
#include "filter.h"
|
|
|
|
#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"
|
1998-05-21 21:49:08 +00:00
|
|
|
#include "bundle.h"
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1998-05-21 21:49: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-05-21 21:49: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-05-21 21:49:08 +00:00
|
|
|
case 0:
|
|
|
|
return "none";
|
|
|
|
}
|
|
|
|
return "unknown";
|
1995-02-26 12:18:08 +00:00
|
|
|
}
|
|
|
|
|
1998-05-21 21:49:08 +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);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1998-08-07 18:42:51 +00:00
|
|
|
auth_SetPhoneList(const char *name, char *phone, int phonelen)
|
|
|
|
{
|
|
|
|
FILE *fp;
|
|
|
|
int n;
|
|
|
|
char *vector[6];
|
|
|
|
char buff[LINE_LEN];
|
|
|
|
|
|
|
|
fp = OpenSecret(SECRETFILE);
|
|
|
|
if (fp != NULL) {
|
|
|
|
while (fgets(buff, sizeof buff, fp)) {
|
|
|
|
if (buff[0] == '#')
|
|
|
|
continue;
|
|
|
|
buff[strlen(buff) - 1] = '\0';
|
|
|
|
memset(vector, '\0', sizeof vector);
|
|
|
|
n = MakeArgs(buff, vector, VECSIZE(vector));
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
int n;
|
1998-05-21 21:49:08 +00:00
|
|
|
char *vector[5];
|
1997-11-09 14:18:55 +00:00
|
|
|
char buff[LINE_LEN];
|
1995-02-26 12:18:08 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
if (*name == '\0') {
|
1999-01-28 01:56:34 +00:00
|
|
|
ipcp_Setup(&bundle->ncp.ipcp, INADDR_NONE);
|
1998-05-21 21:49:08 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
1999-01-28 01:56:34 +00:00
|
|
|
#ifndef NORADIUS
|
|
|
|
if (bundle->radius.valid && bundle->radius.ip.s_addr != INADDR_NONE) {
|
|
|
|
/* 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-05-21 21:49:08 +00:00
|
|
|
fp = OpenSecret(SECRETFILE);
|
|
|
|
if (fp != NULL) {
|
|
|
|
while (fgets(buff, sizeof buff, fp)) {
|
|
|
|
if (buff[0] == '#')
|
|
|
|
continue;
|
1998-07-19 21:07:24 +00:00
|
|
|
buff[strlen(buff) - 1] = '\0';
|
1998-05-21 21:49:08 +00:00
|
|
|
memset(vector, '\0', sizeof vector);
|
|
|
|
n = MakeArgs(buff, vector, VECSIZE(vector));
|
|
|
|
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
|
|
|
}
|
1998-05-21 21:49:08 +00:00
|
|
|
CloseSecret(fp);
|
1995-02-26 12:18:08 +00:00
|
|
|
}
|
1998-05-21 21:49:08 +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-05-21 21:49:08 +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-05-21 21:49:08 +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-05-21 21:49:08 +00:00
|
|
|
const char *key, struct physical *physical)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-05-21 21:49:08 +00:00
|
|
|
/* Used by PAP routines */
|
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
FILE *fp;
|
|
|
|
int n;
|
1998-01-05 01:35:20 +00:00
|
|
|
char *vector[5];
|
1997-11-09 14:18:55 +00:00
|
|
|
char buff[LINE_LEN];
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1998-05-21 21:49:08 +00:00
|
|
|
fp = OpenSecret(SECRETFILE);
|
|
|
|
if (fp != NULL) {
|
|
|
|
while (fgets(buff, sizeof buff, fp)) {
|
|
|
|
if (buff[0] == '#')
|
|
|
|
continue;
|
|
|
|
buff[strlen(buff) - 1] = 0;
|
|
|
|
memset(vector, '\0', sizeof vector);
|
|
|
|
n = MakeArgs(buff, vector, VECSIZE(vector));
|
|
|
|
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-05-21 21:49:08 +00:00
|
|
|
CloseSecret(fp);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
1998-05-21 21:49:08 +00:00
|
|
|
|
|
|
|
#ifndef NOPASSWDAUTH
|
|
|
|
if (Enabled(bundle, OPT_PASSWDAUTH))
|
1999-01-28 01:56:34 +00:00
|
|
|
return auth_CheckPasswd(name, "*", key);
|
1998-05-21 21:49:08 +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-05-21 21:49:08 +00:00
|
|
|
struct physical *physical)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-05-21 21:49:08 +00:00
|
|
|
/* Used by CHAP routines */
|
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
FILE *fp;
|
|
|
|
int n;
|
1998-01-05 01:35:20 +00:00
|
|
|
char *vector[5];
|
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-05-21 21:49:08 +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-05-21 21:49:08 +00:00
|
|
|
|
1997-12-24 09:29:17 +00:00
|
|
|
while (fgets(buff, sizeof buff, fp)) {
|
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);
|
1997-05-07 23:01:25 +00:00
|
|
|
n = MakeArgs(buff, vector, VECSIZE(vector));
|
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-05-21 21:49:08 +00:00
|
|
|
CloseSecret(fp);
|
|
|
|
return vector[1];
|
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-21 21:49:08 +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-21 21:49:08 +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-05-21 21:49:08 +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-05-21 21:49:08 +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-21 21:49:08 +00:00
|
|
|
timer_Stop(&authp->authtimer);
|
|
|
|
authp->authtimer.func = AuthTimeout;
|
|
|
|
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-21 21:49:08 +00:00
|
|
|
timer_Start(&authp->authtimer);
|
1995-02-26 12:18:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1998-05-21 21:49:08 +00:00
|
|
|
auth_StopTimer(struct authinfo *authp)
|
1995-02-26 12:18:08 +00:00
|
|
|
{
|
1998-05-21 21:49:08 +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;
|
|
|
|
|
|
|
|
len = mbuf_Length(bp);
|
|
|
|
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
|
|
|
|
|
|
|
mbuf_Free(bp);
|
|
|
|
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 {
|
|
|
|
int mlen = mbuf_Length(bp);
|
|
|
|
|
|
|
|
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';
|
|
|
|
mbuf_Free(bp);
|
|
|
|
return NULL;
|
1995-02-26 12:18:08 +00:00
|
|
|
}
|