Skip to content

Instantly share code, notes, and snippets.

@kousu
Created January 12, 2018 10:32
Show Gist options
  • Save kousu/af2ce63a590e56c38795f9564586c6bf to your computer and use it in GitHub Desktop.
Save kousu/af2ce63a590e56c38795f9564586c6bf to your computer and use it in GitHub Desktop.
diff -r 933049a60ce6 mod_auth_external/mod_auth_external.lua
--- a/mod_auth_external/mod_auth_external.lua Thu Jan 04 11:41:54 2018 +0100
+++ b/mod_auth_external/mod_auth_external.lua Fri Jan 12 05:26:22 2018 -0500
@@ -75,6 +75,15 @@
log("debug", "Started auth process");
end
+ -- Hotfix: lpty has a glitch in some versions: no_local_echo=true is not respected until *after*
+ -- the first read happens, it seems. The first do_query() therefore fails because it reads
+ -- back the query that was sent in, so the first login after restarting prosody -- or after
+ -- any time the auth process crashes -- mysteriously fails.
+ -- By calling read() immediately and discarding the result, we skip the problem;
+ -- The protocol says that this first read should be empty, since the subprocess shouldn't
+ -- be giving us any data until we probe it.
+ pty:read(read_timeout);
+
pty:send(text);
if blocking then
return pty:read(read_timeout);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment