Don't gratuitously parse ~/.netrc.
This commit is contained in:
parent
bb84449320
commit
bd368af1dc
|
@ -122,23 +122,32 @@
|
|||
;; try to determine a login and password for the server.
|
||||
|
||||
(define (ftp-login connection login password)
|
||||
(let* ((netrc-record (netrc-parse))
|
||||
(login (or login
|
||||
(netrc-lookup-login netrc-record
|
||||
(ftp-connection-host-name connection))))
|
||||
(password (or password
|
||||
(netrc-lookup-password netrc-record
|
||||
(ftp-connection-host-name connection)))))
|
||||
(let ((reply
|
||||
(ftp-send-command connection (ftp-build-command-string "USER" login)
|
||||
(lambda (code)
|
||||
(or (string=? code "331") ; "User name okay, need password."
|
||||
(string=? code "230")))))) ; "User logged in, proceed."
|
||||
(let* ((netrc-record #f)
|
||||
(get-netrc-record
|
||||
(lambda ()
|
||||
(cond
|
||||
(netrc-record)
|
||||
(else
|
||||
(set! netrc-record (netrc-parse))
|
||||
netrc-record)))))
|
||||
(let ((login (or login
|
||||
(netrc-lookup-login (get-netrc-record)
|
||||
(ftp-connection-host-name connection)))))
|
||||
(let ((reply
|
||||
(ftp-send-command connection (ftp-build-command-string "USER" login)
|
||||
(lambda (code)
|
||||
(or (string=? code "331") ; "User name okay, need password."
|
||||
(string=? code "230")))))) ; "User logged in, proceed."
|
||||
|
||||
(if (string-prefix? "331" reply) ; "User name okay, need password."
|
||||
(ftp-send-command connection
|
||||
(ftp-build-command-string "PASS" password)
|
||||
(exactly-code "230"))))))
|
||||
(if (string-prefix? "331" reply) ; "User name okay, need password."
|
||||
(ftp-send-command connection
|
||||
(ftp-build-command-string
|
||||
"PASS"
|
||||
(or password
|
||||
(netrc-lookup-password (get-netrc-record)
|
||||
(ftp-connection-host-name
|
||||
connection))))
|
||||
(exactly-code "230")))))))
|
||||
|
||||
;; Type must be one of 'binary or 'text or 'ascii, or a string which will be
|
||||
;; sent verbatim
|
||||
|
|
Loading…
Reference in New Issue