emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master f579cd472c: auth-source: Fix wrong-type-argument when searching s


From: Michael Albinus
Subject: master f579cd472c: auth-source: Fix wrong-type-argument when searching secret services
Date: Mon, 22 Aug 2022 10:57:09 -0400 (EDT)

branch: master
commit f579cd472cbf3d9af52c87b65473b56ce918abba
Author: Michael Albinus <michael.albinus@gmx.de>
Commit: Michael Albinus <michael.albinus@gmx.de>

    auth-source: Fix wrong-type-argument when searching secret services
    
    `auth-source-search' can be called with an integer port number,
    while the backend implementation doesn't allow non-string attributes.
    
    * doc/misc/auth.texi (Secret Service API): Attribute values are
    stringified.
    
    * lisp/auth-source.el (auth-source-secrets-search):
    Ensure attributes are string.  (Bug#55199)
---
 doc/misc/auth.texi  |  6 +++++-
 lisp/auth-source.el | 11 +++++++----
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/doc/misc/auth.texi b/doc/misc/auth.texi
index 91a9afd9c9..9dc63af6bc 100644
--- a/doc/misc/auth.texi
+++ b/doc/misc/auth.texi
@@ -384,7 +384,7 @@ This function creates a new item in @var{collection} with 
label
 @var{item} and password @var{password}.  The label @var{item} does not
 have to be unique in @var{collection}.  @var{attributes} are key-value
 pairs set for the created item.  The keys are keyword symbols,
-starting with a colon.  Example:
+starting with a colon; values are strings.  Example:
 
 @example
 ;;; The collection is "session", the label is "my item"
@@ -466,6 +466,10 @@ then fall back to @file{~/.authinfo.gpg}.
                      "~/.authinfo.gpg"))
 @end example
 
+Attribute values in the auth-source spec, which are not strings (like
+port numbers), are stringified prior calling the @file{secrets.el}
+functions.
+
 @node The Unix password store
 @chapter The Unix password store
 
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 @@ authentication tokens:
          (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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]