From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Amin Bandali Newsgroups: gmane.emacs.bugs Subject: bug#45340: erc-services.el: Auth-source support for passwords Date: Mon, 28 Dec 2020 19:12:44 -0500 Message-ID: <874kk5jwqr.fsf@gnu.org> References: <87v9cw7np1.fsf@sol.hw.lgcl.de> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20887"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 45340@debbugs.gnu.org To: Leon Vack , Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Dec 29 01:13:14 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ku2dU-0005G4-3J for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 29 Dec 2020 01:13:12 +0100 Original-Received: from localhost ([::1]:43366 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ku2dS-0006yw-Jo for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 28 Dec 2020 19:13:10 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60538) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ku2dK-0006yp-SI for bug-gnu-emacs@gnu.org; Mon, 28 Dec 2020 19:13:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:53875) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ku2dK-0000M4-Ki for bug-gnu-emacs@gnu.org; Mon, 28 Dec 2020 19:13:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ku2dK-0002dx-EA for bug-gnu-emacs@gnu.org; Mon, 28 Dec 2020 19:13:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Amin Bandali Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 29 Dec 2020 00:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45340 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 45340-submit@debbugs.gnu.org id=B45340.160920077910153 (code B ref 45340); Tue, 29 Dec 2020 00:13:02 +0000 Original-Received: (at 45340) by debbugs.gnu.org; 29 Dec 2020 00:12:59 +0000 Original-Received: from localhost ([127.0.0.1]:37188 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ku2dG-0002dg-Q4 for submit@debbugs.gnu.org; Mon, 28 Dec 2020 19:12:59 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:39138) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ku2dB-0002dP-Ng for 45340@debbugs.gnu.org; Mon, 28 Dec 2020 19:12:56 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:49408) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ku2d5-0000G9-4i; Mon, 28 Dec 2020 19:12:47 -0500 Original-Received: from [2607:fea8:3fdf:f688:79c7:928f:c16c:52a1] (port=34478 helo=localhost) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1ku2d4-0005cF-MH; Mon, 28 Dec 2020 19:12:46 -0500 In-Reply-To: <87v9cw7np1.fsf@sol.hw.lgcl.de> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:196903 Archived-At: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hello Leon, Lars, Thanks for your patch, Leon. I've left some stylistic comments below, until I get a chance to have a closer look at your patch and take it for a test run in the next week or so. :-) * * * Leon Vack writes: >> Have you already started the assignment process, or do you need the >> assignment form to get started? > > Yes, I have the form and started the assignment process with it. Thanks > for asking. Great. Please let me know when you hear from the copyright clerk about the completion of the process. * * * Leon Vack writes: > Adds an option to erc-services.el to query auth-source for NickServ > passwords. > > This is my first patch to emacs, so please let me know if I missed any > standards. I am about to start the process of assigning the copyright > to the FSF. Thanks! To begin with, please use spaces for indenting on the lines you change or the new lines you add throughout your patch. >>>From 367593cc4cbfdfbdac778fd15ceb79fd61d7f64c Mon Sep 17 00:00:00 2001 > From: Leon Vack > Date: Sun, 20 Dec 2020 10:53:33 +0100 > Subject: [PATCH] erc-services.el: Auth-source support for passwords Please rewrite the subject to conform to the conventions laid out in emacs.git's CONTRIBUTE file. Perhaps something like this: Support using auth-source for NickServ passwords in ERC > * lisp/etc/erc-services.el (erc-nickserv-passwords): Document that > the passwords are only used when erc-prompt-for-nickserv-password is > nil. > * lisp/etc/erc-services.el > (erc-use-auth-source-for-nickserv-password): New customizable > variable to enable checking auth-source for NickServ passwords. > * lisp/etc/erc-services.el (etc-nickserv-get-password): New function > to handle the lookup of the NickServ password from both auth-source > and the erc-nickserv-passwords variable. > * lisp/etc/erc-services.el (erc-nickserv-call-identify-function): > Use new erc-nickserv-get-password function to lookup NickServ > passwords. > * lisp/etc/erc-services.el (erc-nickserv-identify-autodetect) > (erc-nickserv-identify-on-connect) > (erc-nickserv-identify-on-nick-change): Call > erc-nickserv-call-identify-function when > erc-use-auth-source-for-nickserv-password is set. You don't have to repeat the "* lisp/etc/erc-services.el" at the beginning of each of those subsequent lines. You can simply start those lines with parenthesized name of the modified function/variable, followed by a colon, followed by the change description. Also, for the last entry, you can merge the multiple parenthesized names into one, like so: (erc-nickserv-identify-autodetect, erc-nickserv-identify-on-connect, erc-nickserv-identify-on-nick-change): Call ...... Lastly, please add a simple line like "* etc/NEWS: Document change." about the etc/NEWS update also. > --- > etc/NEWS | 4 ++++ > lisp/erc/erc-services.el | 50 ++++++++++++++++++++++++++++++++-------- > 2 files changed, 45 insertions(+), 9 deletions(-) > > diff --git a/etc/NEWS b/etc/NEWS > index 4a8e70e6a6..c9e0fa7459 100644 > --- a/etc/NEWS > +++ b/etc/NEWS > @@ -1283,6 +1283,10 @@ https://www.w3.org/TR/xml/#charsets). Now it reje= cts such strings. >=20=20 > ** erc >=20=20 > +*** erc-services.el now supports NickServ passwords from auth-source. > +The 'erc-use-auth-source-for-nickserv-password' enables querying > +auth-source for NickServ passwords. > + > --- > *** The '/ignore' command will now ask for a timeout to stop ignoring th= e user. > Allowed inputs are seconds or ISO8601-like periods like "1h" or "4h30m". Please consider adding example(s) of use to the NEWS entry. > diff --git a/lisp/erc/erc-services.el b/lisp/erc/erc-services.el > index c0011f9808..0710813e9d 100644 > --- a/lisp/erc/erc-services.el > +++ b/lisp/erc/erc-services.el > @@ -168,9 +168,23 @@ erc-prompt-for-nickserv-password > :group 'erc-services > :type 'boolean) >=20=20 > +(defcustom erc-use-auth-source-for-nickserv-password nil > + "Query auth-source for a password when identifiying to NickServ. > + > + > +This option has an no effect `erc-prompt-for-nickserv-password' ^ add missing 'if' > +is not nil and passwords from `erc-nickserv-passwords' take ^ add missing comma ',' > +precedence." > + :version "28.1" > + :group 'erc-services > + :type 'boolean) > + > (defcustom erc-nickserv-passwords nil > "Passwords used when identifying to NickServ automatically. >=20=20 > +`erc-prompt-for-nickserv-password' must be nil for these > +passwords to be used. > + > Example of use: > (setq erc-nickserv-passwords > \\=3D'((freenode ((\"nick-one\" . \"password\") > @@ -199,7 +213,7 @@ erc-nickserv-passwords > (cons :tag "Identity" > (string :tag "Nick") > (string :tag "Password" > - :secret ?*)))))) > + :secret ?*)))))) >=20=20 > ;; Variables: >=20=20 > @@ -375,7 +389,8 @@ erc-nickserv-identify-autodetect > If `erc-prompt-for-nickserv-password' is non-nil, prompt the user for the > password for this nickname, otherwise try to send it automatically." > (unless (and (null erc-nickserv-passwords) > - (null erc-prompt-for-nickserv-password)) > + (null erc-prompt-for-nickserv-password) > + (null erc-use-auth-source-for-nickserv-password)) > (let* ((network (erc-network)) > (sender (erc-nickserv-alist-sender network)) > (identify-regex (erc-nickserv-alist-regexp network)) > @@ -394,7 +409,8 @@ erc-nickserv-identify-autodetect > (defun erc-nickserv-identify-on-connect (_server nick) > "Identify to Nickserv after the connection to the server is establishe= d." > (unless (or (and (null erc-nickserv-passwords) > - (null erc-prompt-for-nickserv-password)) > + (null erc-prompt-for-nickserv-password) > + (null erc-use-auth-source-for-nickserv-password)) > (and (eq erc-nickserv-identify-mode 'both) > (erc-nickserv-alist-regexp (erc-network)))) > (erc-nickserv-call-identify-function nick))) > @@ -402,22 +418,38 @@ erc-nickserv-identify-on-connect > (defun erc-nickserv-identify-on-nick-change (nick _old-nick) > "Identify to Nickserv whenever your nick changes." > (unless (or (and (null erc-nickserv-passwords) > - (null erc-prompt-for-nickserv-password)) > + (null erc-prompt-for-nickserv-password) > + (null erc-use-auth-source-for-nickserv-password)) > (and (eq erc-nickserv-identify-mode 'both) > (erc-nickserv-alist-regexp (erc-network)))) > (erc-nickserv-call-identify-function nick))) >=20=20 > +(defun erc-nickserv-get-password (nickname) > + "Return the password for NICKNAME from configured sources. > + > +It uses `erc-nickserv-passwords' and additionally auth-source > +when `erc-use-auth-source-for-nickserv-password' is not nil." > + (or (when erc-nickserv-passwords > + (cdr (assoc nickname Strange formatting/indentation. I would prefer it if "(when erc-nickserv-passwords" started on its own line, and "(cdr (assoc nickname" on the line below it, and the region indented using spaces and properly, in a way that the lines fit the 70-character line length convention. > + (nth 1 (assoc (erc-network) > + erc-nickserv-passwords))))) > + (when erc-use-auth-source-for-nickserv-password > + (let* ((secret (nth 0 (auth-source-search > + :max 1 :require '(:secret) > + :host (erc-with-server-buffer erc-session-server) > + :port (format ; ensure we have a string > + "%s" (erc-with-server-buffer erc-session-port)) > + :user nickname)))) > + (when secret (let ((passwd (plist-get secret :secret))) > + (if (functionp passwd) (funcall passwd) passwd))))))) > + > (defun erc-nickserv-call-identify-function (nickname) > "Call `erc-nickserv-identify'. > Either call it interactively or run it with NICKNAME's password, > depending on the value of `erc-prompt-for-nickserv-password'." > (if erc-prompt-for-nickserv-password > (call-interactively 'erc-nickserv-identify) > - (when erc-nickserv-passwords > - (erc-nickserv-identify > - (cdr (assoc nickname > - (nth 1 (assoc (erc-network) > - erc-nickserv-passwords)))))))) > + (when password (erc-nickserv-identify (erc-nickserv-get-password nic= kname))))) This line is too long; please reformat. >=20=20 > (defvar erc-auto-discard-away) * * * Thanks! =2D-=20 https://bndl.org Free Software activist | GNU maintainer & webmaster GPG: BE62 7373 8E61 6D6D 1B3A 08E8 A21A 0202 4881 6103 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJEBAEBCgAuFiEEObM8jZRIDS3cwqSYi0Sgzce5VvIFAl/qdHwQHGJhbmRhbGlA Z251Lm9yZwAKCRCLRKDNx7lW8okeD/40wqLCdT3KLc/29hkUa7TcsF+3DF5jvGKw LQn1bSA1bL5r70mE6dpLEnfgHVEi055n8y/xtbrhGCdRP0ywsQU4onCoiQ0e6Zou m+h5bt6UnCJRFmZ22l5JL1HVQmsfzyaaSR/pC1I8pvE0qCCWP+XqNH0sMkm7T4w/ wZhvaTwVsaB5XIIS1ZJQ1GAP+oGuAsvE8XYNE37dA/Xou2KnS+UbpRc/af/WtK3f LhVmqCNalsWoMEEo+ozNklMyyrmeRuxA/KZkUErHyiCsYdzU03A1H4lRLEAphkA8 P6ui8bYVmuW3shH0f+G3HrfTwMahfCRJtXzHsWBXvvtbFfylJlFahvuKYSxdJn5f 777KReH8pQ6Zb8wAQVaHA6lR8sJAdO9IbIwdC2VKlJ7/qJ/3B/XOhqoUKfA5JTkB L1ZevGGAmdvqIYIJ4F9iFwwqfIBh3WQSPe7L2qYlM800JMw2+AiZLjctobroPrmr butGMqYgn6JL1Ej6TGMenvDGYoPT5oS2EaJb6e1hrBWLmHwowDtaTawp023fZ9jn 30akNDeAr7Z0GE9Ze1X14mfyhWMFdwnHPR72kT4kBKkHifjLqh3PfeGSABC5TW2s H4j5IRaA6X73wXv8hTZbc+9eUHq+qKt6/cizdNVV5fpUH/OG2b81uRDY4QNav3Ka kx11xSBF1Q== =wpOV -----END PGP SIGNATURE----- --=-=-=--