unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#38371: 27.0.50; network-stream-certificate fails to specify :port as a string for auth-source-search
@ 2019-11-25 11:50 Alex Murray
  2019-11-26  8:30 ` Robert Pluim
  0 siblings, 1 reply; 5+ messages in thread
From: Alex Murray @ 2019-11-25 11:50 UTC (permalink / raw)
  To: 38371

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

Sending mail via SMTP in Emacs 27.0.50 fails when using the secrets
auth-source backend - this seems to be due to network-stream-certificate
calling auth-source-search with :port specified as an integer - since
then later auth-source-secrets-listify-pattern fails with the following
backtrace as it seems to expect all parameters to be strings.

Attached is a patch to resolve this, in the same way bug#20541 was
solved previously.

I wonder however if it might just be better to make
auth-source-secrets-listify-pattern smarter to handle numeric elements

Debugger entered--Lisp error: (wrong-type-argument sequencep 587)
  mapcar(#f(compiled-function (v) #<bytecode 0x157a1426228d>) 587)
  auth-source-secrets-listify-pattern((:port 587))
  auth-source-secrets-listify-pattern((:host "smtp.server.com" :port 587))
  auth-source-secrets-search(:backend #<auth-source-backend auth-source-backend-157a12d702d8> :type secrets :max 1 :require nil :create nil :delete nil :max 1 :host "smtp.server.com" :port 587)
  apply(auth-source-secrets-search :backend #<auth-source-backend auth-source-backend-157a12d702d8> :type secrets :max 1 :require nil :create nil :delete nil (:max 1 :host "smtp.server.com" :port 587))
  auth-source-search-backends((#<auth-source-backend auth-source-backend-157a12d40ef0> #<auth-source-backend auth-source-backend-157a12d702d8> #<auth-source-backend auth-source-backend-157a12d71808>) (:max 1 :host "smtp.server.com" :port 587) 1 nil nil nil)
  auth-source-search(:max 1 :host "smtp.server.com" :port 587)
  network-stream-certificate("smtp.server.com" 587 (:type nil :return-list t :warn-unless-encrypted nil :capability-command "EHLO slate\15\n" :end-of-command "^[0-9]+ .*\15\n" :success "^2.*\n" :always-query-capabilities t :starttls-function #f(compiled-function (capabilities) #<bytecode 0x157a140f6e29>) :client-certificate t :use-starttls-if-possible t))
  network-stream-open-starttls("smtpmail" #<buffer *trace of SMTP session to smtp.server.com*> "smtp.server.com" 587 (:type nil :return-list t :warn-unless-encrypted nil :capability-command "EHLO slate\15\n" :end-of-command "^[0-9]+ .*\15\n" :success "^2.*\n" :always-query-capabilities t :starttls-function #f(compiled-function (capabilities) #<bytecode 0x157a140f6e29>) :client-certificate t :use-starttls-if-possible t))
  open-network-stream("smtpmail" #<buffer *trace of SMTP session to smtp.server.com*> "smtp.server.com" 587 :type nil :return-list t :warn-unless-encrypted nil :capability-command "EHLO slate\15\n" :end-of-command "^[0-9]+ .*\15\n" :success "^2.*\n" :always-query-capabilities t :starttls-function #f(compiled-function (capabilities) #<bytecode 0x157a140f6e29>) :client-certificate t :use-starttls-if-possible t)
  smtpmail-via-smtp(("foo@bar.com") #<buffer  smtpmail temp>)
  smtpmail-send-it()
  message-use-send-mail-function()
  message--default-send-mail-function()
  message-multi-smtp-send-mail()
  message--send-mail-maybe-partially()
  message-send-mail(nil)
  message-send-via-mail(nil)
  message-send(nil)
  message-send-and-exit(nil)
  funcall-interactively(message-send-and-exit nil)
  call-interactively(message-send-and-exit nil nil)
  command-execute(message-send-and-exit)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-auth-source-password-lookup.patch --]
[-- Type: text/x-diff, Size: 1070 bytes --]

From 92942fc012b96240c908834add932f4a551ab883 Mon Sep 17 00:00:00 2001
From: Alex Murray <alex.murray@canonical.com>
Date: Mon, 25 Nov 2019 22:18:07 +1030
Subject: [PATCH] Fix auth-source password lookup

* lisp/net/network-stream.el
(network-stream-certificate): Ensure :port is specified as a string to
'auth-source-search'.

Copyright-paperwork-exempt: yes
---
 lisp/net/network-stream.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lisp/net/network-stream.el b/lisp/net/network-stream.el
index 9a796d93ab..3227458f8a 100644
--- a/lisp/net/network-stream.el
+++ b/lisp/net/network-stream.el
@@ -228,7 +228,9 @@ gnutls-boot (as returned by `gnutls-boot-parameters')."
       (let* ((auth-info
 	      (car (auth-source-search :max 1
 				       :host host
-				       :port service)))
+				       :port (if (numberp service)
+						 (number-to-string service)
+					       service))))
 	     (key (plist-get auth-info :key))
 	     (cert (plist-get auth-info :cert)))
 	(and key cert (file-readable-p key) (file-readable-p cert)
-- 
2.20.1


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

* bug#38371: 27.0.50; network-stream-certificate fails to specify :port as a string for auth-source-search
  2019-11-25 11:50 bug#38371: 27.0.50; network-stream-certificate fails to specify :port as a string for auth-source-search Alex Murray
@ 2019-11-26  8:30 ` Robert Pluim
  2019-11-26 10:43   ` Michael Albinus
  2019-11-26 11:04   ` Alex Murray
  0 siblings, 2 replies; 5+ messages in thread
From: Robert Pluim @ 2019-11-26  8:30 UTC (permalink / raw)
  To: Alex Murray; +Cc: 38371

tags 38371 fixed
close 38371 27.1
quit

>>>>> On Mon, 25 Nov 2019 22:20:02 +1030, Alex Murray <alex.murray@canonical.com> said:

    Alex> Sending mail via SMTP in Emacs 27.0.50 fails when using the secrets
    Alex> auth-source backend - this seems to be due to network-stream-certificate
    Alex> calling auth-source-search with :port specified as an integer - since
    Alex> then later auth-source-secrets-listify-pattern fails with the following
    Alex> backtrace as it seems to expect all parameters to be strings.

    Alex> Attached is a patch to resolve this, in the same way bug#20541 was
    Alex> solved previously.

Thanks for the patch, pushed (with a slight modification, plus I added
the Bug# to the commit message).

    Alex> I wonder however if it might just be better to make
    Alex> auth-source-secrets-listify-pattern smarter to handle numeric elements

Maybe. But this is enough for now (and the recent flipping of the
default of network-stream-use-client-certificates would hide it
anyway).

Robert





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

* bug#38371: 27.0.50; network-stream-certificate fails to specify :port as a string for auth-source-search
  2019-11-26  8:30 ` Robert Pluim
@ 2019-11-26 10:43   ` Michael Albinus
  2019-11-26 10:54     ` Robert Pluim
  2019-11-26 11:04   ` Alex Murray
  1 sibling, 1 reply; 5+ messages in thread
From: Michael Albinus @ 2019-11-26 10:43 UTC (permalink / raw)
  To: Robert Pluim; +Cc: Alex Murray, 38371

Robert Pluim <rpluim@gmail.com> writes:

Hi,

>     Alex> I wonder however if it might just be better to make
>     Alex> auth-source-secrets-listify-pattern smarter to handle
>     Alex> numeric elements
>
> Maybe. But this is enough for now (and the recent flipping of the
> default of network-stream-use-client-certificates would hide it
> anyway).

Integer values for :port are not foreseen, see the docstring of
`auth-source-search':

--8<---------------cut here---------------start------------->8---
A string value is always matched literally.  A symbol is matched
as its string value, literally.  All the SPEC values can be
single values (symbol or string) or lists thereof (in which case
any of the search terms matches).
--8<---------------cut here---------------end--------------->8---

> Robert

Best regards, Michael.





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

* bug#38371: 27.0.50; network-stream-certificate fails to specify :port as a string for auth-source-search
  2019-11-26 10:43   ` Michael Albinus
@ 2019-11-26 10:54     ` Robert Pluim
  0 siblings, 0 replies; 5+ messages in thread
From: Robert Pluim @ 2019-11-26 10:54 UTC (permalink / raw)
  To: Michael Albinus; +Cc: Alex Murray, 38371

>>>>> On Tue, 26 Nov 2019 11:43:40 +0100, Michael Albinus <michael.albinus@gmx.de> said:

    Michael> Integer values for :port are not foreseen, see the docstring of
    Michael> `auth-source-search':

    Michael> A string value is always matched literally.  A symbol is matched
    Michael> as its string value, literally.  All the SPEC values can be
    Michael> single values (symbol or string) or lists thereof (in which case
    Michael> any of the search terms matches).

Right, which is why Alex's patch was the right thing to do.

Robert





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

* bug#38371: 27.0.50; network-stream-certificate fails to specify :port as a string for auth-source-search
  2019-11-26  8:30 ` Robert Pluim
  2019-11-26 10:43   ` Michael Albinus
@ 2019-11-26 11:04   ` Alex Murray
  1 sibling, 0 replies; 5+ messages in thread
From: Alex Murray @ 2019-11-26 11:04 UTC (permalink / raw)
  To: Robert Pluim; +Cc: 38371


On Tue, 2019-11-26 at 19:00:33 +1030, Robert Pluim wrote:

>
> Thanks for the patch, pushed (with a slight modification, plus I added
> the Bug# to the commit message).

Thanks!





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

end of thread, other threads:[~2019-11-26 11:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-11-25 11:50 bug#38371: 27.0.50; network-stream-certificate fails to specify :port as a string for auth-source-search Alex Murray
2019-11-26  8:30 ` Robert Pluim
2019-11-26 10:43   ` Michael Albinus
2019-11-26 10:54     ` Robert Pluim
2019-11-26 11:04   ` Alex Murray

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).