--- crypt_md5.h.orig 2006-06-19 00:37:11.000000000 -0300 +++ crypt_md5.h 2006-06-19 00:37:11.000000000 -0300 @@ -13,3 +13,6 @@ * salt[0] = '\0'; */ char *crypt_md5(const char *pw, const char *salt); + +/* MD5 hash without salt */ +char *md5sum(const char *s); --- crypt_md5.c.orig 2006-06-19 00:37:11.000000000 -0300 +++ crypt_md5.c 2006-06-19 00:37:11.000000000 -0300 @@ -16,6 +16,7 @@ */ #include +#include #include "config.h" #include "md5.h" @@ -166,3 +167,30 @@ char *crypt_md5(const char *pw, const ch return passwd; } + +/* Created by Ramon de Carvalho + Refined by Rodrigo Rubira Branco +*/ +char *md5sum(const char *s){ + static unsigned char digest[16]; + MD5_CTX ctx; + int idx; + static char sum[33]; + + memset(digest,0,16); + + MD5Init(&ctx); + MD5Update(&ctx,(const unsigned char *)s,strlen(s)); + MD5Final(digest,&ctx); + + for(idx=0;idx<16;idx++) + sprintf(&sum[idx*2],"%02x",digest[idx]); + + sum[33]='\0'; + + /* Don't leave anything around in vm they could use. */ + memset(digest, 0, sizeof digest); + + return sum; +} + --- ncsa_auth.c.orig 2006-06-19 00:37:11.000000000 -0300 +++ ncsa_auth.c 2006-06-19 00:37:11.000000000 -0300 @@ -81,6 +81,10 @@ read_passwd_file(const char *passwdfile) exit(1); } f = fopen(passwdfile, "r"); + if (NULL == f) { + fprintf(stderr, "%s: %s\n", passwdfile, xstrerror()); + exit(1); + } while (fgets(buf, 8192, f) != NULL) { if ((buf[0] == '#') || (buf[0] == ' ') || (buf[0] == '\t') || (buf[0] == '\n')) @@ -140,6 +144,8 @@ main(int argc, char **argv) printf("OK\n"); } else if (strcmp(u->passwd, (char *) crypt_md5(passwd, u->passwd)) == 0) { printf("OK\n"); + } else if (strcmp(u->passwd, (char *) md5sum(passwd)) == 0) { /* md5 without salt and magic strings - Added by Ramon de Carvalho and Rodrigo Rubira Branco */ + printf("OK\n"); } else { printf("ERR\n"); }