X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=pppd%2Fchap-new.c;h=10e4507386e277fbdb6413e46bdd80f61a0b783f;hb=c3120199a30977a4da12fd031c1df4a95dec417a;hp=2e74fb86151ce99460c1ce7ca12b9b6e44075e87;hpb=a72f809b1dfe0857290a85b2af52279a05fe2f94;p=ppp.git diff --git a/pppd/chap-new.c b/pppd/chap-new.c index 2e74fb8..10e4507 100644 --- a/pppd/chap-new.c +++ b/pppd/chap-new.c @@ -59,6 +59,7 @@ int chap_server_timeout_time = 3; int chap_max_transmits = 10; int chap_rechallenge_time = 0; int chap_client_timeout_time = 60; +int chapms_strip_domain = 0; /* * Command-line options. @@ -72,6 +73,8 @@ static option_t chap_option_list[] = { "Set interval for rechallenge", OPT_PRIO }, { "chap-timeout", o_int, &chap_client_timeout_time, "Set timeout for CHAP (as client)", OPT_PRIO }, + { "chapms-strip-domain", o_bool, &chapms_strip_domain, + "Strip the domain prefix before the Username", 1 }, { NULL } }; @@ -133,7 +136,7 @@ static void chap_handle_status(struct chap_client_state *cs, int code, int id, static void chap_protrej(int unit); static void chap_input(int unit, unsigned char *pkt, int pktlen); static int chap_print_pkt(unsigned char *p, int plen, - void (*printer) __P((void *, char *, ...)), void *arg); + void (*printer)(void *, char *, ...), void *arg); /* List of digest types that we know about */ static struct chap_digest_type *chap_digests; @@ -163,6 +166,18 @@ chap_register_digest(struct chap_digest_type *dp) chap_digests = dp; } +/* + * Lookup a digest type by code + */ +struct chap_digest_type * +chap_find_digest(int digest_code) { + struct chap_digest_type *dp = NULL; + for (dp = chap_digests; dp != NULL; dp = dp->next) + if (dp->code == digest_code) + break; + return dp; +} + /* * chap_lowerup - we can start doing stuff now. */ @@ -207,9 +222,8 @@ chap_auth_peer(int unit, char *our_name, int digest_code) error("CHAP: peer authentication already started!"); return; } - for (dp = chap_digests; dp != NULL; dp = dp->next) - if (dp->code == digest_code) - break; + + dp = chap_find_digest(digest_code); if (dp == NULL) fatal("CHAP digest 0x%x requested but not available", digest_code); @@ -355,6 +369,14 @@ chap_handle_response(struct chap_server_state *ss, int id, /* Null terminate and clean remote name. */ slprintf(rname, sizeof(rname), "%.*v", len, name); name = rname; + + /* strip the MS domain name */ + if (chapms_strip_domain && strrchr(rname, '\\')) { + char tmp[MAXNAMELEN+1]; + + strcpy(tmp, strrchr(rname, '\\') + 1); + strcpy(rname, tmp); + } } if (chap_verify_hook) @@ -606,7 +628,7 @@ static char *chap_code_names[] = { static int chap_print_pkt(unsigned char *p, int plen, - void (*printer) __P((void *, char *, ...)), void *arg) + void (*printer)(void *, char *, ...), void *arg) { int code, id, len; int clen, nlen;