[Dovecot] Case insensitive user names

andrew fresh andrew at mad-techies.org
Fri Mar 19 23:50:03 EET 2004


Trying to make it work case insensitive, I came up with the following.  It seems to be working so far. I guess I will have to see if there are any issues.

l8rZ,

--- src/auth/db-passwd-file.c.orig      2003-05-18 05:26:28.000000000 -0700
+++ src/auth/db-passwd-file.c   2004-03-19 14:49:22.000000000 -0700
@@ -18,6 +18,7 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <sys/stat.h>
+#include <ctype.h>

 static void passwd_file_add(struct passwd_file *pw, const char *username,
                            const char *pass, const char *const *args)
@@ -153,6 +154,14 @@ static void passwd_file_open(struct pass
                if (args[1] != NULL) {
                        /* at least two fields */
                        const char *no_args = NULL;
+
+                        int  i = 0;
+                        while ( args[0][i] )
+                        {
+                            args[0][i] = tolower(args[0][i]);
+                            i++;
+                        }
+
                        passwd_file_add(pw, args[0], args[1],
                                        pw->userdb ? args+2 : &no_args);
                }
@@ -219,6 +228,14 @@ db_passwd_file_lookup(struct passwd_file
 {
        struct passwd_user *pu;

+       int  i = 0;
+       while ( user[i] )
+       {
+           user[i] = tolower(user[i]);
+           i++;
+       }
+       i_info("passwd-file(%s): lowecase user", user);
+
        passwd_file_sync(pw);

        pu = hash_lookup(pw->users, user);


-- 
andrew

/---------------------------------------------------------------------\
|   ICQ#   |             Proud Member of Mad-Techies.org              |
|  253198  |               http://www.mad-techies.org                 |
|---------------------------------------------------------------------|
| "Programming today is a race between software engineers striving to |
| build bigger and better idiot-proof programs, and the Universe      |
| trying to produce bigger and better idiots. So far, the Universe is |
| winning."                           -- Rich Cook                    |
\---------------------------------------------------------------------/


More information about the dovecot mailing list