httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marc Slemko <ma...@worldgate.com>
Subject Win32: md5 for crypt
Date Sun, 22 Mar 1998 21:35:41 GMT
Ok, let's use md5 for crypt() on NT.

The below changes show how it can be done for NT.  Won't compile on Unix,
etc.

The issues are:

- should it be ap_crypt, os_crypt, what?  I'm not sure the distinctions
here make too much sense.  Once that is decided, it is easy to replace all
crypt with foo_crypt and do the right define in the right place for Unix
to make it work.

- the reason for the change to util_md5.c is to allow something that links
against it or uses it to be able to do stuff without needing pools.  

- a compilation setup for htpasswd needs to be made somehow so it can be
built.  It needs the md5 stuff from the core.

The patches below are enough to make it work as proof of concept on NT.  I
think it is worth getting this done with.

Index: main/util_md5.c
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/main/util_md5.c,v
retrieving revision 1.12
diff -u -r1.12 util_md5.c
--- util_md5.c	1998/01/07 16:46:23	1.12
+++ util_md5.c	1998/03/22 21:29:56
@@ -87,7 +87,8 @@
 {
     AP_MD5_CTX my_md5;
     unsigned char hash[16];
-    char *r, result[33];
+    char *r;
+    static char result[33];
     int i;
 
     /*
@@ -102,7 +103,10 @@
 	sprintf(r, "%02x", hash[i]);
     *r = '\0';
 
-    return pstrdup(p, result);
+    if (p)
+	return pstrdup(p, result);
+    else
+        return result;
 }
 
 /* these portions extracted from mpack, John G. Myers - jgm+@cmu.edu */
Index: modules/standard/mod_auth.c
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_auth.c,v
retrieving revision 1.33
diff -u -r1.33 mod_auth.c
--- mod_auth.c	1998/03/13 19:20:29	1.33
+++ mod_auth.c	1998/03/22 21:29:59
@@ -70,6 +70,7 @@
 #include "http_core.h"
 #include "http_log.h"
 #include "http_protocol.h"
+#include "util_md5.h"
 #if defined(HAVE_CRYPT_H)
 #include <crypt.h>
 #endif
@@ -215,7 +216,7 @@
 	return AUTH_REQUIRED;
     }
     /* anyone know where the prototype for crypt is? */
-    if (strcmp(real_pw, (char *) crypt(sent_pw, real_pw))) {
+    if (strcmp(real_pw, (char *) ap_crypt(r->pool, sent_pw, real_pw))) {
 	aplog_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server,
 		    "user %s: password mismatch: %s", c->user, r->uri);
 	note_basic_auth_failure(r);
Index: os/win32/os.h
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/os/win32/os.h,v
retrieving revision 1.13
diff -u -r1.13 os.h
--- os.h	1998/02/24 10:30:56	1.13
+++ os.h	1998/03/22 21:30:00
@@ -6,7 +6,7 @@
 
 /* temporarily replace crypt */
 /* char *crypt(const char *pw, const char *salt); */
-#define crypt(buf,salt)	    (buf)
+#define ap_crypt(p,buf,salt)	    ap_md5(p,buf)
 
 /* Although DIR_TYPE is dirent (see nt/readdir.h) we need direct.h for
    chdir() */


Mime
View raw message