mirror of
https://github.com/chatmail/relay.git
synced 2026-05-19 20:38:05 +00:00
renames
This commit is contained in:
@@ -13,7 +13,7 @@ def _install_chatctl() -> None:
|
|||||||
"""Setup chatctl."""
|
"""Setup chatctl."""
|
||||||
files.put(
|
files.put(
|
||||||
src=importlib.resources.files(__package__)
|
src=importlib.resources.files(__package__)
|
||||||
.joinpath("chatctl/chatctl.py")
|
.joinpath("dovecot/doveauth.py")
|
||||||
.open("rb"),
|
.open("rb"),
|
||||||
dest="/home/vmail/chatctl",
|
dest="/home/vmail/chatctl",
|
||||||
user="vmail",
|
user="vmail",
|
||||||
@@ -103,8 +103,8 @@ def _configure_dovecot(mail_server: str) -> bool:
|
|||||||
|
|
||||||
# luarocks install http lpeg_patterns fifo
|
# luarocks install http lpeg_patterns fifo
|
||||||
auth_script = files.put(
|
auth_script = files.put(
|
||||||
src=importlib.resources.files(__package__).joinpath("dovecot/auth.lua"),
|
src=importlib.resources.files(__package__).joinpath("dovecot/doveauth.lua"),
|
||||||
dest="/etc/dovecot/auth.lua",
|
dest="/etc/dovecot/doveauth.lua",
|
||||||
user="root",
|
user="root",
|
||||||
group="root",
|
group="root",
|
||||||
mode="644",
|
mode="644",
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -7,11 +7,11 @@ auth_mechanisms = plain
|
|||||||
# Authentication for system users.
|
# Authentication for system users.
|
||||||
passdb {
|
passdb {
|
||||||
driver = lua
|
driver = lua
|
||||||
args = file=/etc/dovecot/auth.lua
|
args = file=/etc/dovecot/doveauth.lua
|
||||||
}
|
}
|
||||||
userdb {
|
userdb {
|
||||||
driver = lua
|
driver = lua
|
||||||
args = file=/etc/dovecot/auth.lua
|
args = file=/etc/dovecot/doveauth.lua
|
||||||
}
|
}
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|||||||
Reference in New Issue
Block a user