GNU bug report logs - #22188
24.5; auth-source-search ignores netrc entries with port set

Previous Next

Package: emacs;

Reported by: Alexey Veretennikov <alexey.veretennikov <at> gmail.com>

Date: Wed, 16 Dec 2015 20:51:02 UTC

Severity: normal

Found in version 24.5

Done: Ted Zlatanov <tzz <at> lifelogs.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 22188 in the body.
You can then email your comments to 22188 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#22188; Package emacs. (Wed, 16 Dec 2015 20:51:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Alexey Veretennikov <alexey.veretennikov <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 16 Dec 2015 20:51:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Alexey Veretennikov <alexey.veretennikov <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.5; auth-source-search ignores netrc entries with port set
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
In step 3 the auth-source-search function should return only machine2
In step 4 the auth-source-search function should return only machine4


==================

In GNU Emacs 24.5.1 (x86_64-apple-darwin14.5.0)
 of 2015-08-27 on tenten-slave.macports.org
Configured using:
 `configure --prefix=/opt/local --without-x --without-dbus
 --without-gconf --without-libotf --without-m17n-flt --without-gpm
 --without-gnutls --with-xml2 --infodir /opt/local/share/info/emacs
 'CFLAGS=-pipe -Os -arch x86_64' CPPFLAGS=-I/opt/local/include
 'LDFLAGS=-L/opt/local/lib -Wl,-headerpad_max_install_names -Wl,-no_pie
 -arch x86_64''

Important settings:
  value of $LC_ALL: en_US.UTF-8
  value of $LC_CTYPE: en_US.UTF-8
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  electric-indent-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent messages:
Entering debugger...
Back to top level.
auth-source
nil
("~/test.authinfo")
Mark set
current-kill: Kill ring is empty
Mark set
current-kill: Kill ring is empty
Mark set
current-kill: Kill ring is empty

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message format-spec rfc822 mml mml-sec
mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils
mailheader sendmail regexp-opt rfc2047 rfc2045 ietf-drums mail-utils
auth-source eieio byte-opt bytecomp byte-compile cl-extra cl-loaddefs
cl-lib cconv eieio-core gnus-util mm-util help-fns mail-prsvr
password-cache help-mode easymenu debug xterm time-date tooltip electric
uniquify ediff-hook vc-hooks lisp-float-type tabulated-list newcomment
lisp-mode prog-mode register page menu-bar rfn-eshadow timer select
mouse jit-lock font-lock syntax facemenu font-core frame cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev
minibuffer nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote make-network-process
multi-tty emacs)

Memory information:
((conses 16 85506 4283)
 (symbols 48 18222 0)
 (miscs 40 37 163)
 (strings 32 13562 4449)
 (string-bytes 1 398492)
 (vectors 16 8949)
 (vector-slots 8 352429 16861)
 (floats 8 54 757)
 (intervals 56 262 0)
 (buffers 960 12))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#22188; Package emacs. (Thu, 17 Dec 2015 18:37:01 GMT) Full text and rfc822 format available.

Message #8 received at 22188 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Alexey Veretennikov <alexey.veretennikov <at> gmail.com>
Cc: 22188 <at> debbugs.gnu.org, Lars Magne Ingebrigtsen <larsi <at> gnus.org>
Subject: Re: bug#22188: 24.5;
 auth-source-search ignores netrc entries with port set
Date: Thu, 17 Dec 2015 20:36:55 +0200
> From: Alexey Veretennikov <alexey.veretennikov <at> gmail.com>
> 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.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#22188; Package emacs. (Wed, 23 Dec 2015 16:54:02 GMT) Full text and rfc822 format available.

Message #11 received at 22188 <at> debbugs.gnu.org (full text, mbox):

From: Ted Zlatanov <tzz <at> lifelogs.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 22188 <at> debbugs.gnu.org, Alexey Veretennikov <alexey.veretennikov <at> gmail.com>,
 Lars Magne Ingebrigtsen <larsi <at> gnus.org>
Subject: Re: bug#22188: 24.5;
 auth-source-search ignores netrc entries with port set
Date: Wed, 23 Dec 2015 11:53:18 -0500
On Thu, 17 Dec 2015 20:36:55 +0200 Eli Zaretskii <eliz <at> gnu.org> wrote: 

EZ> What happened was that the function that parsed the netrc entries
EZ> would reject any entry which had a port specified.

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

Thanks for fixing it!

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

Katsumi Yamaoka does the synchronizations bidirectionally. I can confirm
this bugfix was synchronized.

Alexey, can you confirm the bug can be closed?

Thanks
Ted




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#22188; Package emacs. (Thu, 24 Dec 2015 14:24:01 GMT) Full text and rfc822 format available.

Message #14 received at 22188 <at> debbugs.gnu.org (full text, mbox):

From: Alexey Veretennikov <alexey.veretennikov <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>, Ted Zlatanov <tzz <at> lifelogs.com>
Cc: 22188 <at> debbugs.gnu.org, Lars Magne Ingebrigtsen <larsi <at> gnus.org>
Subject: Re: bug#22188: 24.5;
 auth-source-search ignores netrc entries with port set
Date: Thu, 24 Dec 2015 15:22:55 +0100
Hi,

The bug itself is fixed. However the behavior when port specified is
still strange. Given the same test case, the 

(dolist (account (auth-source-search :port 100 :max 999))
  (print (plist-get account :host)))

returns

"mymachine1"

"mymachine2"

"mymachine3"

Therefore all machines without ports and the one with the correct
port. I assume there should be only one result returned, the machine
with the proper port.
More, if we specify the port which doesn't exist in the list:

(dolist (account (auth-source-search :port 150 :max 999))
  (print (plist-get account :host)))

returns

"mymachine1"

"mymachine3"

- all machines without ports in test.authinfo.

Br
/Alexey

Ted Zlatanov <tzz <at> lifelogs.com> writes:

> On Thu, 17 Dec 2015 20:36:55 +0200 Eli Zaretskii <eliz <at> gnu.org> wrote: 
>
> EZ> What happened was that the function that parsed the netrc entries
> EZ> would reject any entry which had a port specified.
>
> EZ> This is now fixed on the emacs-25 branch, in commit 9384953.
>
> Thanks for fixing it!
>
> EZ> Lars, I hope it's okay to fix something in Gnus in the Emacs
> EZ> repository?  I assume you will synchronize with your repo.
>
> Katsumi Yamaoka does the synchronizations bidirectionally. I can confirm
> this bugfix was synchronized.
>
> Alexey, can you confirm the bug can be closed?
>
> Thanks
> Ted




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#22188; Package emacs. (Thu, 24 Dec 2015 15:10:02 GMT) Full text and rfc822 format available.

Message #17 received at 22188 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: Alexey Veretennikov <alexey.veretennikov <at> gmail.com>
Cc: Lars Magne Ingebrigtsen <larsi <at> gnus.org>, Eli Zaretskii <eliz <at> gnu.org>,
 22188 <at> debbugs.gnu.org, Ted Zlatanov <tzz <at> lifelogs.com>
Subject: Re: bug#22188: 24.5;
 auth-source-search ignores netrc entries with port set
Date: Thu, 24 Dec 2015 16:09:41 +0100
Alexey Veretennikov <alexey.veretennikov <at> gmail.com> writes:

> The bug itself is fixed. However the behavior when port specified is
> still strange. Given the same test case, the 
>
> (dolist (account (auth-source-search :port 100 :max 999))
>   (print (plist-get account :host)))
>
> returns
>
> "mymachine1"
>
> "mymachine2"
>
> "mymachine3"
>
> Therefore all machines without ports and the one with the correct
> port. I assume there should be only one result returned, the machine
> with the proper port.

An entry without port is matched by any port.  In general, an absent
specification means any.

Andreas.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




Reply sent to Ted Zlatanov <tzz <at> lifelogs.com>:
You have taken responsibility. (Thu, 24 Dec 2015 15:19:01 GMT) Full text and rfc822 format available.

Notification sent to Alexey Veretennikov <alexey.veretennikov <at> gmail.com>:
bug acknowledged by developer. (Thu, 24 Dec 2015 15:19:01 GMT) Full text and rfc822 format available.

Message #22 received at 22188-done <at> debbugs.gnu.org (full text, mbox):

From: Ted Zlatanov <tzz <at> lifelogs.com>
To: Andreas Schwab <schwab <at> linux-m68k.org>
Cc: Lars Magne Ingebrigtsen <larsi <at> gnus.org>,
 Alexey Veretennikov <alexey.veretennikov <at> gmail.com>,
 22188-done <at> debbugs.gnu.org
Subject: Re: bug#22188: 24.5;
 auth-source-search ignores netrc entries with port set
Date: Thu, 24 Dec 2015 10:18:31 -0500
On Thu, 24 Dec 2015 16:09:41 +0100 Andreas Schwab <schwab <at> linux-m68k.org> wrote: 

AS> An entry without port is matched by any port.  In general, an absent
AS> specification means any.

Exactly :)

The only tricky case is explained in (info "(auth) Help for users")

   The typical netrc line example is without a port.

     machine YOURMACHINE login YOU password YOURPASSWORD

   This will match any authentication port.  Simple, right?  But what if
there’s a SMTP server on port 433 of that machine that needs a different
password from the IMAP server?

     machine YOURMACHINE login YOU password SMTPPASSWORD port 433
     machine YOURMACHINE login YOU password GENERALPASSWORD

I hope that helps. Closing this as done, but please let me know if the
auth-source manual or docstrings need improvement.

Thank you
Ted




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#22188; Package emacs. (Thu, 24 Dec 2015 15:26:02 GMT) Full text and rfc822 format available.

Message #25 received at 22188 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Andreas Schwab <schwab <at> linux-m68k.org>
Cc: 22188 <at> debbugs.gnu.org, Alexey Veretennikov <alexey.veretennikov <at> gmail.com>
Subject: Re: bug#22188: 24.5;
 auth-source-search ignores netrc entries with port set
Date: Thu, 24 Dec 2015 16:25:31 +0100
Ted Zlatanov <tzz <at> lifelogs.com> writes:

>    This will match any authentication port.  Simple, right?  But what if
> there’s a SMTP server on port 433 of that machine that needs a different
> password from the IMAP server?
>
>      machine YOURMACHINE login YOU password SMTPPASSWORD port 433
>      machine YOURMACHINE login YOU password GENERALPASSWORD
>
> I hope that helps. Closing this as done, but please let me know if the
> auth-source manual or docstrings need improvement.

The return values are hopefully sorted by specificity, right?  So the
first entry will be 433 if you specify :port "443" in the auth-source
call?  (And :max 1 will just return that entry...)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#22188; Package emacs. (Thu, 24 Dec 2015 21:03:02 GMT) Full text and rfc822 format available.

Message #28 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ted Zlatanov <tzz <at> lifelogs.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#22188: 24.5;
 auth-source-search ignores netrc entries with port set
Date: Thu, 24 Dec 2015 16:02:00 -0500
On Thu, 24 Dec 2015 16:25:31 +0100 Lars Ingebrigtsen <larsi <at> gnus.org> wrote: 

LI> Ted Zlatanov <tzz <at> lifelogs.com> writes:
>> This will match any authentication port.  Simple, right?  But what if
>> there’s a SMTP server on port 433 of that machine that needs a different
>> password from the IMAP server?
>> 
>> machine YOURMACHINE login YOU password SMTPPASSWORD port 433
>> machine YOURMACHINE login YOU password GENERALPASSWORD
>> 
>> I hope that helps. Closing this as done, but please let me know if the
>> auth-source manual or docstrings need improvement.

LI> The return values are hopefully sorted by specificity, right?  So the
LI> first entry will be 433 if you specify :port "443" in the auth-source
LI> call?  (And :max 1 will just return that entry...)

They are in the order they're found, yes.

Ted





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#22188; Package emacs. (Fri, 25 Dec 2015 20:43:02 GMT) Full text and rfc822 format available.

Message #31 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#22188: 24.5;
 auth-source-search ignores netrc entries with port set
Date: Fri, 25 Dec 2015 21:41:27 +0100
Ted Zlatanov <tzz <at> lifelogs.com> writes:

> LI> The return values are hopefully sorted by specificity, right?  So the
> LI> first entry will be 433 if you specify :port "443" in the auth-source
> LI> call?  (And :max 1 will just return that entry...)
>
> They are in the order they're found, yes.

Ah, so the order of the entries in the .authinfo file matters...

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 23 Jan 2016 12:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 9 years and 153 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.