4 messages in net.sourceforge.lists.courier-usersRe: [courier-users] MYSQL_SELECT_CLAU...
FromSent OnAttachments
Lane VanceApr 18, 2003 8:43 am 
Rodrigo SeveroApr 21, 2003 6:15 am 
Ryan ParleeApr 21, 2003 7:33 am 
Sam VarshavchikApr 21, 2003 2:37 pm 
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] MYSQL_SELECT_CLAUSE ProblemActions...
From:Rodrigo Severo (rodr@fabricadeideias.com)
Date:Apr 21, 2003 6:15:46 am
List:net.sourceforge.lists.courier-users

Lane Vance wrote:

Using: Courier 1.7.1 MySQL 3.23.56-log

I am having a problem trying to use a custom MySQL select clause with authmysql. When I try to use the suggested Courier schema for the MySQL table I see the following query run with the data it returns in order and I successfully authenticate into that mail box:

SELECT id, crypt, clear, uid, gid, home, maildir, quota, name FROM courier WHERE id = "la@heave.info"

la@heave.info fyGQOQRqjL/rY password 1000 1000 /home/spool/mail/domains/heave.info /home/spool/mail/domains/heave.info NULL Lane Vance

However, the suggested schema does not fit my needs. When run my own query below it returns the following but I do NOT authenticate successfully into the mail box:

SELECT CONCAT(popbox.local_part,'@',popbox.domain_name), TRIM('{crypt}' FROM popbox.password_hash), popbox.clearpw, domain.uid, domain.gid, CONCAT(domain.path,'/', popbox.mbox_name), CONCAT(domain.path, '/', popbox.mbox_name), popbox.imap_quota, '' FROM popbox, domain WHERE popbox.local_part = 'lane' AND popbox.domain_name = 'heave.info' AND popbox.domain_name = domain.domain_name

First of all, use the first three fields of the above SQL in your authmysqlrc file, not the ones below. The correct order of the fields is "id, crypt, clear, uid, gid, home, maildir, quota, name" even for the custom select clause, not only for the regular select clause. Besides that the id should have the domain attached. You don't have it in the SELECT_CLAUSE below.

After fixing these two problems, if you still can't login, turn on mysql query log with an entry in /etc/my.cnf like:

[mysqld] log = /usr/local/mysql/var/query.log

With this log you will be able to see if courier is sending the proper query to courier (which it probably will be happening).

BTW, I have it working fine in my system right now.

Good luck,

Rodrigo

The authmysqlrc file for my custom select statement is as follows:

MYSQL_SERVER localhost MYSQL_USERNAME dbusername MYSQL_PASSWORD password # MYSQL_SOCKET /var/mysql/mysql.sock MYSQL_PORT 3306 MYSQL_OPT 0 MYSQL_DATABASE email # MYSQL_USER_TABLE passwd # MYSQL_CRYPT_PWFIELD crypt # MYSQL_CLEAR_PWFIELD clear # DEFAULT_DOMAIN example.com # MYSQL_UID_FIELD uid # MYSQL_GID_FIELD gid # MYSQL_LOGIN_FIELD id # MYSQL_HOME_FIELD home # MYSQL_NAME_FIELD name # MYSQL_MAILDIR_FIELD maildir # MYSQL_QUOTA_FIELD quota # MYSQL_WHERE_CLAUSE server='mailhost.example.com' MYSQL_SELECT_CLAUSE SELECT popbox.local_part, TRIM('{crypt}' FROM popbox.password_hash), domain.gid, domain.uid, popbox.clearpw, TRIM(TRAILING 'Maildir' FROM CONCAT(domain.path,'/', popbox.mbox_name)), CONCAT(domain.path, '/', popbox.mbox_name), popbox.imap_quota, '' FROM popbox, domain WHERE popbox.local_part = '$(local_part)' AND popbox.domain_name = '$(domain)' AND popbox.domain_name = domain.domain_name

I have tried everything I can think of. Any assistance anyone can offer will be _greatly_ appreciated!