mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-14 06:00:33 +03:00
gnupdate: Handle FTP logins with password.
* maintainers/scripts/gnu/gnupdate.scm (%ftp-login): New procedure. (ftp-open): Use it. svn path=/nixpkgs/trunk/; revision=21714
This commit is contained in:
parent
659e48bbb0
commit
d8c33c1820
1 changed files with 9 additions and 2 deletions
|
@ -307,6 +307,14 @@
|
||||||
message
|
message
|
||||||
(throw 'ftp-error port command code message))))
|
(throw 'ftp-error port command code message))))
|
||||||
|
|
||||||
|
(define (%ftp-login user pass port)
|
||||||
|
(display (string-append "USER " user (string #\newline)) port)
|
||||||
|
(let-values (((code message) (%ftp-listen port)))
|
||||||
|
(case code
|
||||||
|
((230) #t)
|
||||||
|
((331) (%ftp-command (string-append "PASS " pass) 230 port))
|
||||||
|
(else (throw 'ftp-error port command code message)))))
|
||||||
|
|
||||||
(define (ftp-open host)
|
(define (ftp-open host)
|
||||||
(catch 'getaddrinfo-error
|
(catch 'getaddrinfo-error
|
||||||
(lambda ()
|
(lambda ()
|
||||||
|
@ -319,8 +327,7 @@
|
||||||
(if (eqv? code 220)
|
(if (eqv? code 220)
|
||||||
(begin
|
(begin
|
||||||
;(%ftp-command "OPTS UTF8 ON" 200 s)
|
;(%ftp-command "OPTS UTF8 ON" 200 s)
|
||||||
;; FIXME: When `USER' returns 331, we should do a `PASS email'.
|
(%ftp-login "anonymous" "ludo@example.com" s)
|
||||||
(%ftp-command "USER anonymous" 230 s)
|
|
||||||
(%make-ftp-connection s ai))
|
(%make-ftp-connection s ai))
|
||||||
(begin
|
(begin
|
||||||
(format (current-error-port) "FTP to `~a' failed: ~A: ~A~%"
|
(format (current-error-port) "FTP to `~a' failed: ~A: ~A~%"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue