[Dovecot] Case insensitive user names
I am trying to set up the Dovecot pop3 server for some virtual hosting I am doing and it is going well, I am generating a passwd file that points dovecot to the virtual users mailspool. The only thing that I don't have working is that my current pop3 server (NTMail) has case insensitve usernames. Dovecot doesn't. I was hoping there was just an option to turn on, but I didn't see one, and unfortunately I don't know enough C to change to lc($submitted_user) eq lc($database_user) like I would in perl :-)
I do have control over generating the passwd file, and it is currently generating the users to lowecase in the file, so just lc($submitted_user) eq $database_user would work well enough. Unfortunately I don't know enough C to do that, so I thought I would ask if anyone has done this.
So, does anyone have any ideas on how to do this?
Thank you,
-- andrew
/---------------------------------------------------------------------
| ICQ# | Proud Member of Mad-Techies.org |
| 253198 | http://www.mad-techies.org |
|---------------------------------------------------------------------|
| There are two ways to write error-free programs; |
| only the third one works. |
\---------------------------------------------------------------------/
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 | \---------------------------------------------------------------------/
aha, a little more digging through the dovecot source leads me to this much simpler patch. --- src/auth/db-passwd-file.c.orig 2003-05-18 05:26:28.000000000 -0700 +++ src/auth/db-passwd-file.c 2004-03-19 15:32:52.000000000 -0700 @@ -153,6 +153,9 @@ static void passwd_file_open(struct pass if (args[1] != NULL) { /* at least two fields */ const char *no_args = NULL; + + args[0] = str_lcase(args[0]); + passwd_file_add(pw, args[0], args[1], pw->userdb ? args+2 : &no_args); } @@ -219,6 +222,8 @@ db_passwd_file_lookup(struct passwd_file { struct passwd_user *pu; + user = str_lcase(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 | |---------------------------------------------------------------------| | A computer is like an air-conditioned house, so don't open Windows! | \---------------------------------------------------------------------/
participants (1)
-
andrew fresh