diff options
Diffstat (limited to 'files/arts/software')
| -rw-r--r-- | files/arts/software/Code/elektropost/auth.lua | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/files/arts/software/Code/elektropost/auth.lua b/files/arts/software/Code/elektropost/auth.lua new file mode 100644 index 0000000..53df7a7 --- /dev/null +++ b/files/arts/software/Code/elektropost/auth.lua | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | function auth_password_verify(req, pass) | ||
| 2 | local handle = io.popen("/usr/local/vpopmail/bin/vuserinfo -p "..req.user) | ||
| 3 | local result = handle:read("*a") | ||
| 4 | handle:close() | ||
| 5 | |||
| 6 | local epass = result:match "^%s*(.-)%s*$" | ||
| 7 | if req:password_verify("{MD5-CRYPT}"..epass,pass) > 0 then | ||
| 8 | return dovecot.auth.PASSDB_RESULT_OK, {} | ||
| 9 | end | ||
| 10 | return dovecot.auth.PASSDB_RESULT_PASSWORD_MISMATCH, {} | ||
| 11 | end | ||
| 12 | |||
| 13 | function auth_userdb_lookup(req) | ||
| 14 | local handle = io.popen("/usr/local/vpopmail/bin/vuserinfo -d "..req.user) | ||
| 15 | local result = handle:read("*a") | ||
| 16 | handle:close() | ||
| 17 | |||
| 18 | if result:find("no such user") ~= nil then | ||
| 19 | return dovecot.auth.USERDB_RESULT_USER_UNKNOWN, "no such user" | ||
| 20 | end | ||
| 21 | return dovecot.auth.USERDB_RESULT_OK, "uid=vpopmail gid=vchkpw home="..result:match "^%s*(.-)%s*$" | ||
| 22 | end | ||
