This commit is contained in:
holger krekel
2023-10-13 10:54:12 +02:00
parent f013ff434e
commit 47091db28c
7 changed files with 5 additions and 40 deletions

View File

@@ -13,7 +13,7 @@ def _install_chatctl() -> None:
"""Setup chatctl."""
files.put(
src=importlib.resources.files(__package__)
.joinpath("chatctl/chatctl.py")
.joinpath("dovecot/doveauth.py")
.open("rb"),
dest="/home/vmail/chatctl",
user="vmail",
@@ -103,8 +103,8 @@ def _configure_dovecot(mail_server: str) -> bool:
# luarocks install http lpeg_patterns fifo
auth_script = files.put(
src=importlib.resources.files(__package__).joinpath("dovecot/auth.lua"),
dest="/etc/dovecot/auth.lua",
src=importlib.resources.files(__package__).joinpath("dovecot/doveauth.lua"),
dest="/etc/dovecot/doveauth.lua",
user="root",
group="root",
mode="644",

View File

@@ -1,35 +0,0 @@
-- Lua based authentication script for Dovecot.
--
-- It calls external chatctl command to answer requests.
-- Hexadecimal aka base16 encoding.
function hex(data)
return (data:gsub(".", function(char) return string.format("%2X", char:byte()) end))
end
-- Escape shell argument by hex encoding it and wrapping in quotes.
function escape(data)
return ("'"..hex(data).."'")
end
function auth_password_verify(request, password)
if os.execute("/home/vmail/chatctl hexauth "..escape(request.user).." "..escape(password)) then
return dovecot.auth.PASSDB_RESULT_OK, {}
end
return dovecot.auth.PASSDB_RESULT_PASSWORD_MISMATCH, ""
end
function auth_passdb_lookup(request)
if os.execute("/home/vmail/chatctl hexlookup "..escape(request.user)) then
return dovecot.auth.PASSDB_RESULT_OK, {}
end
return dovecot.auth.PASSDB_RESULT_USER_UNKNOWN, "no such user"
end
function auth_userdb_lookup(request)
if os.execute("/home/vmail/chatctl hexlookup "..escape(request.user)) then
return dovecot.auth.USERDB_RESULT_OK, "uid=vmail gid=vmail"
end
return dovecot.auth.USERDB_RESULT_USER_UNKNOWN, "no such user"
end

View File

@@ -7,11 +7,11 @@ auth_mechanisms = plain
# Authentication for system users.
passdb {
driver = lua
args = file=/etc/dovecot/auth.lua
args = file=/etc/dovecot/doveauth.lua
}
userdb {
driver = lua
args = file=/etc/dovecot/auth.lua
args = file=/etc/dovecot/doveauth.lua
}
##