Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

We are running courier currently which enables us to set different SQL userdb queries for IMAP and POP3. We need this because we do not want to give all users IMAP access, a boolean column in the userdb allows IMAP access if set.

For performance and stability reasons we are currently migrating to dovecot. I found no way yet to either set different SQL queries based on POP3 or IMAP access - or to pass the access method as variable to the SQL query. Both ways would work.

Here's the relevant mysql config from courier:

MYSQL_SELECT_CLAUSE SELECT \
  username,password_enc,password,uid,gid,homedir,maildir,'',CONCAT(\
    IF(isimap=1 OR '$(service)'='webmail','disableimap=0,','disableimap=1,'),\
    'disablepop3=0,disablewebmail=0'\
  )\
  FROM mail_users WHERE username = '$(local_part)@$(domain)'

The service variable comes from the daemon config file. Is there something similar in dovecot?

share|improve this question
add comment

1 Answer

You can use the %s variable to check what service is being requested. See http://wiki2.dovecot.org/Variables .

Something like this could work for you as the SQL query:

SELECT
  '%u' AS username, '%d' AS domain,
  password, uid, gid, homedir AS home
FROM mail_users
WHERE
  CONCAT('%u', '@', '%d') = username'' AND
  (isimap=1 OR '%s' <> 'imap')

-Phil

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.