emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Enable passwords to be functions in erc-services


From: Rudolf Adrian Kral
Subject: [PATCH] Enable passwords to be functions in erc-services
Date: Fri, 20 Mar 2020 22:49:54 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)

Hi,

I have written a patch enabling use of functions for providing passwords
in erc-services.el. My intuition is to avoid passwords being stored in
plaintext and use something like auth-sources instead. What do you
think?

Best regards,
Rudolf Kral

diff --git a/lisp/erc/erc-services.el b/lisp/erc/erc-services.el
index 2d1d8556b2..d61e5f0db3 100644
--- a/lisp/erc/erc-services.el
+++ b/lisp/erc/erc-services.el
@@ -47,6 +47,12 @@
 ;;
 ;; (setq erc-nickserv-passwords '((freenode (("nickname" "password")))))
 ;;
+;; You can also provide a function as a password. ERC will evaluate it when
+;; needed for making a connection.
+;;
+;; (setq erc-nickserv-passwords '((freenode
+;;                                 (("nickname" (lambda () "password"))))))
+;;
 ;; The default automatic identification mode is autodetection of NickServ
 ;; identify requests.  Set the variable `erc-nickserv-identify-mode' if
 ;; you'd like to change this behavior.  You can also change the way
@@ -174,7 +180,7 @@ erc-nickserv-passwords
 Example of use:
   (setq erc-nickserv-passwords
         \\='((freenode ((\"nick-one\" . \"password\")
-                     (\"nick-two\" . \"password\")))
+                     (\"nick-two\" . (lambda () \"password\"))))
           (DALnet ((\"nick\" . \"password\")))))"
   :group 'erc-services
   :type '(repeat
@@ -198,8 +204,9 @@ erc-nickserv-passwords
                (repeat :tag "Nickname and password"
                        (cons :tag "Identity"
                              (string :tag "Nick")
-                             (string :tag "Password"
-                                      :secret ?*))))))
+                              (choice :tag "Password"
+                                      (string :secret ?*)
+                                      (function)))))))
 
 ;; Variables:
 
@@ -415,9 +422,12 @@ erc-nickserv-call-identify-function
       (call-interactively 'erc-nickserv-identify)
     (when erc-nickserv-passwords
       (erc-nickserv-identify
-       (cdr (assoc nickname
-                  (nth 1 (assoc (erc-network)
-                                erc-nickserv-passwords))))))))
+       (let ((raw-password (cdr (assoc nickname
+                                       (nth 1 (assoc (erc-network)
+                                                     
erc-nickserv-passwords))))))
+         (if (functionp raw-password)
+             (funcall raw-password)
+           raw-password))))))
 
 (defvar erc-auto-discard-away)
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]