Subject: bug#22188: 24.5; auth-source-search ignores netrc entries with port set

From: Eli Zaretskii <[email-masked]>
Date: Thu, 17 Dec 2015 20:36:55 +0200

> From: Alexey Veretennikov <[email-masked]>
> Date: Wed, 16 Dec 2015 21:42:26 +0100
> 
> The auth-source-search function ignores .authinfo entries which contains
> port if port is not specified in the search.
> 
> Steps to reproduce:
> 
> 1) Create a file "~/test.authinfo" with the following contents:
> machine mymachine1 login user1 password pass1
> machine mymachine2 login user2 password pass2 port 100
> machine mymachine3 login user3 password pass3
> machine mymachine4 login user4 password pass4 port 200
> 
> 2) Perform in *scratch* buffer to set this file as a auth source
> (require 'auth-source)
> (auth-source-forget-all-cached)
> (setq auth-sources '("~/test.authinfo"))
> 
> 3) Run the following:
> (dolist (account (auth-source-search))
>   (print (plist-get account :host)))
> 
> Output:
> "mymachine1"
> 
> "mymachine3"
> nil
> 
> 4) Run the following:
> 
> (dolist (account (auth-source-search :port 100))
>   (print (plist-get account :host)))
> 
> 
> Output:
> "mymachine1"
> 
> "mymachine2"
> 
> "mymachine3"
> nil
> 
> 5) Run the following:
> 
> (dolist (account (auth-source-search :port 200))
>   (print (plist-get account :host)))
> 
> "mymachine1"
> 
> "mymachine3"
> 
> "mymachine4"
> nil
> 
> 
> Expected result:
> In step 2 the auth-source-search function should return all 4 machines

Technically, you cannot expect more than 1 result, if you don't
specify :max (it defaults to 1).  But that doesn't mean the bug you
report isn't real: it is.  What happened was that the function that
parsed the netrc entries would reject any entry which had a port
specified.

This is now fixed on the emacs-25 branch, in commit 9384953.

Lars, I hope it's okay to fix something in Gnus in the Emacs
repository?  I assume you will synchronize with your repo.

Thanks.