all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] Enable passwords to be functions in erc-services
@ 2020-03-20 21:49 Rudolf Adrian Kral
  2020-04-08 14:21 ` Bruno Félix Rezende Ribeiro
  0 siblings, 1 reply; 4+ messages in thread
From: Rudolf Adrian Kral @ 2020-03-20 21:49 UTC (permalink / raw)
  To: GNU Emacs Developers

[-- Attachment #1: Type: text/plain, Size: 251 bytes --]

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Patch for erc-services --]
[-- Type: text/x-diff, Size: 2118 bytes --]

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)
 

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-06-11 19:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-20 21:49 [PATCH] Enable passwords to be functions in erc-services Rudolf Adrian Kral
2020-04-08 14:21 ` Bruno Félix Rezende Ribeiro
2020-04-09  4:21   ` Amin Bandali
2020-06-11 19:21     ` Ted Zlatanov

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.