diff -urN auth.c.old auth.c --- auth.c.old Wed May 5 08:45:14 1999 +++ auth.c Fri Jun 11 13:28:13 1999 @@ -205,9 +205,19 @@ /* * Check encrypted password. */ +#ifdef NOUSERCASE + encpw = crypt(passwd, encrypted_pass); + if (strcmp(encpw, encrypted_pass)) { + encpw = crypt(makecleanstr(passwd), encrypted_pass); + if (strcmp(encpw, encrypted_pass)) { + return -1; + } + } +#else encpw = crypt(passwd, encrypted_pass); if (strcmp(encpw, encrypted_pass)) return -1; +#endif return 0; } @@ -379,9 +389,18 @@ result = string[0] ? -1 : 0; break; } +#ifdef NOUSERCASE if (strcmp(password_pair->strvalue, - crypt(string, password_pair->strvalue)) != 0) + crypt(string, password_pair->strvalue)) != 0) + if (strcmp(password_pair->strvalue, + crypt(makecleanstr(string), password_pair->strvalue)) != 0) { result = -1; + } +#else + if (strcmp(password_pair->strvalue, + crypt(string, password_pair->strvalue)) != 0) + result = -1; +#endif break; case PW_AUTHTYPE_LOCAL: DEBUG2(" auth: Local"); @@ -392,9 +411,17 @@ /* * Plain text password. */ +#ifdef NOUSERCASE + if (password_pair == NULL || + strcmp(password_pair->strvalue, string)!=0) + if(password_pair == NULL || + strcmp(password_pair->strvalue, makecleanstr(string))!=0) + result = -1; +#else if (password_pair == NULL || - strcmp(password_pair->strvalue, string)!=0) + strcmp(password_pair->strvalue, string)!=0) result = -1; +#endif break; } diff -urN cache.c.old cache.c --- cache.c.old Wed May 5 08:35:56 1999 +++ cache.c Fri Jun 11 13:29:10 1999 @@ -436,9 +436,19 @@ /* * Check encrypted password. */ +#ifdef NOUSERCASE + encpw = crypt(passwd, encrypted_pass); + if (strcmp(encpw, encrypted_pass)) { + encpw = crypt(makecleanstr(passwd), encrypted_pass); + if (strcmp(encpw, encrypted_pass)) { + return -1; + } + } +#else encpw = (char *)crypt(passwd, encrypted_pass); if (strcmp(encpw, encrypted_pass)) return -1; +#endif return 0; } diff -urN radiusd-cistron-1.5.4.3-orig/src/radiusd.c radiusd-cistron-1.5.4.3/src/radiusd.c --- radiusd.c.old Wed May 5 08:44:45 1999 +++ radiusd.c Fri Jun 11 13:32:16 1999 @@ -514,6 +514,13 @@ namepair = pairfind(authreq->request, PW_USER_NAME); if (namepair == NULL) break; +#ifdef NOUSERCASE + /* We only do this on auth requests */ + if(authreq->code == PW_AUTHENTICATION_REQUEST) { + makecleanstr(authreq->username); + makecleanstr(namepair->strvalue); + } +#endif /* * We always call proxy_send, it returns non-zero * if it did actually proxy the request. @@ -867,3 +874,35 @@ need_reload = 1; } +#ifdef NOUSERCASE +/* Take a string, strip all spaces from it, + * lowercase all upper letters, and return it + */ +char* makecleanstr(char *str) { + char *ptr; + int index=0; + unsigned char mychar; + + DEBUG2(" makecleanstr received: %s (%ld)", str, str) ; + /* If null, return immediately */ + if(!str) + return str; + + for(ptr = str; *ptr!='\0'; ptr++) { + while(*ptr == ' ') { + ptr++; + } + mychar = *ptr; + if((mychar > 64) && (mychar < 91)) { + mychar += 32; + *ptr = mychar; + } + str[index] = *ptr; + index++; + } + str[index] = '\0'; + + DEBUG2(" makecleanstr returning: %s (%ld)", str, str); + return str; +} +#endif diff -urN radiusd-cistron-1.5.4.3-orig/src/radiusd.h radiusd-cistron-1.5.4.3/src/radiusd.h --- radiusd.h.old Wed May 5 08:45:01 1999 +++ radiusd.h Fri Jun 11 13:32:23 1999 @@ -276,3 +276,7 @@ /* timestr.c */ int timestr_match(char *, time_t); +/* nocase.c */ +#ifdef NOUSERCASE +char* makecleanstr(char *str); +#endif