]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Imported ncsa_auth changes from Squid-2
authorhno <>
Mon, 25 Jun 2007 17:27:03 +0000 (17:27 +0000)
committerhno <>
Mon, 25 Jun 2007 17:27:03 +0000 (17:27 +0000)
- Support for plain MD5 hashed password (no salting)
- man page documenting it's use

helpers/basic_auth/NCSA/Makefile.am
helpers/basic_auth/NCSA/crypt_md5.c
helpers/basic_auth/NCSA/crypt_md5.h
helpers/basic_auth/NCSA/ncsa_auth.c

index 825c3b961cfa6719b9515c2682273ed69d34b11b..43d736f555d2c9de6415efe0496bdb2baaa56e6f 100644 (file)
@@ -1,12 +1,14 @@
 #
 #  Makefile for the Squid Object Cache server
 #
-#  $Id: Makefile.am,v 1.5 2003/05/31 11:31:46 hno Exp $
+#  $Id: Makefile.am,v 1.6 2007/06/25 11:27:03 hno Exp $
 #
 #  Uncomment and customize the following to suit your needs:
 #
 
 libexec_PROGRAMS       = ncsa_auth
 ncsa_auth_SOURCES      = ncsa_auth.c crypt_md5.c crypt_md5.h
+man_MANS               = ncsa_auth.8
+EXTRA_DIST             = ncsa_auth.8
 LDADD                  = -L$(top_builddir)/lib -lmiscutil $(CRYPTLIB) $(XTRA_LIBS) $(SSLLIB)
 INCLUDES      = -I$(top_srcdir)/include
index d781a02746988b3f5467f41bdd4ff2dbf068b455..8936c84bee69c2d54e8d427b737b105d03da3d3c 100644 (file)
@@ -16,6 +16,7 @@
  */
 
 #include <string.h>
+#include <stdio.h>
 #include "config.h"
 #include "md5.h"
 
@@ -166,3 +167,30 @@ char *crypt_md5(const char *pw, const char *salt)
 
     return passwd;
 }
+
+/* Created by Ramon de Carvalho <ramondecarvalho@yahoo.com.br>
+   Refined by Rodrigo Rubira Branco <rodrigo@kernelhacking.com>
+*/
+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[32]='\0';
+
+   /* Don't leave anything around in vm they could use. */
+   memset(digest, 0, sizeof digest);
+
+   return sum;
+}
+
index 2e27d82d7e8aa86fb9cebc236d9f483a03d9ee6d..47c4e7787fa6433f02c70f44afd184dea40b10fb 100644 (file)
@@ -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);
index 07e5f7b045480e3bb72fb3ef4ebaad75734e30bf..7d690515d799155aff01aecff9d189a411100c55 100644 (file)
@@ -141,10 +141,14 @@ main(int argc, char **argv)
        u = (user_data *) hash_lookup(hash, user);
        if (u == NULL) {
            printf("ERR No such user\n");
+#if HAVE_CRYPT
        } else if (strcmp(u->passwd, (char *) crypt(passwd, u->passwd)) == 0) {
            printf("OK\n");
+#endif
        } 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 Wrong password\n");
        }