[prev in list] [next in list] [prev in thread] [next in thread] 

List:       thttpd
Subject:    [THTTPD] .htpasswd patch
From:       Carlo Caputo <zed () 9hells ! org>
Date:       2002-06-02 7:46:04
[Download RAW message or body]

this patch to enable the use of complex passwd files as .htpasswd

.htpasswd were limited to login:pass format.
after patching it can do login:pass:f3:f4:f5:...

PS: the #include <time.h> were necessary to make thttpd
compile on my system: slackware-version 8.0.0 (åtta)


--- libhttpd.c.orig     2001-11-22 04:06:23.000000000 -0200
+++ libhttpd.c  2002-05-29 07:30:03.000000000 -0300
@@ -32,10 +32,11 @@
 #include <sys/types.h>
 #include <sys/param.h>
 #include <sys/wait.h>
 #include <sys/stat.h>
 #include <sys/time.h>
+#include <time.h>

 #include <ctype.h>
 #include <errno.h>
 #include <fcntl.h>
 #ifdef HAVE_MEMORY_H
@@ -853,10 +854,11 @@
     char* authpass;
     int l;
     FILE* fp;
     char line[500];
     char* cryp;
+    char* cryp_end;
     static char* prevauthpath;
     static int maxprevauthpath = 0;
     static time_t prevmtime;
     static char* prevuser;
     static int maxprevuser = 0;
@@ -944,10 +946,14 @@
        /* Split into user and encrypted password. */
        cryp = strchr( line, ':' );
        if ( cryp == (char*) 0 )
            continue;
        *cryp++ = '\0';
+       /* Get rid of other possible fields */
+       cryp_end = strchr( cryp, ':' );
+       if ( cryp_end != (char*) 0 )
+               *cryp_end = '\0';
        /* Is this the right user? */
        if ( strcmp( line, authinfo ) == 0 )
            {
            /* Yes. */
            (void) fclose( fp );

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic