don't duplicate user and password anymore, anyway, the PPP user will have them already allocated as static strings or from configuration flash/file

This commit is contained in:
Sylvain Rochet 2012-06-19 21:26:52 +02:00
parent 8e9c07df39
commit 2aa9a66c57
6 changed files with 21 additions and 17 deletions

View File

@ -1465,7 +1465,7 @@ void auth_reset(ppp_pcb *pcb) {
lcp_options *go = &pcb->lcp_gotoptions;
lcp_options *ao = &pcb->lcp_allowoptions;
if( pcb->settings.passwd[0] ) {
if(pcb->settings.passwd) {
#if PAP_SUPPORT
ao->neg_upap = !pcb->settings.refuse_pap;
@ -1932,7 +1932,7 @@ int get_secret(ppp_pcb *pcb, char *client, char *server, char *secret, int *secr
LWIP_UNUSED_ARG(server);
LWIP_UNUSED_ARG(am_server);
if(!client || !client[0] || strcmp(client, pcb->settings.user)) {
if(!client || !client[0] || !pcb->settings.user || !pcb->settings.passwd || strcmp(client, pcb->settings.user)) {
return 0;
}

View File

@ -205,6 +205,9 @@ void chap_auth_peer(ppp_pcb *pcb, char *our_name, int digest_code) {
void chap_auth_with_peer(ppp_pcb *pcb, char *our_name, int digest_code) {
struct chap_digest_type *dp;
if(NULL == our_name)
return;
if (pcb->chap_client.flags & AUTH_STARTED) {
error("CHAP: authentication with peer already started!");
return;
@ -221,7 +224,7 @@ void chap_auth_with_peer(ppp_pcb *pcb, char *our_name, int digest_code) {
pcb->chap_client.flags |= AUTH_STARTED;
}
# if PPP_SERVER
#if PPP_SERVER
/*
* chap_timeout - It's time to send another challenge to the peer.
* This could be either a retransmission of a previous challenge,

View File

@ -235,6 +235,9 @@ static void eap_client_timeout(void *arg) {
*/
void eap_authwithpeer(ppp_pcb *pcb, char *localname) {
if(NULL == localname)
return;
/* Save the peer name we're given */
pcb->eap.es_client.ea_name = localname;
pcb->eap.es_client.ea_namelen = strlen(localname);

View File

@ -261,7 +261,7 @@ ppp_pcb *ppp_new(u8_t num) {
return pcb;
}
void ppp_set_auth(ppp_pcb *pcb, u8_t authtype, const char *user, const char *passwd) {
void ppp_set_auth(ppp_pcb *pcb, u8_t authtype, char *user, char *passwd) {
#if PAP_SUPPORT
if(authtype & PPPAUTHTYPE_PAP)
@ -293,17 +293,11 @@ void ppp_set_auth(ppp_pcb *pcb, u8_t authtype, const char *user, const char *pas
pcb->settings.refuse_eap = 1;
#endif /* EAP_SUPPORT */
if(user) {
strncpy(pcb->settings.user, user, sizeof(pcb->settings.user)-1);
pcb->settings.user[sizeof(pcb->settings.user)-1] = '\0';
} else
pcb->settings.user[0] = '\0';
if(user)
pcb->settings.user = user;
if(passwd) {
strncpy(pcb->settings.passwd, passwd, sizeof(pcb->settings.passwd)-1);
pcb->settings.passwd[sizeof(pcb->settings.passwd)-1] = '\0';
} else
pcb->settings.passwd[0] = '\0';
if(passwd)
pcb->settings.passwd = passwd;
}
#if PPPOS_SUPPORT

View File

@ -193,8 +193,8 @@ typedef struct ppp_settings_s {
#endif /* PPP_MAXCONNECT */
/* auth data */
char user [MAXNAMELEN + 1]; /* Username for PAP */
char passwd [MAXSECRETLEN + 1]; /* Password for PAP, secret for CHAP */
char *user; /* Username for PAP */
char *passwd; /* Password for PAP, secret for CHAP */
#if PPP_SERVER
char our_name [MAXNAMELEN + 1]; /* Our name for authentication purposes */
#endif /* PPP_SERVER */
@ -390,7 +390,7 @@ ppp_pcb *ppp_new(u8_t num);
#define PPPAUTHTYPE_EAP 0x08
#define PPPAUTHTYPE_ANY 0xff
void ppp_set_auth(ppp_pcb *pcb, u8_t authtype, const char *user, const char *passwd);
void ppp_set_auth(ppp_pcb *pcb, u8_t authtype, char *user, char *passwd);
/* Link status callback function prototype */
typedef void (*ppp_link_status_cb_fn)(void *ctx, int errcode, void *arg);

View File

@ -157,6 +157,10 @@ static void upap_init(ppp_pcb *pcb) {
* Set new state and send authenticate's.
*/
void upap_authwithpeer(ppp_pcb *pcb, char *user, char *password) {
if(!user || !password)
return;
/* Save the username and password we're given */
pcb->upap.us_user = user;
pcb->upap.us_userlen = strlen(user);