GNU bug report logs - #27009
Tramp doesn't distinguish between connections differing only by port number

Previous Next

Package: emacs;

Reported by: "Devon Sean McCullough" <Emacs-Hacker2017 <at> jovi.net>

Date: Sun, 21 May 2017 16:12:03 UTC

Severity: normal

Tags: confirmed

Found in version 25.1

Fixed in version 26.1

Done: Michael Albinus <michael.albinus <at> gmx.de>

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 27009 in the body.
You can then email your comments to 27009 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#27009; Package emacs. (Sun, 21 May 2017 16:12:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Devon Sean McCullough" <Emacs-Hacker2017 <at> jovi.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 21 May 2017 16:12:03 GMT) Full text and rfc822 format available.

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

From: "Devon Sean McCullough" <Emacs-Hacker2017 <at> jovi.net>
To: bug-gnu-emacs <at> gnu.org
Subject: 25.1; Tramp stuck on wrong host
Date: Sun, 21 May 2017 05:12:07 -0500
Tramp connects to the wrong host -- the user may not notice, leading to
devastating damage.

To replicate this bug, have two different systems serve SSH on different
ports of the same IP address,
e.g., In VBox, map local host ports 11111 and 22222 respectively to two
different guest systems:
VirtualBox VM > Devices > Network > Network Settings ... > Adapter 1 >
  Attached to: NAT
  Advanced > Port Forwarding >
    Host Port: 11111 for system one, 22222 for system two
    Guest Port: 22

bash$ Open -n -a /Applications/Emacs.app --args -Q --eval '
(message "Emacs %s tramp bug %s" ; t = bug, nil = ok
	 emacs-version
	 (let ((one "/scp:127.0.0.1#11111:")
	       (two "/scp:127.0.0.1#22222:"))
	   (delete-other-windows)
	   (dired one)
	   (revert-buffer)
	   (split-window)
	   (other-window 1)
	   (dired two)
	   (revert-buffer)
	   (apply (function string=)
		  (mapcar (lambda (w)
			    (with-current-buffer (window-buffer w)
			      (buffer-substring (save-excursion
						  (goto-char (point-min))
						  (forward-line 1)
						  (point))
						(point-max))))
			  (window-list-1)))))'

		Peace
			--Devon

P.S. (tramp-cleanup-all-connections) ; fails to fix it but can switch
which host is wrong.

In GNU Emacs 25.1.1 (x86_64-apple-darwin13.4.0, NS appkit-1265.21 Version
10.9.5 (Build 13F1911))
 of 2016-09-21 built on builder10-9.porkrind.org
Windowing system distributor 'Apple', version 10.3.1404
Configured using:
 'configure --with-ns '--enable-locallisppath=/Library/Application
 Support/Emacs/${version}/site-lisp:/Library/Application
 Support/Emacs/site-lisp' --with-modules'

Configured features:
NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS MODULES

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

Major mode: Dired by name

Minor modes in effect:
  shell-dirtrack-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  line-number-mode: t
  transient-mark-mode: t

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Tramp: Opening connection for 127.0.0.1#11111 using scp...
Tramp: Sending command ‘exec ssh  -p 11111 -o ControlMaster=auto -o
ControlPath='tramp.%C' -o ControlPersist=no -e none 127.0.0.1’
Tramp: Waiting for prompts from remote shell...done
Tramp: Found remote shell prompt on ‘127.0.0.1’
Tramp: Opening connection for 127.0.0.1#11111 using scp...done
ls does not support --dired; see ‘dired-use-ls-dired’ for more details.
Emacs 25.1.1 tramp bug t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rfc822 mml mml-sec epg
epg-config mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev
gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mail-utils
tramp-cache tramp-sh tramp tramp-compat auth-source cl-seq eieio
byte-opt bytecomp byte-compile cl-extra cconv eieio-core cl-macs gv
gnus-util mm-util help-fns help-mode easymenu cl-loaddefs pcase cl-lib
mail-prsvr password-cache tramp-loaddefs trampver shell pcomplete comint
ansi-color ring format-spec advice dired time-date mule-util tooltip
eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel
ns-win ucs-normalize term/common-win tool-bar dnd fontset image
regexp-opt fringe tabulated-list newcomment elisp-mode lisp-mode
prog-mode register page menu-bar rfn-eshadow timer select scroll-bar
mouse jit-lock font-lock syntax facemenu font-core frame cl-generic cham
georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese charscript case-table epa-hook
jka-cmpr-hook help simple abbrev minibuffer cl-preloaded 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 kqueue cocoa ns multi-tty
make-network-process emacs)

Memory information:
((conses 16 216764 9018)
 (symbols 48 22062 0)
 (miscs 40 59 298)
 (strings 32 24033 6626)
 (string-bytes 1 768617)
 (vectors 16 36983)
 (vector-slots 8 706708 7377)
 (floats 8 283 52)
 (intervals 56 539 0)
 (buffers 976 20))





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27009; Package emacs. (Mon, 22 May 2017 12:04:02 GMT) Full text and rfc822 format available.

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

From: Michael Albinus <michael.albinus <at> gmx.de>
To: "Devon Sean McCullough" <Emacs-Hacker2017 <at> jovi.net>
Cc: 27009 <at> debbugs.gnu.org
Subject: Re: bug#27009: 25.1; Tramp stuck on wrong host
Date: Mon, 22 May 2017 14:03:19 +0200
"Devon Sean McCullough" <Emacs-Hacker2017 <at> jovi.net> writes:

Hi Davon,

> Tramp connects to the wrong host -- the user may not notice, leading to
> devastating damage.

Tramp is almost agnostic to port numbers. It uses them for the command
raised for connecting, but everywhere else it ignores them. This happens
especially in managing internal data, like the name of the connection
buffer or access to cached values.

As a result, two remote file names are handled as identical if they
differ only in their port numbers. See also the todo entry in tramp.el:

;; * Use also port to distinguish connections.  This is needed for
;;   different hosts sitting behind a single router (distinguished by
;;   different port numbers).  (Tzvi Edelman)

I know, this is not satisfying. If time permits, I'll work on this next
time. Unfortunately, there's no trivial fix.

As a workaround, use different host names. In your example, you could
use something like

(let ((one "/scp:localhost#11111:")
      (two "/scp:localhost.#22222:"))

Name resolution for "localhost" and "localhost." will return the same IP
address. But from the Tramp pov, the host names are different strings.

Best regards, Michael.




Changed bug title to 'Tramp doesn't distinguish between connections differing only by port number' from '25.1; Tramp stuck on wrong host' Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Mon, 22 May 2017 12:16:01 GMT) Full text and rfc822 format available.

Added tag(s) confirmed. Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Mon, 22 May 2017 12:16:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27009; Package emacs. (Wed, 24 May 2017 14:29:02 GMT) Full text and rfc822 format available.

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

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Devon Sean McCullough <devon <at> csail.mit.edu>
Cc: 27009 <at> debbugs.gnu.org
Subject: Re: bug#27009: 25.1; Tramp stuck on wrong host
Date: Wed, 24 May 2017 16:28:09 +0200
Michael Albinus <michael.albinus <at> gmx.de> writes:

Hi Devon,

> I plan to reserve an own slot for the port in the tramp-file-name
> vector. Maybe even converting this to a defstruct. This would be
> future-proof, and it should show immediately the places I have missed to
> change.

I took the opportunity to implement this. Now, the bug is fixed.

If you have any chance to test the development version of Emacs (the
upcoming 26.1 release), you could crosscheck this.

Due to the new defstruct and its mechanery, I had to cut Emacs 23
backward compatibility for Tramp 2.3. I don't know how many users are
hit by this; hopefully not too many.

> But this will be a more complex change.

With the default settings for tramp-tests.el, all test cases pass. But
for some other methods, there are still failures. Will continue to test.

>> 		Peace
>> 			—Devon

Best regards, Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27009; Package emacs. (Wed, 24 May 2017 17:24:02 GMT) Full text and rfc822 format available.

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

From: Glenn Morris <rgm <at> gnu.org>
To: Michael Albinus <michael.albinus <at> gmx.de>
Cc: 27009 <at> debbugs.gnu.org, Devon Sean McCullough <devon <at> csail.mit.edu>
Subject: Re: bug#27009: 25.1; Tramp stuck on wrong host
Date: Wed, 24 May 2017 13:22:59 -0400
Michael Albinus wrote:

> Due to the new defstruct and its mechanery, I had to cut Emacs 23
> backward compatibility for Tramp 2.3. I don't know how many users are
> hit by this; hopefully not too many.

In 2016, we had one bug report from an Emacs 23 user.

https://debbugs.gnu.org/stats/emacs.html

So, I would guess that the number of people using Emacs 23 AND
upgrading to the latest Tramp version is... zero.

> With the default settings for tramp-tests.el, all test cases pass. But
> for some other methods, there are still failures. Will continue to test.

FYI, I think these changes cause some python tests to fail with

  (wrong-type-argument tramp-file-name nil)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27009; Package emacs. (Wed, 24 May 2017 20:32:01 GMT) Full text and rfc822 format available.

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

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 27009 <at> debbugs.gnu.org, Devon Sean McCullough <devon <at> csail.mit.edu>
Subject: Re: bug#27009: 25.1; Tramp stuck on wrong host
Date: Wed, 24 May 2017 22:31:07 +0200
Glenn Morris <rgm <at> gnu.org> writes:

> FYI, I think these changes cause some python tests to fail with
>
>   (wrong-type-argument tramp-file-name nil)

Shall be fixed now in master.

Best regards, Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27009; Package emacs. (Wed, 07 Jun 2017 14:27:01 GMT) Full text and rfc822 format available.

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

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Devon Sean McCullough <devon <at> csail.mit.edu>
Cc: Glenn Morris <rgm <at> gnu.org>, 27009 <at> debbugs.gnu.org
Subject: Re: bug#27009: 25.1; Tramp stuck on wrong host
Date: Wed, 07 Jun 2017 16:26:18 +0200
Devon Sean McCullough <devon <at> csail.mit.edu> writes:

Hi Devon,

> In the current nightly build, tramp fails to tell ssh to connect to
> the user-specified port so it tries default port 22 instead.

Oops, yes. Should be fixed now.

> 		Peace
> 			--Devon

Best regards, Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27009; Package emacs. (Wed, 07 Jun 2017 15:25:02 GMT) Full text and rfc822 format available.

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

From: Devon Sean McCullough <devon <at> csail.mit.edu>
To: Michael Albinus <michael.albinus <at> gmx.de>
Cc: Glenn Morris <rgm <at> gnu.org>, 27009 <at> debbugs.gnu.org
Subject: Re: bug#27009: 25.1; Tramp stuck on wrong host
Date: Wed, 7 Jun 2017 20:41:44 +0800
[Message part 1 (text/plain, inline)]
In the current nightly build, tramp fails to tell ssh to connect to the user-specified port
so it tries default port 22 instead.  Am I missing something really obvious here?

		Peace
			--Devon

bash$ Open -n -a /Applications/Emacs-2017f07w.app --args --no-init-file --no-site-file --no-site-lisp --eval '(dired "/scp:127.0.0.1#2222:”)’

ssh: connect to host 127.0.0.1 port 22: Connection Refused^M

U:**@  *tramp/scp 127.0.0.1#2222*  All  L2     (Fundamental)

In GNU Emacs 26.0.50 (build 1, x86_64-apple-darwin13.4.0, NS appkit-1265.21 Version 10.9.5 (Build 13F1911))
 of 2017-06-07 built on builder10-9.local
Windowing system distributor 'Apple', version 10.3.1404
Recent messages:

For information about GNU Emacs and the GNU system, type C-h C-a.
Tramp: Opening connection for 127.0.0.1 using scp...
Tramp: Sending command ‘exec ssh   -o ControlMaster=auto -o ControlPath='tramp.%C' -o ControlPersist=no -e none 127.0.0.1’
Tramp: Waiting for prompts from remote shell...
Tramp failed to connect.  If this happens repeatedly, try
    ‘M-x tramp-cleanup-this-connection’
Tramp: Waiting for prompts from remote shell...failed
Tramp: Opening connection for 127.0.0.1 using scp...failed
tramp-file-name-handler: Tramp failed to connect.  If this happens repeatedly, try
    ‘M-x tramp-cleanup-this-connection’
Configured using:
 'configure --with-ns '--enable-locallisppath=/Library/Application
 Support/Emacs/${version}/site-lisp:/Library/Application
 Support/Emacs/site-lisp' --with-modules'

Configured features:
NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS MODULES

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

Major mode: Lisp Interaction

Minor modes in effect:
  shell-dirtrack-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message subr-x puny seq rfc822 mml
easymenu mml-sec epa derived epg epg-config gnus-util rmail
rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils tramp-cmds tramp-cache tramp-sh tramp
tramp-compat tramp-loaddefs trampver shell pcomplete comint ansi-color
ring parse-time format-spec advice auth-source cl-seq eieio byte-opt
bytecomp byte-compile cconv eieio-core cl-macs gv eieio-loaddefs
cl-loaddefs cl-lib password-cache dired dired-loaddefs time-date tooltip
eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel
term/ns-win ns-win ucs-normalize mule-util term/common-win tool-bar dnd
fontset image regexp-opt fringe tabulated-list replace newcomment
text-mode elisp-mode lisp-mode prog-mode register page menu-bar
rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core term/tty-colors frame cl-generic cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese composite charscript charprop
case-table epa-hook jka-cmpr-hook help simple abbrev obarray minibuffer
cl-preloaded 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 kqueue cocoa ns
multi-tty make-network-process emacs)

Memory information:
((conses 16 218715 4885)
 (symbols 48 21515 1)
 (miscs 40 46 164)
 (strings 32 25033 7176)
 (string-bytes 1 865927)
 (vectors 16 38152)
 (vector-slots 8 729944 4504)
 (floats 8 65 283)
 (intervals 56 203 0)
 (buffers 976 12))

[smime.p7s (application/pkcs7-signature, attachment)]

Reply sent to Michael Albinus <michael.albinus <at> gmx.de>:
You have taken responsibility. (Fri, 14 Jul 2017 13:20:02 GMT) Full text and rfc822 format available.

Notification sent to "Devon Sean McCullough" <Emacs-Hacker2017 <at> jovi.net>:
bug acknowledged by developer. (Fri, 14 Jul 2017 13:20:02 GMT) Full text and rfc822 format available.

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

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Devon Sean McCullough <devon <at> csail.mit.edu>
Cc: Glenn Morris <rgm <at> gnu.org>, 27009-done <at> debbugs.gnu.org
Subject: Re: bug#27009: 25.1; Tramp stuck on wrong host
Date: Fri, 14 Jul 2017 15:19:07 +0200
Version: 26.1

Michael Albinus <michael.albinus <at> gmx.de> writes:

Hi Devon,

>> In the current nightly build, tramp fails to tell ssh to connect to
>> the user-specified port so it tries default port 22 instead.
>
> Oops, yes. Should be fixed now.

No further (negative) feedback, so I'm closing the bug.

>> 		Peace
>> 			--Devon

Best regards, Michael.




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

This bug report was last modified 6 years and 258 days ago.

Previous Next


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