[Dovecot] Fix lua error when trying to escape empty domains

master
andryyy 2019-12-04 21:47:25 +01:00
parent b320465da3
commit 13ef9dd113
No known key found for this signature in database
GPG Key ID: 8EC34FF2794E25EF
1 changed files with 6 additions and 2 deletions

View File

@ -114,6 +114,10 @@ EOF
cat <<EOF > /var/lib/dovecot/app-passdb.lua
function auth_password_verify(req, pass)
if req.domain == nil then
req.log_info(req, "Domain cannot be empty")
return dovecot.auth.PASSDB_RESULT_USER_UNKNOWN, "No such user"
end
local cur,errorString = con:execute(string.format([[SELECT mailbox, password FROM app_passwd
WHERE mailbox = '%s'
AND active = '1'
@ -121,13 +125,13 @@ function auth_password_verify(req, pass)
local row = cur:fetch ({}, "a")
while row do
if req.password_verify(req, row.password, pass) == 1 then
req.log_warning(req, string.format("User %s logged in with app password", row.mailbox))
req.log_info(req, string.format("User %s logged in with app password", row.mailbox))
cur:close()
return dovecot.auth.PASSDB_RESULT_OK, "password=" .. pass
end
row = cur:fetch (row, "a")
end
return dovecot.auth.PASSDB_RESULT_USER_UNKNOWN, "no such user"
return dovecot.auth.PASSDB_RESULT_USER_UNKNOWN, "No such user"
end
function script_init()