modoboa / modoboa-installer

An installer for Modoboa
MIT License
254 stars 135 forks source link

Manual installation guide fails on dovecot password_query because home_dir is not set #528

Closed patrickschmelter closed 9 months ago

patrickschmelter commented 9 months ago

Impacted versions

Steps to reproduce

I followed the installation guide on https://modoboa.readthedocs.io/en/latest/installation.html#manual-installation and can not log in to dovecot via imap. I have restricted knowledge about all of the inner workings of mailservers and can not figure out what went wrong. After a log of investivation and turning on auth_debug in dovecot, I noticed the following lines in the logs:

auth-worker(8712): Debug: conn unix:auth-worker (pid=8705,uid=97): auth-worker<2>: sql(*@*.*,*.*.*.*,<*>): Failed to expand password_query=SELECT email AS user, password, '%{home_dir}/%%d/%%n' AS userdb_home, %mailboxes_owner_uid AS userdb_uid, %mailboxes_owner_gid AS userdb_gid, CONCAT('*:bytes=', mb.quota, 'M') AS userdb_quota_rule FROM core_user u INNER JOIN admin_mailbox mb ON u.id=mb.user_id INNER JOIN admin_domain dom ON mb.domain_id=dom.id WHERE (mb.is_send_only=0 OR '%s' NOT IN ('imap', 'pop3')) AND u.email='%%u' AND u.is_active=1 AND dom.enabled=1: Unknown variable '%home_dir'

In the corresponding tables, I could not find any of the home_dir or uid/gid fields queried in the sql. Did I miss something in the setup guide? How can I set the home_dir correctly? Where do my mailboxes live? Do I have to configure something in Modoboa? There is no new user or home directory created on the system, is this a problem?

Is this linked to modoboa not delegating the mailbox creation successfully to dovecot? In the manual, there is a cron job which says * * * * * <mailbox user> \$PYTHON \$INSTANCE/manage.py handle_mailbox_operations What do I enter in ? Do I have to create one manually? I couldn't find any info in the manual.

Edit: Do I need to follow this https://doc.dovecot.org/configuration_manual/howto/simple_virtual_install/ ?

I added the vmail user and group with a home dir, set the to vmail and hardcoded the %{home_dir} to /home/vmail/ while keeping the appendix /%%d/%%n. Still I see no mailboxes being created and no "Maildir" directory. Does it have to be created manually? (-> No, didn't help either) Also, now I get another error logging in with imap after deleting and creating a new domain and mail user via modoboa:

Warning: sqlpool(mysql): Query failed, retrying: Unknown column 'PLAINailboxes_owner_uid' in 'field list'

Seems like the %mailboxes_owner_uid and %mailboxes_owner_gid fields in the query do not get populated correctly. I am not sure how to proceed.. The "PLAIN" and missing "%m" also seem weird to me

Edit2: After filling the mailboxes_owner_uid and mailboxes_owner_gid manually with the user and group id of the vmail user, it is finally working 🎉

Expected behavior

Video/Screenshot link (optional)