diff options
Diffstat (limited to 'stories/projects/elektropost.rst')
-rw-r--r-- | stories/projects/elektropost.rst | 46 |
1 files changed, 40 insertions, 6 deletions
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 @@ | |||
4 | .. date: 2014/02/01 19:10:08 | 4 | .. date: 2014/02/01 19:10:08 |
5 | .. title: elektropost | 5 | .. title: elektropost |
6 | .. subtitle: a FreeBSD jail based mail server project. | 6 | .. subtitle: a FreeBSD jail based mail server project. |
7 | .. slug: ../arts/software/elektropost/index | 7 | .. slug: ../arts/software/elektropost |
8 | .. prio: 750 | 8 | .. prio: 750 |
9 | 9 | ||
10 | .. contents:: | 10 | .. contents:: |
@@ -70,7 +70,7 @@ Install dovecot | |||
70 | =============== | 70 | =============== |
71 | 71 | ||
72 | * ``make install`` in /usr/ports/mail/dovecot | 72 | * ``make install`` in /usr/ports/mail/dovecot |
73 | * choose option VPOPMAIL, keep the rest (maybe disable IPV6) | 73 | * choose option LUA, keep the rest (maybe disable IPV6) |
74 | * ``echo 'dovecot_enable="YES"' >> /etc/rc.conf`` | 74 | * ``echo 'dovecot_enable="YES"' >> /etc/rc.conf`` |
75 | 75 | ||
76 | ---- | 76 | ---- |
@@ -78,7 +78,7 @@ Install dovecot | |||
78 | Configure dovecot | 78 | Configure dovecot |
79 | ================= | 79 | ================= |
80 | 80 | ||
81 | * ``cp /usr/local/etc/dovecot-example.conf /usr/local/etc/dovecot.conf`` | 81 | * ``cp /usr/local/etc/dovecot/dovecot-example.conf /usr/local/etc/dovecot/dovecot.conf`` |
82 | * Change: protocols = imap imaps pop3s | 82 | * Change: protocols = imap imaps pop3s |
83 | * Change: listen = and ssl_listen = to match your ip addresses | 83 | * Change: listen = and ssl_listen = to match your ip addresses |
84 | * Change: ssl_cert_file = /var/qmail/control/servercert.pem | 84 | * Change: ssl_cert_file = /var/qmail/control/servercert.pem |
@@ -88,9 +88,43 @@ Configure dovecot | |||
88 | * Change: first_valid_gid = 1 | 88 | * Change: first_valid_gid = 1 |
89 | * Change: max_mail_processes = 1024 | 89 | * Change: max_mail_processes = 1024 |
90 | * Change: auth_username_format = %Ln@%Ld | 90 | * Change: auth_username_format = %Ln@%Ld |
91 | * Change: #passdb pam { and #} if you do not have local user mail | 91 | * Change:: |
92 | * Change: #userdb passwd { and #} if you do not have local user mail | 92 | |
93 | * Change: userdb vpopmail { and } to use vpopmail's vchkpw | 93 | passdb { |
94 | driver = lua | ||
95 | args = file=/usr/local/etc/dovecot/auth.lua blocking=yes # default is yes | ||
96 | } | ||
97 | userdb { | ||
98 | driver = lua | ||
99 | args = file=/usr/local/etc/dovecot/auth.lua blocking=yes # default is yes | ||
100 | } | ||
101 | |||
102 | Install the file http://erdgeist.org/arts/software/Code/elektropost/auth.lua in ``/usr/local/etc/dovecot/``, | ||
103 | |||
104 | .. code-block:: | ||
105 | |||
106 | function auth_password_verify(req, pass) | ||
107 | local handle = io.popen("/usr/local/vpopmail/bin/vuserinfo -p "..req.user) | ||
108 | local result = handle:read("*a") | ||
109 | handle:close() | ||
110 | |||
111 | local epass = result:match "^%s*(.-)%s*$" | ||
112 | if req:password_verify("{MD5-CRYPT}"..epass,pass) > 0 then | ||
113 | return dovecot.auth.PASSDB_RESULT_OK, {} | ||
114 | end | ||
115 | return dovecot.auth.PASSDB_RESULT_PASSWORD_MISMATCH, {} | ||
116 | end | ||
117 | |||
118 | function auth_userdb_lookup(req) | ||
119 | local handle = io.popen("/usr/local/vpopmail/bin/vuserinfo -d "..req.user) | ||
120 | local result = handle:read("*a") | ||
121 | handle:close() | ||
122 | |||
123 | if result:find("no such user") ~= nil then | ||
124 | return dovecot.auth.USERDB_RESULT_USER_UNKNOWN, "no such user" | ||
125 | end | ||
126 | return dovecot.auth.USERDB_RESULT_OK, "uid=vpopmail gid=vchkpw home="..result:match "^%s*(.-)%s*$" | ||
127 | end | ||
94 | 128 | ||
95 | ---- | 129 | ---- |
96 | 130 | ||