diff options
Diffstat (limited to 'auth.txr')
-rw-r--r-- | auth.txr | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/auth.txr b/auth.txr new file mode 100644 index 0000000..f2c062e --- /dev/null +++ b/auth.txr @@ -0,0 +1,19 @@ +@(do + (defun put-binary-str (str stream) + (let ((len (length str))) + (put-byte (trunc len 256) stream) + (put-byte (mod len 256) stream) + (put-string str stream))) + + (defun sasl-auth (user pass) + (let ((sock (open-socket af-unix sock-stream))) + (sock-connect sock (new sockaddr-un path "/var/run/saslauthd/mux")) + (put-binary-str user sock) + (put-binary-str pass sock) + (put-binary-str "" sock) + (put-binary-str "" sock) + (let ((response (get-string sock))) + (equal [response 2..4] "OK"))))) +@(define auth (userid password)) +@ (require (sasl-auth userid password)) +@(end) |