Merged from DEVEL.

This commit is contained in:
marcbou
2003-06-27 20:46:11 +00:00
parent 45756246b9
commit 351e590e01
13 changed files with 131 additions and 94 deletions

View File

@@ -122,7 +122,7 @@ static int get_pap_passwd (int, char *, char *);
static int have_pap_secret (void);
static int have_chap_secret (char *, char *, u32_t);
static int ip_addr_check (u32_t, struct wordlist *);
#if PAP_SUPPORT > 0 || CHAP_SUPPORT > 0
#if 0 /* PAP_SUPPORT > 0 || CHAP_SUPPORT > 0 */
static void set_allowed_addrs(int unit, struct wordlist *addrs);
static void free_wordlist (struct wordlist *);
#endif
@@ -476,7 +476,7 @@ void auth_reset(int unit)
AUTHDEBUG((LOG_INFO, "auth_reset: %d\n", unit));
ao->neg_upap = !ppp_settings.refuse_pap && (ppp_settings.passwd[0] != 0 || get_pap_passwd(unit, NULL, NULL));
ao->neg_chap = !ppp_settings.refuse_chap && have_chap_secret(ppp_settings.user, ppp_settings.remote_name, (u32_t)0);
ao->neg_chap = !ppp_settings.refuse_chap && ppp_settings.passwd[0] != 0 /*have_chap_secret(ppp_settings.user, ppp_settings.remote_name, (u32_t)0)*/;
if (go->neg_upap && !have_pap_secret())
go->neg_upap = 0;
@@ -605,7 +605,24 @@ int get_secret(
)
{
#if 1
int len;
struct wordlist *addrs;
addrs = NULL;
if(!client || !client[0] && strcmp(client, ppp_settings.user)) {
return 0;
}
len = strlen(ppp_settings.passwd);
if (len > MAXSECRETLEN) {
ppp_trace(LOG_ERR, "Secret for %s on %s is too long\n", client, server);
len = MAXSECRETLEN;
}
BCOPY(ppp_settings.passwd, secret, len);
*secret_len = len;
return 1;
#else
int ret = 0, len;
struct wordlist *addrs;
@@ -841,7 +858,7 @@ static int have_chap_secret(char *client, char *server, u32_t remote)
}
#if PAP_SUPPORT > 0 || CHAP_SUPPORT > 0
#if 0 /* PAP_SUPPORT > 0 || CHAP_SUPPORT > 0 */
/*
* set_allowed_addrs() - set the list of allowed addresses.
*/
@@ -891,7 +908,7 @@ static int ip_addr_check(u32_t addr, struct wordlist *addrs)
return 1;
}
#if PAP_SUPPORT > 0 || CHAP_SUPPORT
#if 0 /* PAP_SUPPORT > 0 || CHAP_SUPPORT */
/*
* free_wordlist - release memory allocated for a wordlist.
*/

View File

@@ -290,7 +290,7 @@ void pppInit(void)
memset(&ppp_settings, 0, sizeof(ppp_settings));
ppp_settings.usepeerdns = 1;
ppp_settings.refuse_chap = (CHAP_SUPPORT == 0);
pppSetAuth(PPPAUTHTYPE_NONE, NULL, NULL);
magicInit();
@@ -313,19 +313,40 @@ void pppInit(void)
#endif
}
void pppSetAuth(const char *user, const char *passwd)
void pppSetAuth(enum pppAuthType authType, const char *user, const char *passwd)
{
if(user) {
strncpy(ppp_settings.user, user, sizeof(ppp_settings.user)-1);
ppp_settings.user[sizeof(ppp_settings.user)-1] = '\0';
} else
ppp_settings.user[0] = '\0';
switch(authType) {
case PPPAUTHTYPE_NONE:
default:
#ifdef LWIP_PPP_STRICT_PAP_REJECT
ppp_settings.refuse_pap = 1;
#else
/* some providers request pap and accept an empty login/pw */
ppp_settings.refuse_pap = 0;
#endif
ppp_settings.refuse_chap = 1;
break;
case PPPAUTHTYPE_PAP:
ppp_settings.refuse_pap = 0;
ppp_settings.refuse_chap = 1;
break;
case PPPAUTHTYPE_CHAP:
ppp_settings.refuse_pap = 1;
ppp_settings.refuse_chap = 0;
break;
}
if(passwd) {
strncpy(ppp_settings.passwd, passwd, sizeof(ppp_settings.passwd)-1);
ppp_settings.passwd[sizeof(ppp_settings.passwd)-1] = '\0';
} else
ppp_settings.passwd[0] = '\0';
if(user) {
strncpy(ppp_settings.user, user, sizeof(ppp_settings.user)-1);
ppp_settings.user[sizeof(ppp_settings.user)-1] = '\0';
} else
ppp_settings.user[0] = '\0';
if(passwd) {
strncpy(ppp_settings.passwd, passwd, sizeof(ppp_settings.passwd)-1);
ppp_settings.passwd[sizeof(ppp_settings.passwd)-1] = '\0';
} else
ppp_settings.passwd[0] = '\0';
}
/* Open a new PPP connection using the given I/O device.

View File

@@ -313,7 +313,7 @@ struct ppp_settings {
int maxconnect; /* Maximum connect time (seconds) */
char user[MAXNAMELEN + 1];/* Username for PAP */
char passwd[MAXNAMELEN + 1]; /* Password for PAP */
char passwd[MAXSECRETLEN + 1]; /* Password for PAP, secret for CHAP */
char our_name[MAXNAMELEN + 1]; /* Our name for authentication purposes */
char remote_name[MAXNAMELEN + 1]; /* Peer's name for authentication */
};
@@ -340,7 +340,13 @@ extern struct protent *ppp_protocols[];/* Table of pointers to supported protoco
/* Initialize the PPP subsystem. */
void pppInit(void);
void pppSetAuth(const char *user, const char *passwd);
enum pppAuthType {
PPPAUTHTYPE_NONE,
PPPAUTHTYPE_PAP,
PPPAUTHTYPE_CHAP
};
void pppSetAuth(enum pppAuthType authType, const char *user, const char *passwd);
/*
* Open a new PPP connection using the given I/O device.