svn: r4535
This commit is contained in:
Jay McCarthy 2006-10-09 20:09:29 +00:00
parent e98caf31c1
commit 37a25a74df

View File

@ -23,20 +23,23 @@
(define last-read-time (box #f)) (define last-read-time (box #f))
(define password-cache (box #f)) (define password-cache (box #f))
(define (update-password-cache!) (define (update-password-cache!)
(define cur-mtime (file-or-directory-modify-seconds password-file)) (when (and (file-exists? password-file) (memq 'read (file-or-directory-permissions password-file)))
(let ([cur-mtime (file-or-directory-modify-seconds password-file)])
(when (or (not (unbox last-read-time)) (when (or (not (unbox last-read-time))
(cur-mtime . > . (unbox last-read-time)) (cur-mtime . > . (unbox last-read-time))
(not (unbox password-cache))) (not (unbox password-cache)))
(set-box! last-read-time cur-mtime) (set-box! last-read-time cur-mtime)
; more here - a malformed password file will kill the connection ; more here - a malformed password file will kill the connection
(set-box! password-cache (read-passwords password-file)))) (set-box! password-cache (read-passwords password-file))))))
(define (read-password-cache) (define (read-password-cache)
(update-password-cache!) (update-password-cache!)
(unbox password-cache)) (unbox password-cache))
(lambda (conn req) (lambda (conn req)
(define-values (uri method path) (decompose-request req)) (define-values (uri method path) (decompose-request req))
(define denied? (read-password-cache))
(cond (cond
[(access-denied? method path (request-headers/raw req) (read-password-cache)) [(and denied?
(access-denied? method path (request-headers/raw req) denied?))
=> (lambda (realm) => (lambda (realm)
(adjust-connection-timeout! conn password-connection-timeout) (adjust-connection-timeout! conn password-connection-timeout)
(request-authentication conn method uri (request-authentication conn method uri
@ -80,7 +83,6 @@
(raise (make-exn:password-file (string->immutable-string (raise (make-exn:password-file (string->immutable-string
(format "could not load password file ~a" password-path)) (format "could not load password file ~a" password-path))
(current-continuation-marks))))]) (current-continuation-marks))))])
(if (and (file-exists? password-path) (memq 'read (file-or-directory-permissions password-path)))
(let ([passwords (let ([passwords
(let ([raw (load password-path)]) (let ([raw (load password-path)])
(unless (password-list? raw) (unless (password-list? raw)
@ -99,8 +101,7 @@
(bytes->string/utf-8 password))) (bytes->string/utf-8 password)))
#f #f
(pass-entry-domain x))))) (pass-entry-domain x)))))
passwords))) passwords)))))
(lambda (req user pass) #f))))
(define fake-user (gensym)) (define fake-user (gensym))