(nami, hpk) some random WIP-changes to make dovecot auth work and get us an understanding

This commit is contained in:
holger krekel
2023-10-13 12:51:09 +02:00
committed by missytake
parent 1942ad3cef
commit 28fe373489
3 changed files with 15 additions and 12 deletions

View File

@@ -8,7 +8,8 @@ end
-- call out to python program to actually manage authentication for dovecot -- call out to python program to actually manage authentication for dovecot
function chatctl_verify(user, password) function chatctl_verify(user, password)
local handle = io.popen("python doveauth.py hexauth "..escape(user).." "..escape(password)) dovecot.i_debug("chatctl_verify wurde aufgerufen")
local handle = io.popen("python3 /home/vmail/chatctl hexauth "..escape(user).." "..escape(password))
local result = handle:read("*a") local result = handle:read("*a")
handle:close() handle:close()
return split_chatctl(result) return split_chatctl(result)
@@ -16,7 +17,7 @@ end
function chatctl_lookup(user) function chatctl_lookup(user)
assert(user) assert(user)
local handle = io.popen("python doveauth.py hexlookup "..escape(user)) local handle = io.popen("python3 /home/vmail/chatctl hexlookup "..escape(user))
local result = handle:read("*a") local result = handle:read("*a")
handle:close() handle:close()
return split_chatctl(result) return split_chatctl(result)
@@ -27,24 +28,21 @@ function get_extra_dovecot_output(res)
end end
function auth_passdb_verify(request, password) function auth_password_verify(request, password)
local res = chatctl_verify(request.user, password) local res = chatctl_verify(request.user, password)
dovecot.i_debug("auth_password_verify")
if res.status == "ok" then if res.status == "ok" then
local extra = get_extra_dovecot_output(res)
return dovecot.auth.PASSDB_RESULT_OK, get_extra_dovecot_output(res) return dovecot.auth.PASSDB_RESULT_OK, get_extra_dovecot_output(res)
end end
return dovecot.auth.PASSDB_RESULT_PASSWORD_MISMATCH, "" return dovecot.auth.PASSDB_RESULT_PASSWORD_MISMATCH, ""
end end
function auth_passdb_lookup(request)
local res = chatctl_lookup(request.user)
if res.status == "ok" then
return dovecot.auth.PASSDB_RESULT_OK, get_extra_dovecot_output(res)
end
return dovecot.auth.PASSDB_RESULT_USER_UNKNOWN, "no such user"
end
function auth_userdb_lookup(request) function auth_userdb_lookup(request)
local res = chatctl_lookup(request.user) local res = chatctl_lookup(request.user)
dovecot.i_debug("auth_userdb_lookup")
if res.status == "ok" then if res.status == "ok" then
return dovecot.auth.USERDB_RESULT_OK, get_extra_dovecot_output(res) return dovecot.auth.USERDB_RESULT_OK, get_extra_dovecot_output(res)
end end

View File

@@ -6,7 +6,7 @@ import sys
def get_user_data(user): def get_user_data(user):
if user == b"link2xt@instant2.testrun.org": if user == b"link2xt@instant2.testrun.org":
return dict( return dict(
homedir="/home/vmail/link2xt", home="/home/vmail/link2xt",
uid="vmail", uid="vmail",
gid="vmail", gid="vmail",
password=b"Ahyei6ie", password=b"Ahyei6ie",
@@ -17,7 +17,7 @@ def get_user_data(user):
def create_user(user, password): def create_user(user, password):
assert isinstance(password, bytes) assert isinstance(password, bytes)
return dict( return dict(
homedir=f"/home/vmail/{user}", uid="vmail", gid="vmail", password=password home=f"/home/vmail/{user}", uid="vmail", gid="vmail", password=password
) )

View File

@@ -4,6 +4,11 @@ protocols = imap lmtp
auth_mechanisms = plain auth_mechanisms = plain
auth_verbose = yes
auth_debug = yes
auth_debug_passwords = yes
auth_verbose_passwords = plain
# Authentication for system users. # Authentication for system users.
passdb { passdb {
driver = lua driver = lua