unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "João Távora" <joaotavora@gmail.com>
To: 38284@debbugs.gnu.org
Cc: Damien Cassou <damien@cassou.me>, Nicolas Petton <nicolas@petton.fr>
Subject: bug#38284: 27.0.50; [PATCH] Make auth-source-pass-search understand port lists
Date: Wed, 20 Nov 2019 00:20:28 +0000	[thread overview]
Message-ID: <87ftijz9df.fsf@gmail.com> (raw)

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

Hi,

When trying to follow along a tutorial on setting up Gnus for GMAIL, I
tried to use auth-source-pass.el to access encrypted entries under
~/.password-store instead of the usual ~/.authinfo.gpg.

After much wrestling with the system, I couldn't figure out why my
entry:

   gmail:imap.gpg

whose contents are

   NotReallyThePassword
   host: imap.gmail.com
   user: joaotavora@gmail.com
   port: 993

weren't being understood by the new auth-source.  Eventually I came to
this patch, which seems to do the right thing.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Make-auth-source-pass-search-understand-port-lists.patch --]
[-- Type: text/x-diff, Size: 1837 bytes --]

From 4a6c24c23c9f7097807c1ef58688b51db330f503 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jo=C3=A3o=20T=C3=A1vora?= <joaotavora@gmail.com>
Date: Wed, 20 Nov 2019 00:11:00 +0000
Subject: [PATCH] Make auth-source-pass-search understand port lists

For cases such as a typical IMAP Gnus setup, auto-source-pass-search
will be passed a list of "port aliases" like (993 "imaps" "imap" "993"
"143") in hopes of finding a matching ~/.password-store entry.

This modification makes this library understand and unroll the port
list so that, i.e. "domain:993", "domain:imaps"", "domain:imap",
etc. are computed as potential suffixes.  Previously a nonsensical
string "domain:(993 imaps imap ...)" was return.

* lisp/auth-source-pass.el
(auth-source-pass--generate-entry-suffixes): Allow PORT to
be a list of ports.
---
 lisp/auth-source-pass.el | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/lisp/auth-source-pass.el b/lisp/auth-source-pass.el
index 524a72792c..cc0a6fe4de 100644
--- a/lisp/auth-source-pass.el
+++ b/lisp/auth-source-pass.el
@@ -269,10 +269,15 @@ auth-source-pass--generate-entry-suffixes
 
 Based on the supported pathname patterns for HOSTNAME, USER, &
 PORT, return a list of possible suffixes for matching entries in
-the password-store."
+the password-store.
+
+PORT may be a list of ports."
   (let ((domains (auth-source-pass--domains (split-string hostname "\\."))))
-    (seq-mapcat (lambda (n)
-                  (auth-source-pass--name-port-user-suffixes n user port))
+    (seq-mapcat (lambda (d)
+                  (seq-mapcat
+                   (lambda (p)
+                     (auth-source-pass--name-port-user-suffixes d user p))
+                   (if (listp port) port (list port))))
                 domains)))
 
 (defun auth-source-pass--domains (name-components)
-- 
2.24.0


[-- Attachment #3: Type: text/plain, Size: 34 bytes --]


Please have a look,
João



             reply	other threads:[~2019-11-20  0:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-20  0:20 João Távora [this message]
2019-11-21 13:47 ` bug#38284: 27.0.50; [PATCH] Make auth-source-pass-search understand port lists Lars Ingebrigtsen
2019-11-21 18:27 ` Damien Cassou
2019-11-21 19:06   ` João Távora
2019-11-22  8:49     ` Damien Cassou
2019-11-22  9:35       ` João Távora
2020-01-20 18:54         ` Stefan Kangas
2020-01-21 19:25           ` Damien Cassou
2020-01-22  8:02             ` Stefan Kangas
2020-01-22  9:22               ` Damien Cassou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ftijz9df.fsf@gmail.com \
    --to=joaotavora@gmail.com \
    --cc=38284@debbugs.gnu.org \
    --cc=damien@cassou.me \
    --cc=nicolas@petton.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).