From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Albinus via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#74105: 30.0.92; Some issues in TRAMP NEWS entries Date: Tue, 12 Nov 2024 17:11:32 +0100 Message-ID: <87a5e4mnyj.fsf@gmx.de> References: <87v7x9g82h.fsf@melete.silentflame.com> <87frod957b.fsf@gmx.de> <87ldy023f7.fsf@melete.silentflame.com> <87cyjcnyz4.fsf@gmx.de> <87plnbzyz0.fsf@melete.silentflame.com> <87h68mlxac.fsf@gmx.de> <87ses3okh1.fsf@melete.silentflame.com> <8734k3jvts.fsf@gmx.de> <87ed3mla7f.fsf@melete.silentflame.com> <877c9b8d7w.fsf@gmx.de> <87y11rgnrs.fsf@melete.silentflame.com> <87sery6sm5.fsf@gmx.de> Reply-To: Michael Albinus Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19614"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 74105@debbugs.gnu.org To: Sean Whitton Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Nov 12 17:12:41 2024 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 1tAtVP-0004sG-LH for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 12 Nov 2024 17:12:39 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tAtUr-00070l-Bg; Tue, 12 Nov 2024 11:12: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 1tAtUo-00070Q-O0 for bug-gnu-emacs@gnu.org; Tue, 12 Nov 2024 11:12:03 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tAtUo-0003KK-AV for bug-gnu-emacs@gnu.org; Tue, 12 Nov 2024 11:12:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=QBeDGb2Ay3MztOPpZ/FUMq0OwI8GsZiWi5G3tlM97XY=; b=BixGZQLeAZxryAW3Cb/67bIOV29fowdCmVZoDXWrCBZiFmmIC8+uToxupVrNQbhMRNpU9G7vSU0cqP+uGk+0HS6WiqvkmmHpGPPjABeL/oH+8KgZRVF4p94lzvziAAVZrNlwNpWXdKc2IdyC4Dm8AAui5mZDyUraM3zVqkdl+roJccJrEEK45x0FwDLC4dZoy2ADaqgdB+fOOpBW1h/39K1N7uuVH1U499Z/ZHETkKxsjOzb6y1SnntYn2ISIdaVw5KIwPjr3yrU0Aavoj5d10HIK2dMEzKJbH6l4N9h6rgrbf+lTeLvqW1Sk6ffk9AsppKlc0+XgLF6Dd1p07copA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tAtUn-0007x3-Pv for bug-gnu-emacs@gnu.org; Tue, 12 Nov 2024 11:12:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Michael Albinus Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 12 Nov 2024 16:12:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74105 X-GNU-PR-Package: emacs Original-Received: via spool by 74105-submit@debbugs.gnu.org id=B74105.173142790630491 (code B ref 74105); Tue, 12 Nov 2024 16:12:01 +0000 Original-Received: (at 74105) by debbugs.gnu.org; 12 Nov 2024 16:11:46 +0000 Original-Received: from localhost ([127.0.0.1]:39000 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tAtUX-0007vj-QV for submit@debbugs.gnu.org; Tue, 12 Nov 2024 11:11:46 -0500 Original-Received: from mout.gmx.net ([212.227.15.19]:35053) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tAtUV-0007vU-6G for 74105@debbugs.gnu.org; Tue, 12 Nov 2024 11:11:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1731427895; x=1732032695; i=michael.albinus@gmx.de; bh=QBeDGb2Ay3MztOPpZ/FUMq0OwI8GsZiWi5G3tlM97XY=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=ZAyhA3IjalQPvhXZjBrEkR9VWtIDrZQ0p/T3pVdwbdS6FTg/OuFMPTAzyVCgqdz7 vHzWWL4IcgcZZ/HGDql0BaF5lEkA5iwj0+OzowCc+GpkTQSKdfcphiAyQyBagva7U G2bboDxCot7Bbw5Dcz4SEkX8j3O7al06td+7oCYZZ/aFD9cEqewpzcurS/5jrkVvM 6QTIyGQsbDbhzF1faeHvleDnJD+xeFHSFAItWnuT//SNm8U09YWcsqooFQPxRgtSx QR8m3zFDKY7DZ0hM2lD1TqIgFK8Xm/zFjOwocmiCenMb94OzkXKlFJC2G7f4yxPtq d0jTfYDNA55UKMK4ug== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from gandalf.gmx.de ([185.89.38.155]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MBlxW-1t5LZb2yom-004xQT; Tue, 12 Nov 2024 17:11:35 +0100 In-Reply-To: <87sery6sm5.fsf@gmx.de> (Michael Albinus via's message of "Mon, 11 Nov 2024 10:13:06 +0100") X-Provags-ID: V03:K1:tNoh1ajbjRf4hyJTl1/u3EfHQ3kZKF+SkMgL7Y4UCAOwNOl2vgY jyw8kdDfpNByvtXz29CQQBqsAUEz2B7J9uT7WPOpyUT3dRR2TUTOikNFUyRqtWsq5LM5bGK Jc8pPMOWsnmjHtNV5WLJkJkiSrS3pq5QYb0FbHF3H5T77kdUZTPKpqeitO34MBboTwGlbxT wCL/ZL0jmkS6U+tbDBaOA== UI-OutboundReport: notjunk:1;M01:P0:noTXgC4Gqvw=;Qb0JwFU6zkqmg1ubeHpTiSk5e1J LtssuAeUmw80XBb+eM1e7zwp5iz87gH3LibLU4F2BlD0B+aq9ILxHauGeTPBAV9ZHv827HVJv tLBfe+VDrbyavgCGZs8Vkx39FM/78rcpN1w6uPqyIcCLcwmqqE+T5eXJUo6xUxwiDXgMNMxJX OOAzTRx/2Jw82wD69nwSV8t9H+JPl0Ew1UYyfnFcqZcROkEMmmmUeUIsX1S1wZwTWvYgbdiXL +J7Nbx1p3vjrwrzmM9VUXi0LAxtrFDAUOT92HrJ9Xe8ZNoq2QQ75ba72QlrmGsiOJNmhRLh7Y GZ2LPSjb2WYjRjH69uuvGH2Bs5YOsbLgeQlZA9Myck/JJXIdKEIzunZTsJWp6UgyRKOuFjc4c lkrAZ5HoPvP2x+4SMotd4mnvwpXIutTMn3rv6cZFz1nU/ohe3xojqphfGg7yZvSpEBuClMxHC CmldjeSXQKBYk28EKk3CxBmuUBlGXRRPw0CDWhFcguul3PmTpc4JfTzCG3SNNYmtkxH4bAS/1 LN6Lkx7a5XinSJgt1QD82gtrBzHI8nhhE+YiRIgXFWD/6cXhehtm+UB7fphqimH6A4nQwG92u rQ7XxoHDqSwUrHPsNUBuRPhkyvuAYe+FiV1dPjaRz7JuDkRcsN3Mwrf3War5ig7K8KddxNPtC FProKnxVPn5gy141rXKybleDndA4bdxNYmsI8Izmsl94gFziUSG4tmXUxaCGw34F5hs4m6u6A 4yhyfbu1F83a0BUpb5/OULDGg/5KBd5Rd0OMlRShIdVbKF6Os1ArbfXsv5jmVb6sSlAEzpXJ 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:295247 Archived-At: --=-=-= Content-Type: text/plain Michael Albinus via "Bug reports for GNU Emacs, the Swiss army knife of text editors" writes: Hi Sean, >> Thanks for the documentation update. I think, though, that this is a >> backwards-incompatible change (or even a regression, depending on your >> point of view): in older Emacs, the password was not cached at all, by >> default. So, I think we need a NEWS entry as well. > > I have difficulties to reproduce the problem with older Emacsen exactly > as you have described. Could you pls send me the value of auth-sources > on your Emacs as well as the output of the shell command > > # ls -al ~/.authinfo* ~/.netrc* xxx > > I would like to understand in detail, why the behavior has been changed > for you. I've digged further. Surprisingly, Tramp has a feature that, when a session times out, the corresponding password cache entry is removed. So there shouldn't be a problem at all, right? I wrote this years ago. But since I don't need it myself, I've forgotten about. However, this feature has errors in implementation. Most important, when the user, for whom the password has to be cached, was changed back in Emacs 29, this mechanism wasn't adapted properly. I rewrote tramp-read-passwd and tramp-clear-passwd, see the appended a patch. I've tested the change with all Emacsen from Emacs 27 .. 31, seems to work. The patch is written for Tramp 2.7.1.4 from GNU ELPA. However, it seems to apply also on the Emacs 30 sources (where it wouldn't go due to the pretest). Would you like to test? Since this feature has been brought back to work, you don't need to care about auth-source-cache-expiry or password-cache-expiry. Simply set the connection property "session-timeout" to 8, as you do in your test, and it shall work. I'll continue to work on the patch. Next step, I want to add a test to tramp-tests.el, in order to not break it again silently. Best regards, Michael. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment Content-Transfer-Encoding: quoted-printable diff --git a/lisp/tramp.el b/lisp/tramp.el index b149b3b9..4303d25b 100644 =2D-- a/lisp/tramp.el +++ b/lisp/tramp.el @@ -5646,7 +5646,11 @@ of." ;; Sometimes, the process returns a new password request ;; immediately after rejecting the previous (wrong) one. (unless (or tramp-password-prompt-not-unique - (tramp-get-connection-property vec "first-password-request")) + (tramp-get-connection-property + (tramp-get-connection-property + proc "password-vector" + (process-get proc 'tramp-vector)) + "first-password-request")) (tramp-clear-passwd vec)) (goto-char (point-min)) (tramp-check-for-regexp proc tramp-process-action-regexp) @@ -6797,13 +6801,13 @@ Consults the auth-source package." (case-fold-search t) ;; In tramp-sh.el, we must use "password-vector" due to ;; multi-hop. - (vec (tramp-get-connection-property - proc "password-vector" (process-get proc 'tramp-vector))) - (key (tramp-make-tramp-file-name vec 'noloc)) - (method (tramp-file-name-method vec)) - (user-domain (or (tramp-file-name-user-domain vec) + (vec (process-get proc 'tramp-vector)) + (pw-vec (tramp-get-connection-property proc "password-vector" vec)) + (key (tramp-make-tramp-file-name pw-vec 'noloc)) + (method (tramp-file-name-method pw-vec)) + (user-domain (or (tramp-file-name-user-domain pw-vec) (tramp-get-connection-property key "login-as"))) - (host-port (tramp-file-name-host-port vec)) + (host-port (tramp-file-name-host-port pw-vec)) (pw-prompt (string-trim-left (or prompt @@ -6812,29 +6816,23 @@ Consults the auth-source package." (if (string-match-p "passphrase" (match-string 1)) (match-string 0) (format "%s for %s " (capitalize (match-string 1)) key)))))) + ;; If there is no user name, `:create' triggers to ask for. + ;; We suppress it. + (pw-spec (list :max 1 :user user-domain :host host-port :port method + :require (cons :secret (and user-domain '(:user))) + :create (and user-domain t))) (auth-source-creation-prompts `((secret . ,pw-prompt))) ;; Use connection-local value. (auth-sources (buffer-local-value 'auth-sources (process-buffer proc))) auth-info auth-passwd tramp-dont-suspend-timers) (unwind-protect - ;; We cannot use `with-parsed-tramp-file-name', because it - ;; expands the file name. (or (setq tramp-password-save-function nil) - ;; See if auth-sources contains something useful. + ;; See if `auth-sources' contains something useful. (ignore-errors - (and auth-sources - (tramp-get-connection-property vec "first-password-reques= t") - ;; Try with Tramp's current method. If there is no - ;; user name, `:create' triggers to ask for. We - ;; suppress it. - (setq auth-info - (car - (auth-source-search - :max 1 :user user-domain :host host-port :port method - :require (cons :secret (and user-domain '(:user))) - :create (and user-domain t))) + (and (tramp-get-connection-property pw-vec "first-password-request") + (setq auth-info (car (apply #'auth-source-search pw-spec)) tramp-password-save-function (plist-get auth-info :save-function) auth-passwd @@ -6842,16 +6840,23 @@ Consults the auth-source package." ;; Try the password cache. (with-tramp-suspended-timers - (setq auth-passwd (password-read pw-prompt key) + (setq auth-passwd + (password-read + pw-prompt (auth-source-format-cache-entry pw-spec)) tramp-password-save-function - (lambda () (password-cache-add key auth-passwd))) + (when auth-source-do-cache + (lambda () + (password-cache-add + (auth-source-format-cache-entry pw-spec) auth-passwd)))) auth-passwd)) ;; Workaround. Prior Emacs 28.1, auth-source has saved empty ;; passwords. See discussion in Bug#50399. (when (tramp-string-empty-or-nil-p auth-passwd) (setq tramp-password-save-function nil)) - (tramp-set-connection-property vec "first-password-request" nil)))) + ;; Remember the values. + (tramp-set-connection-property vec "pw-spec" pw-spec) + (tramp-set-connection-property pw-vec "first-password-request" nil)= ))) (defun tramp-read-passwd-without-cache (proc &optional prompt) "Read a password from user (compat function)." @@ -6868,17 +6873,11 @@ Consults the auth-source package." (defun tramp-clear-passwd (vec) "Clear password cache for connection related to VEC." (declare (tramp-suppress-trace t)) - (let ((method (tramp-file-name-method vec)) - (user-domain (tramp-file-name-user-domain vec)) - (host-port (tramp-file-name-host-port vec)) - (hop (tramp-file-name-hop vec))) - (when hop - ;; Clear also the passwords of the hops. - (tramp-clear-passwd (tramp-dissect-hop-name hop))) - (auth-source-forget - `(:max 1 ,(and user-domain :user) ,user-domain - :host ,host-port :port ,method)) - (password-cache-remove (tramp-make-tramp-file-name vec 'noloc)))) + (when-let* ((hop (tramp-file-name-hop vec))) + ;; Clear also the passwords of the hops. + (tramp-clear-passwd (tramp-dissect-hop-name hop))) + (when-let* ((pw-spec (tramp-get-connection-property vec "pw-spec"))) + (auth-source-forget pw-spec))) (defun tramp-time-diff (t1 t2) "Return the difference between the two times, in seconds. --=-=-=--