From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "J.P." Newsgroups: gmane.emacs.bugs Subject: bug#29108: 25.3; ERC SASL support Date: Wed, 16 Nov 2022 06:51:27 -0800 Message-ID: <875yfflzps.fsf__38085.6396209978$1668610360$gmane$org@neverwas.me> References: <87h8ud92zl.fsf@gmail.com> <874jx4h6sk.fsf@neverwas.me> <875yhifujk.fsf_-_@neverwas.me> <87edw4swdk.fsf@neverwas.me> <878rljxfxs.fsf@neverwas.me> <87k04m4th8.fsf@neverwas.me> <87o7thlepf.fsf@neverwas.me> <87o7taoohd.fsf@neverwas.me> <87a64unifk.fsf@neverwas.me> <87y1sdk1fg.fsf@neverwas.me> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24416"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: emacs-erc@gnu.org, bandali@gnu.org To: 29108@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Nov 16 15:52:32 2022 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 1ovJmA-00063P-Rl for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 16 Nov 2022 15:52:31 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovJll-0006PR-Nl; Wed, 16 Nov 2022 09:52:05 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovJlj-0006Nz-C6 for bug-gnu-emacs@gnu.org; Wed, 16 Nov 2022 09:52:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ovJlj-0002ay-3s for bug-gnu-emacs@gnu.org; Wed, 16 Nov 2022 09:52:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ovJli-0002Kh-F7 for bug-gnu-emacs@gnu.org; Wed, 16 Nov 2022 09:52:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: "J.P." Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 16 Nov 2022 14:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 29108 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 29108-submit@debbugs.gnu.org id=B29108.16686103058944 (code B ref 29108); Wed, 16 Nov 2022 14:52:02 +0000 Original-Received: (at 29108) by debbugs.gnu.org; 16 Nov 2022 14:51:45 +0000 Original-Received: from localhost ([127.0.0.1]:56512 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ovJlR-0002KC-4v for submit@debbugs.gnu.org; Wed, 16 Nov 2022 09:51:45 -0500 Original-Received: from mail-108-mta133.mxroute.com ([136.175.108.133]:34049) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ovJlM-0002Jt-Ld for 29108@debbugs.gnu.org; Wed, 16 Nov 2022 09:51:44 -0500 Original-Received: from mail-111-mta2.mxroute.com ([136.175.111.2] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta133.mxroute.com (ZoneMTA) with ESMTPSA id 18480ec71ac0006e99.001 for <29108@debbugs.gnu.org> (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256); Wed, 16 Nov 2022 14:51:30 +0000 X-Zone-Loop: 00fd1c7ffb6bd25dbd16ecd45936b1872bfcf4f7346e X-Originating-IP: [136.175.111.2] DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=neverwas.me ; s=x; h=Content-Type:MIME-Version:Message-ID:Date:References:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=jifwvELTzJ0FrsVwn1tsv4w4KGGKHU5xSCj+AfaqaLQ=; b=k78cBbQl6zV66H6/F7AMbA5OBq qlyXCWQX+I7nt8rDvdt51b8XIl+9Qo4kGW+8ruZt+3SVdYH36LrURaACHIR0kHeDHICRCttZeqbXO QjG4wA0PegHpvbJE+969ay6UvTbNPqcO+0CsjBb//2AAxTNzmWUfd1wf0LEBuCzRH6stxRZ+1sNve 57R9u2XT2iFoXYb68a+MJP6jUHOkNiLwBGi3sw+TwMlpJXElV7O6qMJQs+PeDd2u5/CRfH/5/Slhh 8P4rmCwm00xa+/m52E6dOv0Wh3jhhWQf3bz5YEIW8XUqL2sjQEGTUfDAD+x4j8Za+9DnLORJ94hhb Tqoz3ccQ==; In-Reply-To: <87y1sdk1fg.fsf@neverwas.me> (J. P.'s message of "Mon, 14 Nov 2022 07:20:35 -0800") X-Authenticated-Id: masked@neverwas.me 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:248021 Archived-At: Some last-minute thoughts on the previous iteration. In 0005-Add-non-IRCv3-SASL-module-to-ERC.patch: > diff --git a/doc/misc/erc.texi b/doc/misc/erc.texi > index 5049710b32..8eb33c8e80 100644 > --- a/doc/misc/erc.texi > +++ b/doc/misc/erc.texi > @@ -78,6 +78,7 @@ Top > [...] > + > +Note that @code{sasl} is a ``local'' ERC module, which various library > +functions, like @code{erc-update-modules}, may treat differently than > +global modules in user code. However, this should not affect everyday > +client use. To get started, just add @code{sasl} to > +@code{erc-modules} like any other module. But before that, please > +explore all custom options pertaining to your chosen mechanism. An earlier version mentioned that users can customize per-network SASL settings by let-binding `erc-sasl-*' options and `erc-modules' around `erc-tls' invocations. I'm doubtful this is a sustainable approach and would guess that a more declarative solution is the likeliest way forward, perhaps something based on connection-local variables. That said, I think users still need a practical solution to tide them over in the short term, one that doesn't involve hooks or timers. And since this module already takes a snapshot of its own options on initialization (for reconnection purposes), we might as well revert to mentioning let-binding, but this time also stress (maybe in an Advanced chapter) that local modules are still being fleshed out and that third-party implementations aren't yet encouraged. > diff --git a/lisp/erc/erc-sasl.el b/lisp/erc/erc-sasl.el > new file mode 100644 > index 0000000000..a9d7ed235d > --- /dev/null > +++ b/lisp/erc/erc-sasl.el > @@ -0,0 +1,433 @@ > [...] > +;; > +;; TODO: > +;; > +;; - Find a way to obfuscate the password in memory (via something > +;; like `auth-source--obfuscate'); it's currently visible in > +;; backtraces and bug reports. Just backtraces, not bug reports. > [...] > + > +;; This stands alone because it's also used by bug#49860. > +(defun erc-sasl--init () > + ;; When reconnecting, try to recover stashed parameters. > + (let ((existing (assoc erc-networks--id erc-sasl--session-options > + #'erc-networks--id-equal-p))) > + ;; This likely only runs when `erc' was called with an :id keyword. > + (when (and existing (not erc--server-reconnecting)) > + (setq erc-sasl--session-options (delq existing erc-sasl--session-options) > + existing nil)) > + (setq erc-sasl--state (make-erc-sasl--state) > + erc-sasl--options (or (cdr existing) > + `((user . ,erc-sasl-user) > + (password . ,erc-sasl-password) > + (mechanism . ,erc-sasl-mechanism) > + (authzid . ,erc-sasl-authzid)))))) > + We should probably register a local `erc-kill-server-hook' that deletes whatever's stored in `erc-sasl--session-options' for the current network context. > [...] > + > +(defun erc-sasl--on-connection-established (&rest _) > + (setf (alist-get erc-networks--id erc-sasl--session-options nil nil > + #'erc-networks--id-equal-p) > + erc-sasl--options > + ;; > + erc-sasl--options nil)) > + We could just drop `erc-sasl--options' completely and use a getter to retrieve values from the global `erc-sasl--session-options' store. That'd be one less point of failure as far as password exposure is concerned. And, in the future, whatever context-aware abstractions emerge for making granular options a thing should obsolete all this ugly stashing business anyhow.