Function: auth-source-netrc-normalize

auth-source-netrc-normalize is a byte-compiled function defined in auth-source.el.gz.

Signature

(auth-source-netrc-normalize ALIST FILENAME)

Source Code

;; Defined in /usr/src/emacs/lisp/auth-source.el.gz
(defun auth-source-netrc-normalize (alist filename)
  (mapcar (lambda (entry)
            (let (ret item)
              (while (setq item (pop entry))
                (let ((k (car item))
                      (v (cdr item)))

                  ;; apply key aliases
                  (setq k (cond ((member k '("machine")) "host")
                                ((member k '("login" "account")) "user")
                                ((member k '("protocol")) "port")
                                ((member k '("password")) "secret")
                                (t k)))

                  ;; Send back the secret in a function (lexical
                  ;; binding).  We slightly obfuscate the passwords
                  ;; (that's the "(mapcar #+' ..)" stuff) to avoid
                  ;; showing the passwords in clear text in backtraces
                  ;; and the like.
                  (when (equal k "secret")
                    (setq v (let ((lexv (auth-source--obfuscate v))
                                  (token-decoder nil))
                              (when (string-match "^gpg:" v)
                                ;; it's a GPG token: create a token decoder
                                ;; which unsets itself once
                                (setq token-decoder
                                      (lambda (val)
                                        (prog1
                                            (auth-source-epa-extract-gpg-token
                                             val
                                             filename)
                                          (setq token-decoder nil)))))
                              (lambda ()
                                (if token-decoder
                                    (funcall token-decoder
                                             (auth-source--deobfuscate lexv))
                                  (auth-source--deobfuscate lexv))))))
                  (setq ret (plist-put ret
                                       (auth-source--symbol-keyword k)
                                       v))))
              ret))
          alist))