Ethan Glasser-Camp <ethan.glasser.c...@gmail.com> writes:

> Hi! I tried this:

Hi Ethan,

> Then did C-x C-f /sudo:: RET. Again, I was asked for a label but not a
> password, and no `ethan@black-diamond` entry was created in my Login
> keyring. The contents of the `*Messages*` buffer were the same as
> before.

Finally, I could reproduce your problem, after I had created (manually)
the "root@gandalf" item in the "Login" collection. "gandalf2 is my local host.

Digging further, I've found bug#49289 <https://debbugs.gnu.org/49289>.
It isn't only for this problem, but also for the cascading secret
function, which I have bypassed by the modified auth-info-password ...

Reading the bug messages, I've seen it was fixed only for the netrc
backend. Oh. I've applied a similar patch to the other backends, secrets
and plstore, and voilĂ , problem solved :-)

I've pushed the appended patch to Emacs. This includes also the revert
of my previous auth-info-password change. If you like, you could try to
apply it to your Emacs 29 sources. Otherwise, you'll get the fix with
Emacs 30.

Thanks for your patient testing!

> Ethan

Best regards, Michael.

diff --git a/lisp/auth-source.el b/lisp/auth-source.el
index 9ec9ede80e0..90b58f560c0 100644
--- a/lisp/auth-source.el
+++ b/lisp/auth-source.el
@@ -869,9 +869,9 @@ auth-source-specmatchp
 (defun auth-info-password (auth-info)
   "Return the :secret password from the AUTH-INFO."
   (let ((secret (plist-get auth-info :secret)))
-    (while (functionp secret)
-      (setq secret (funcall secret)))
-    secret))
+    (if (functionp secret)
+        (funcall secret)
+      secret)))

 (defun auth-source-pick-first-password (&rest spec)
   "Pick the first secret found by applying `auth-source-search' to SPEC."
@@ -1692,7 +1692,7 @@ auth-source-secrets-search
     items))

 (cl-defun auth-source-secrets-create (&rest spec
-                                      &key backend host port create
+                                      &key backend host port create user
                                       &allow-other-keys)
   (let* ((base-required '(host user port secret label))
          ;; we know (because of an assertion in auth-source-search) that the
@@ -1700,6 +1700,7 @@ auth-source-secrets-create
          (create-extra (if (eq t create) nil create))
          (current-data (car (auth-source-search :max 1
                                                 :host host
+                                                :user user
                                                 :port port)))
          (required (append base-required create-extra))
          (collection (oref backend source))
@@ -2162,7 +2163,7 @@ auth-source-plstore-search
     items))

 (cl-defun auth-source-plstore-create (&rest spec
-                                      &key backend host port create
+                                      &key backend host port create user
                                       &allow-other-keys)
   (let* ((base-required '(host user port secret))
          (base-secret '(secret))
@@ -2172,9 +2173,11 @@ auth-source-plstore-create
          (create-extra-secret (plist-get create :encrypted))
          (create-extra (if (eq t create) nil
                          (or (append (plist-get create :unencrypted)
-                                     create-extra-secret) create)))
+                                     create-extra-secret)
+                             create)))
          (current-data (car (auth-source-search :max 1
                                                 :host host
+                                                :user user
                                                 :port port)))
          (required (append base-required create-extra))
          (required-secret (append base-secret create-extra-secret))

Reply via email to