3 messages in net.sourceforge.lists.courier-usersRe: [courier-users] Setting up Courie...
FromSent OnAttachments
Joel DeYoungMay 24, 2003 5:04 pm 
Joel DeYoungMay 24, 2003 6:05 pm 
Joel DeYoungMay 26, 2003 8:09 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [courier-users] Setting up Courier-IMAP with mysql authActions...
From:Joel DeYoung (jo@deyoung.net)
Date:May 26, 2003 8:09:44 am
List:net.sourceforge.lists.courier-users

I didn't get any replies on this issue, but I did solve it and I learned a lot in the process. Here are my results: YMMV.

Courier's logging facilities are pretty bad. After I initially used mySQL's debugging to determine the authdaemon wasn't issuing the query to the database, my only option was to modify the source and pepper the code with calls to syslog. That ended up working pretty well.

I found what I think is a problem with the code in the patch by Pawel Wilk to allow arbitrary database queries for mySQL authorization. It seems to depend on the select clause having a valid domain or a default domain being defined. I am only using Courier as a POP3 and IMAP server, not an MTA, so for my authentication I am only interested in mapping mailbox/password pairs into maildir locations. This means domain names are kind of irrelevant. Here is the code I changed in authlib/authmysqllib.c, with my change marked with "jo@deyoung.net".

/* sie@pld.org.pl */ static char *parse_select_clause (const char *clause, const char *username, const char *defdomain, const char *service) { static struct var_data vd[]={ {"local_part", NULL, sizeof("local_part"), 0}, {"domain", NULL, sizeof("domain"), 0}, {"service", NULL, sizeof("service"), 0}, {NULL, NULL, 0, 0}};

if (clause == NULL || *clause == '\0' || !username || *username == '\0') return NULL;

vd[0].value = get_localpart (username); vd[1].value = get_domain (username, defdomain); if (!vd[1].value) vd[1].value = ""; /* jo@deyoung.net */ if (!vd[0].value || !vd[1].value) return NULL; vd[2].value = service;

return (parse_string (clause, vd)); }

Without the change above, a value clause is passed into this function for string substitution to be performed on it, but since the default domain is empty, the function simply returns NULL. This causes the caller to give up sending the query and to fail silently.

I have sent this change to the code author to see if he wants to incorporate it. And I should also mention that I'm in his debt for implementing this patch in the first place! It's my hope that in future release of Courier, this will be the default behavior of the mySQL auth lib.

Joel

A followup: I turned on mysql logging and was able to find out that courier was connecting successfully to the database, and setting vmail as the default database. But it never issues the query.

Any ideas?

Joel DeYoung wrote:

I am setting up exim and courier-imap for virtual mailboxes driven by a mysql backend. My database schema is simple: a table containing mailbox names, plaintext passwords, and a subdirectory for the maildir. Compiling was no problem and I can start up my POP3 or IMAP daemons with the .rc scripts. Here is the content of my authmysqlrc:

MYSQL_SERVER localhost MYSQL_USERNAME vmail MYSQL_PASSWORD <hidden> MYSQL_DATABASE vmail MYSQL_SELECT_CLAUSE SELECT mailbox, \ '', \ password, \ 'vmail', \ 'mail', \ CONCAT('/var/spool/vmail/',maildir) \ CONCAT('/var/spool/vmail/',maildir) \ '', \ '' \ FROM mailboxes \ WHERE mailbox='$(local_part)'

When I try to login via pop3, the server reports login failed. I would like to debug this, but I'm not sure where useful log information might be written. How can I find out if the daemon connected to the mySQL server alright? How can I see what actual query it sends? How can I see what maildir is returned?

Any help would be appreciated.

Thanks in advance, Joel