Subject: bug#55199: 28.1; rcirc auth-source integration doesn't handle port being a number

From: Michael Albinus <[email-masked]>
Date: Sun, 21 Aug 2022 10:02:24 +0200

Javier Olaechea <[email-masked]> writes:

Hi Javier,

> I have a simple way to reproduce the issue. Start emacs with emacs -Q.
> Then evaluate the following snippet
>
> (require 'auth-source)
>
> (let ((auth-sources '("secrets:Login")))
>   (auth-source-search :port 6697))

Yep. Fails here as well.

> So the issue is not at all on rcirc, but that secrets backend assumes
> that the search specs should be strings. I haven't researched the
> SecretService API to know if this is a restriction of the underlying
> dbus service the secrets backend works with or just a restrictive
> assumption of the code in secrets.el.

The Secret Service API allows only strings for attribute keys and
values, see <https://specifications.freedesktop.org/secret-service/latest/re03.html>:

--8<---------------cut here---------------start------------->8---
READWRITE Dict<String,String> Attributes ;
--8<---------------cut here---------------end--------------->8---

Looking at auth-source.el. there was a similar problem in
auth-source-plstore-search, see commit
fcb89237d9ab969bcd29bf8f8fae8d9905644b92 in Emacs git. Applying a
similar change to auth-source-secrets-search let the error go away.

I've appended the patch, could you pls check in the rcirc context? I'm
also not sure whether we need to change something when creating an item
in auth-source-secrets-create.

Best regrads, Michael.

diff --git a/lisp/auth-source.el b/lisp/auth-source.el
index f198362f10..c79e5b81f7 100644
--- a/lisp/auth-source.el
+++ b/lisp/auth-source.el
@@ -1618,10 +1618,13 @@ auth-source-secrets-search
          (search-specs (auth-source-secrets-listify-pattern
                         (apply #'append (mapcar
                                       (lambda (k)
-                                        (if (or (null (plist-get spec k))
-                                                (eq t (plist-get spec k)))
-                                            nil
-                                          (list k (plist-get spec k))))
+                                        (let ((v (plist-get spec k)))
+                                          (if (or (null v)
+                                                  (eq t v))
+                                              nil
+                                            (list
+                                             k
+                                             (auth-source-ensure-strings v)))))
                                       search-keys))))
          ;; needed keys (always including host, login, port, and secret)
          (returned-keys (delete-dups (append