diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-03-21 12:43:57 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-03-21 12:43:57 -0700 |
commit | 90d7449c02681e1e16d81784d6610d6b0af96a3d (patch) | |
tree | 814a7c66b84912c8d131626c36cd5a5346334516 | |
parent | 610e83f3d6654d2fe95c20cf2280f7d894ac58f8 (diff) | |
download | tamarind-90d7449c02681e1e16d81784d6610d6b0af96a3d.tar.gz tamarind-90d7449c02681e1e16d81784d6610d6b0af96a3d.tar.bz2 tamarind-90d7449c02681e1e16d81784d6610d6b0af96a3d.zip |
Implementing IMAP authentication.
-rw-r--r-- | auth.txr | 31 | ||||
-rw-r--r-- | config.txr | 1 |
2 files changed, 31 insertions, 1 deletions
@@ -15,5 +15,34 @@ (let ((response (get-string sock))) (equal [response 2..4] "OK"))))) @(define auth (userid password)) -@ (require (sasl-auth userid password)) +@ (if (eq auth :sasl)) +@ (require (sasl-auth userid password)) +@ (elif (eq auth :imap)) +@ (try) +@ (bind s @(let ((sock (open-socket af-inet sock-stream "r+ib"))) + (sock-connect sock (new sockaddr-in + addr inaddr-loopback + port 143)) + (sock-recv-timeout sock (* 30 1000000)))) +@ (next s) +* OK@(skip) +@ (output s) +A0001 LOGIN @userid @password@\r +@ (end) +@ (repeat :gap 0) +* @(skip) +@ (end) +@ (cases) +A0001 OK@(skip) +@ (accept) +@ (or) +A0001 NO@(skip) +@ (fail) +@ (end) +@ (catch timeout-error) +@ (fail) +@ (end) +@ (else) +@ (fail) +@ (end) @(end) @@ -1,5 +1,6 @@ @(bind debug-enable t) @(bind aliases-file "/etc/tamarind/aliases") @(bind sessions-dir "/var/run/tamarind/sessions") +@(bind auth :imap) @(bind sasl-sock "/var/run/saslauthd/mux") @(bind csslink "") |