unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#68376: 30.0.50; auth-source-search doesn't support numeric port on macOS
@ 2024-01-11  0:57 Kirill A. Korinsky
  2024-01-11 10:12 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 4+ messages in thread
From: Kirill A. Korinsky @ 2024-01-11  0:57 UTC (permalink / raw)
  To: 68376


[-- Attachment #1.1: Type: text/plain, Size: 2829 bytes --]

Greeting,

I'd like to share a bug with simple reproducer:

(auth-source-search :host "some.host" :port "123" :user "user")
(auth-source-search :host "some.host" :port 123 :user "user")

The first line works as expected, and the second one fails as:

Debugger entered--Lisp error: (wrong-type-argument stringp 123)
  call-process("/usr/bin/security" nil t nil "find-generic-password" "-g" "-c" "some.host" "-a" "user" "-s" 123)
  auth-source-macos-keychain-search-items("default" macos-keychain-generic 1 "some.host" 123 "user" :type macos-keychain-generic :user "user")
  apply(auth-source-macos-keychain-search-items "default" macos-keychain-generic 1 "some.host" 123 "user" (:type macos-keychain-generic :user "user"))
  auth-source-macos-keychain-search(:backend #<auth-source-backend auth-source-backend-1ff08463df92> :type macos-keychain-generic :max 1 :require nil :create nil :delete nil :host "some.host" :port 123 :user "user")
  auth-source-search-backends((#<auth-source-backend auth-source-backend-1ff08463df92> #<auth-source-backend auth-source-backend-1ff0887f79e6> #<auth-source-backend auth-source-backend-1ff07046d5fe> #<auth-source-backend auth-source-backend-1ff070457074>) (:host "some.host" :port 123 :user "user") 1 nil nil nil)
  auth-source-search(:host "some.host" :port 123 :user "user")
  eval((auth-source-search :host "some.host" :port 123 :user "user") nil)
  elisp--eval-last-sexp(nil)
  eval-last-sexp(nil)
  funcall-interactively(eval-last-sexp nil)
  command-execute(eval-last-sexp)

on

In GNU Emacs 30.0.50 (build 1, x86_64-apple-darwin21.6.0, NS
 appkit-2113.60 Version 12.7.1 (Build 21G920)) of 2024-01-10 built on
 Kirills-MBP.sa31-home.catap.net
Windowing system distributor 'Apple', version 10.3.2113
System Description:  macOS 12.7.1

Configured using:
 'configure --prefix=/opt/local --disable-silent-rules --without-dbus
 --without-gconf --without-libotf --without-m17n-flt --with-libgmp
 --with-gnutls --with-json --with-xml2 --with-modules --with-sqlite3
 --with-webp --infodir /opt/local/share/info/emacs --with-ns
 --with-lcms2 --without-harfbuzz --without-xaw3d --with-imagemagick
 --with-rsvg --with-native-compilation=aot --with-tree-sitter
 'CFLAGS=-pipe -Os
 -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -arch
 x86_64' 'CPPFLAGS=-I/opt/local/include
 -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk'
 'LDFLAGS=-L/opt/local/lib -Wl,-headerpad_max_install_names -Wl,-rpath
 /opt/local/lib/gcc13
 -Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk
 -arch x86_64''

which was build from https://github.com/emacs-mirror/emacs/commit/d9462e24a967e32d550ee886b5150f0cc78358f6 <https://github.com/emacs-mirror/emacs/commit/d9462e24a967e32d550ee886b5150f0cc78358f6>
--
wbr, Kirill


[-- Attachment #1.2: Type: text/html, Size: 4359 bytes --]

[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#68376: 30.0.50; auth-source-search doesn't support numeric port on macOS
  2024-01-11  0:57 bug#68376: 30.0.50; auth-source-search doesn't support numeric port on macOS Kirill A. Korinsky
@ 2024-01-11 10:12 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-01-11 10:38   ` Kirill A. Korinsky
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-01-11 10:12 UTC (permalink / raw)
  To: Kirill A. Korinsky; +Cc: 68376

[-- Attachment #1: Type: text/plain, Size: 762 bytes --]

"Kirill A. Korinsky" <kirill@korins.ky> writes:

> Greeting,

Hi Kirill,

> I'd like to share a bug with simple reproducer:
>
> (auth-source-search :host "some.host" :port "123" :user "user")
> (auth-source-search :host "some.host" :port 123 :user "user")
>
> The first line works as expected, and the second one fails as:
>
> Debugger entered--Lisp error: (wrong-type-argument stringp 123)
>   call-process("/usr/bin/security" nil t nil "find-generic-password"
> "-g" "-c" "some.host" "-a" "user" "-s" 123)

call-process requires strings as arguments. This must be converted
in auth-source-macos-keychain-search-items if needed.

Could you, please, check whether the appended patch works? I cannot test
myself, I have no macOS machine.

Best regards, Michael.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 1985 bytes --]

diff --git a/lisp/auth-source.el b/lisp/auth-source.el
index 369cf4dca2e..cf93cb05fba 100644
--- a/lisp/auth-source.el
+++ b/lisp/auth-source.el
@@ -1946,18 +1946,20 @@ auth-source-macos-keychain-search
          (returned-keys (delete-dups (append
 				      '(:host :login :port :secret)
 				      search-keys)))
-         ;; Extract host and port from spec
+         ;; Extract host, port and user from spec
          (hosts (plist-get spec :host))
-         (hosts (if (and hosts (listp hosts)) hosts `(,hosts)))
+         (hosts (if (consp hosts) hosts `(,hosts)))
          (ports (plist-get spec :port))
-         (ports (if (and ports (listp ports)) ports `(,ports)))
+         (ports (if (consp ports) ports `(,ports)))
          (users (plist-get spec :user))
-         (users (if (and users (listp users)) users `(,users)))
+         (users (if (consp users) users `(,users)))
          ;; Loop through all combinations of host/port and pass each of these to
-         ;; auth-source-macos-keychain-search-items
+         ;; auth-source-macos-keychain-search-items.  Convert numeric port to
+         ;; string (bug#68376).
          (items (catch 'match
                   (dolist (host hosts)
                     (dolist (port ports)
+                      (when (numberp port) (setq port (number-to-string port)))
                       (dolist (user users)
                         (let ((items (apply
                                       #'auth-source-macos-keychain-search-items
@@ -2019,7 +2021,7 @@ auth-source-macos-keychain-search-items
     (when port
       (if keychain-generic
           (setq args (append args (list "-s" port)))
-        (setq args (append args (if (string-match "[0-9]+" port)
+        (setq args (append args (if (string-match-p "\\`[[:digit:]]+\\'" port)
                                     (list "-P" port)
                                   (list "-r" (substring
                                               (format "%-4s" port)

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#68376: 30.0.50; auth-source-search doesn't support numeric port on macOS
  2024-01-11 10:12 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-01-11 10:38   ` Kirill A. Korinsky
  2024-01-11 11:32     ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 4+ messages in thread
From: Kirill A. Korinsky @ 2024-01-11 10:38 UTC (permalink / raw)
  To: Michael Albinus; +Cc: 68376

[-- Attachment #1: Type: text/plain, Size: 227 bytes --]

> On 11. Jan 2024, at 11:12, Michael Albinus <michael.albinus@gmx.de> wrote:
> 
> Could you, please, check whether the appended patch works? I cannot test
> myself, I have no macOS machine.


It works, thanks.

--
wbr, Kirill


[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#68376: 30.0.50; auth-source-search doesn't support numeric port on macOS
  2024-01-11 10:38   ` Kirill A. Korinsky
@ 2024-01-11 11:32     ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-01-11 11:32 UTC (permalink / raw)
  To: Kirill A. Korinsky; +Cc: 68376-done

Version: 30.1

"Kirill A. Korinsky" <kirill@korins.ky> writes:

Hi Kirill,

>> Could you, please, check whether the appended patch works? I cannot test
>> myself, I have no macOS machine.
>
> It works, thanks.

Thanks for the feedback. I've pushed the fix to the master branch,
closing the bug.

> wbr, Kirill

Best regards, Michael.





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-01-11 11:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-11  0:57 bug#68376: 30.0.50; auth-source-search doesn't support numeric port on macOS Kirill A. Korinsky
2024-01-11 10:12 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-11 10:38   ` Kirill A. Korinsky
2024-01-11 11:32     ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).