Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Courier-IMAP - It works! Using things from MYSQL_SELECT_CLAUSE in regular settings..

0 views
Skip to first unread message

Sizzle

unread,
Jul 20, 2002, 3:06:06 AM7/20/02
to
Hi all!

I am setting up Courier-IMAP + Postfix + MySQL, and I'd been having
some trouble getting Courier IMAP to talk to MySQL without choking. I
noticed a few things, and thought I would share.. =)

1) Yes, those spaces between settings in authmysqlrc do seem to
matter. Use one. And only one.

2) You can stuff constant values directly into the various MYSQL
values, and you can use some of the nifty tricks demonstrated in
MYSQL_SELECT_CLAUSE.

For example, I have a REALLY simplified users table now..

+--------+---------------------+---------+
| Field | Type | Default |
+--------+---------------------+---------+
| id | varchar(128) | |
| crypt | varchar(128) | |
| clear | varchar(128) | |
| name | varchar(128) | |
| home | varchar(255) binary | admin/ |
| ... | | |
+--------+---------------------+---------+

A quick aside - I know the default for home is admin/ admin is the
virtual mailbox for the postmaster, and I figured any id that didn't
have a properly defined home should send stuff to the postmaster so
that it can be fixed. <shrug>

I have only one id owning the virtual mailboxes - in postfix's
main.cf, that translates to (two fields to remove from the db =):

virtual_uid_maps = static:65534
virtual_gid_maps = static:65534

Postfix has a virtual_mailbox_base parameter, which is constant, and I
was not liking the idea of having to maintain home and maildir when
they essentially contained the same things, in /etc/postfix/main.cf,
I have:

virtual_mailbox_base = /path/to/virtual/boxes/
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virt.cf

In /etc/postfix/mysql_virt.cf, I changed this -> to this:

user = postfix
password = xxxxxx
dbname = maildb
table = users
select_field = maildir -> select_field = CONCAT(home,'Maildir/')
where_field = id
hosts = 127.0.0.1

Which, when combined with the virtual_mailbox_base, gives you the full
path to the Maildir without ever having to give a lame path like '/'.

/path/to/virtual/boxes/<home/>Maildir/

(Assumes path in home, and path in virtual_mailbox_base both end in
/).

I know I have postfix going to mysql through TCP. When my measly
server gets enough traffic, I'll worry about how to keep the chroot
happy. For now, having it go through tcp means I don't have to worry
about how and where to set mysql.sock.

For Courier-IMAP, in authmysqlrc, I can use CONCAT again to build the
home directory using the same home field in the database (which
contains only a relative directory name):

MYSQL_USER_TABLE users
MYSQL_LOGIN_FIELD id
MYSQL_CRYPT_PWFIELD crypt
MYSQL_CLEAR_PWFIELD clear
MYSQL_NAME_FIELD name
MYSQL_HOME_FIELD CONCAT('/path/to/virtual/',home)

MYSQL_UID_FIELD 65534
MYSQL_GID_FIELD 65534

I can also pass constant uid/gid values, which is perfect for my case
where I only use one pair. Here, I'm using the Courier default to
figure out the name of the maildir (Maildir), I could just as easily
add MYSQL_MAILDIR_FIELD, which would be appended after home..

Hope this helps somebody. =)

~Sizzle~
"Waste of a good apple" - Samwise Gamgee

0 new messages