Function: ange-ftp-get-passwd
ange-ftp-get-passwd is a byte-compiled function defined in
ange-ftp.el.gz.
Signature
(ange-ftp-get-passwd HOST USER)
Documentation
Return the password for specified HOST and USER, asking user if necessary.
Source Code
;; Defined in /usr/src/emacs/lisp/net/ange-ftp.el.gz
(defun ange-ftp-get-passwd (host user)
"Return the password for specified HOST and USER, asking user if necessary."
;; If `non-essential' is non-nil, don't ask for a password. It will
;; be caught in Tramp.
(when non-essential
(throw 'non-essential 'non-essential))
(ange-ftp-parse-netrc)
;; look up password in the hash table first; user might have overridden the
;; defaults.
(cond ((ange-ftp-lookup-passwd host user))
;; See if default user and password set.
((and (stringp ange-ftp-default-user)
ange-ftp-default-password
(string-equal user ange-ftp-default-user))
ange-ftp-default-password)
;; See if default user and password set from .netrc file.
((and (stringp ange-ftp-netrc-default-user)
ange-ftp-netrc-default-password
(string-equal user ange-ftp-netrc-default-user))
ange-ftp-netrc-default-password)
;; anonymous ftp password is handled specially since there is an
;; unwritten rule about how that is used on the Internet.
((and (or (string-equal user "anonymous")
(string-equal user "ftp"))
ange-ftp-generate-anonymous-password)
(if (stringp ange-ftp-generate-anonymous-password)
ange-ftp-generate-anonymous-password
user-mail-address))
;; see if same user has logged in to other hosts; if so then prompt
;; with the password that was used there.
(t
(let* ((enable-recursive-minibuffers t)
(other (ange-ftp-get-host-with-passwd user))
(passwd (if other
;; found another machine with the same user.
;; Try that account.
(read-passwd
(format "passwd for %s@%s (default same as %s@%s): "
user host user other)
nil
(ange-ftp-lookup-passwd other user))
;; I give up. Ask the user for the password.
(read-passwd
(format "Password for %s@%s: " user host)))))
(ange-ftp-set-passwd host user passwd)
passwd))))