Function: nntp-send-authinfo
nntp-send-authinfo is a byte-compiled function defined in nntp.el.gz.
Signature
(nntp-send-authinfo &optional SEND-IF-FORCE)
Documentation
Send the AUTHINFO to the nntp server.
It will look in the "~/.authinfo" file for matching entries. If nothing suitable is found there, it will prompt for a user name and a password.
If SEND-IF-FORCE, only send authinfo to the server if the
.authinfo file has the FORCE token.
Source Code
;; Defined in /usr/src/emacs/lisp/gnus/nntp.el.gz
(defun nntp-send-authinfo (&optional send-if-force)
"Send the AUTHINFO to the nntp server.
It will look in the \"~/.authinfo\" file for matching entries. If
nothing suitable is found there, it will prompt for a user name
and a password.
If SEND-IF-FORCE, only send authinfo to the server if the
.authinfo file has the FORCE token."
(require 'netrc)
(let* ((list (netrc-parse nntp-authinfo-file))
(alist (netrc-machine list nntp-address "nntp"))
(auth-info
(nth 0 (auth-source-search
:max 1
:host (list nntp-address (nnoo-current-server 'nntp))
:port `("119" "nntp" ,(format "%s" nntp-port-number)
"563" "nntps" "snews"))))
(auth-user (plist-get auth-info :user))
(auth-force (plist-get auth-info :force))
(auth-passwd (plist-get auth-info :secret))
(auth-passwd (if (functionp auth-passwd)
(funcall auth-passwd)
auth-passwd))
(force (or (netrc-get alist "force")
nntp-authinfo-force
auth-force))
(user (or
;; this is preferred to netrc-*
auth-user
(netrc-get alist "login")
nntp-authinfo-user))
(passwd (or
;; this is preferred to netrc-*
auth-passwd
(netrc-get alist "password"))))
(when (or (not send-if-force)
force)
(unless user
(setq user (read-string (format "NNTP (%s) user name: " nntp-address))
nntp-authinfo-user user))
(unless (member user '(nil ""))
(nntp-send-command "^3.*\r?\n" "AUTHINFO USER" user)
(let ((result
(nntp-send-command
"^2.*\r?\n" "AUTHINFO PASS"
(or passwd
nntp-authinfo-password
(setq nntp-authinfo-password
(read-passwd (format "NNTP (%s@%s) password: "
user nntp-address)))))))
(if (not result)
(error "Password rejected")
result))))))