From 9bb5248dab5fafc7e999ec92667b8dba8a5cc644 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Thu, 2 Jan 2025 03:42:39 +0100 Subject: bring the blog up to date --- stories/projects/elektropost.rst | 46 ++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 6 deletions(-) (limited to 'stories/projects/elektropost.rst') diff --git a/stories/projects/elektropost.rst b/stories/projects/elektropost.rst index 1a04345..cedd7f7 100644 --- a/stories/projects/elektropost.rst +++ b/stories/projects/elektropost.rst @@ -4,7 +4,7 @@ .. date: 2014/02/01 19:10:08 .. title: elektropost .. subtitle: a FreeBSD jail based mail server project. -.. slug: ../arts/software/elektropost/index +.. slug: ../arts/software/elektropost .. prio: 750 .. contents:: @@ -70,7 +70,7 @@ Install dovecot =============== * ``make install`` in /usr/ports/mail/dovecot -* choose option VPOPMAIL, keep the rest (maybe disable IPV6) +* choose option LUA, keep the rest (maybe disable IPV6) * ``echo 'dovecot_enable="YES"' >> /etc/rc.conf`` ---- @@ -78,7 +78,7 @@ Install dovecot Configure dovecot ================= -* ``cp /usr/local/etc/dovecot-example.conf /usr/local/etc/dovecot.conf`` +* ``cp /usr/local/etc/dovecot/dovecot-example.conf /usr/local/etc/dovecot/dovecot.conf`` * Change: protocols = imap imaps pop3s * Change: listen = and ssl_listen = to match your ip addresses * Change: ssl_cert_file = /var/qmail/control/servercert.pem @@ -88,9 +88,43 @@ Configure dovecot * Change: first_valid_gid = 1 * Change: max_mail_processes = 1024 * Change: auth_username_format = %Ln@%Ld -* Change: #passdb pam { and #} if you do not have local user mail -* Change: #userdb passwd { and #} if you do not have local user mail -* Change: userdb vpopmail { and } to use vpopmail's vchkpw +* Change:: + + passdb { + driver = lua + args = file=/usr/local/etc/dovecot/auth.lua blocking=yes # default is yes + } + userdb { + driver = lua + args = file=/usr/local/etc/dovecot/auth.lua blocking=yes # default is yes + } + +Install the file http://erdgeist.org/arts/software/Code/elektropost/auth.lua in ``/usr/local/etc/dovecot/``, + +.. code-block:: + + function auth_password_verify(req, pass) + local handle = io.popen("/usr/local/vpopmail/bin/vuserinfo -p "..req.user) + local result = handle:read("*a") + handle:close() + + local epass = result:match "^%s*(.-)%s*$" + if req:password_verify("{MD5-CRYPT}"..epass,pass) > 0 then + return dovecot.auth.PASSDB_RESULT_OK, {} + end + return dovecot.auth.PASSDB_RESULT_PASSWORD_MISMATCH, {} + end + + function auth_userdb_lookup(req) + local handle = io.popen("/usr/local/vpopmail/bin/vuserinfo -d "..req.user) + local result = handle:read("*a") + handle:close() + + if result:find("no such user") ~= nil then + return dovecot.auth.USERDB_RESULT_USER_UNKNOWN, "no such user" + end + return dovecot.auth.USERDB_RESULT_OK, "uid=vpopmail gid=vchkpw home="..result:match "^%s*(.-)%s*$" + end ---- -- cgit v1.2.3