Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite recursion when opening file via "/ssh:host|sudo:host:" #244

Closed
iskur opened this issue Oct 28, 2019 · 5 comments
Closed

Infinite recursion when opening file via "/ssh:host|sudo:host:" #244

iskur opened this issue Oct 28, 2019 · 5 comments
Labels
bug Something isn't working

Comments

@iskur
Copy link

iskur commented Oct 28, 2019

Describe
Upon opening a file with tramp's ad-hoc multihop feature, emacs enters an infinite recursion.

Steps and Expected
I started emacs with emacs -Q and evaluated the following code:

(require 'package)
(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
                    (not (gnutls-available-p))))
       (proto (if no-ssl "http" "https")))
  (when no-ssl
    (warn "\
Your version of Emacs does not support SSL connections,
which is unsafe because it allows man-in-the-middle attacks.
There are two things you can do about this warning:
1. Install an Emacs version that does support SSL and be safe.
2. Remove this warning from your init file so you won't see it again."))
  ;; Comment/uncomment these two lines to enable/disable MELPA and MELPA Stable as desired
  (add-to-list 'package-archives (cons "melpa" (concat proto "://melpa.org/packages/")) t)
  ;;(add-to-list 'package-archives (cons "melpa-stable" (concat proto "://stable.melpa.org/packages/")) t)
  (when (< emacs-major-version 24)
    ;; For important compatibility libraries like cl-lib
    (add-to-list 'package-archives (cons "gnu" (concat proto "://elpa.gnu.org/packages/")))))
(package-initialize)
(package-install 'doom-modeline)
(require 'doom-modeline)
(doom-modeline-mode 1)
(find-file "/ssh:cubox|sudo:cubox:/root/.zshrc")

I expect the file to be opened.

Environment:

  • ArchLinux
  • GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.12, cairo version 1.17.3)
  • doom-modeline 20191027.1850

Additional context
Traceback from enabling toggle-debug-on-quit and hitting C-g:

Debugger entered--Lisp error: (quit "nil")
  signal(quit ("nil"))
  tramp-signal-hook-function(quit nil)
  get-buffer-create(" *temp*-665421")
  #f(compiled-function (name) "Create and return a buffer with a name based on NAME.\nChoose the buffer's name using `generate-new-buffer-name'." #<bytecode 0x1fdea9f7f729>)(" *temp*")
  apply(#f(compiled-function (name) "Create and return a buffer with a name based on NAME.\nChoose the buffer's name using `generate-new-buffer-name'." #<bytecode 0x1fdea9f7f729>) " *temp*")
  generate-new-buffer(" *temp*")
  format-spec("ssh:cubox|" ((104 . "cubox") (117 . #("root" 0 4 (tramp-default t)))))
  tramp-dissect-file-name(#("/ssh:cubox|sudo:root@cubox:/root/.bash_history" 16 20 (tramp-default t)))
  tramp-file-name-handler(expand-file-name #("/ssh:cubox|sudo:root@cubox:/root/.bash_history" 16 20 (tramp-default t)) nil)
  file-exists-p(#("/ssh:cubox|sudo:root@cubox:/root/.bash_history" 16 20 (tramp-default t)))
  doom-modeline-update-buffer-file-state-icon(" *temp*")
  apply(doom-modeline-update-buffer-file-state-icon " *temp*")
  generate-new-buffer(" *temp*")
...
  generate-new-buffer(" *temp*")
  format-spec("ssh:cubox|" ((104 . "cubox") (117 . #("root" 0 4 (tramp-default t)))))
  tramp-dissect-file-name(#("/ssh:cubox|sudo:root@cubox:/root/.bash_history" 16 20 (tramp-default t)))
  tramp-file-name-handler(expand-file-name #("/ssh:cubox|sudo:root@cubox:/root/.bash_history" 16 20 (tramp-default t)) nil)
  file-exists-p(#("/ssh:cubox|sudo:root@cubox:/root/.bash_history" 16 20 (tramp-default t)))
  doom-modeline-update-buffer-file-state-icon(" *temp*")
  apply(doom-modeline-update-buffer-file-state-icon " *temp*")
  generate-new-buffer(" *temp*")
  format-spec("ssh:cubox|" ((104 . "cubox") (117 . #("root" 0 4 (tramp-default t)))))
  tramp-dissect-file-name(#("/ssh:cubox|sudo:root@cubox:/root/.bash_history" 16 20 (tramp-default t)))
  tramp-file-name-handler(file-remote-p #("/ssh:cubox|sudo:root@cubox:/root/.bash_history" 16 20 (tramp-default t)) nil connected)
  file-remote-p(#("/ssh:cubox|sudo:root@cubox:/root/.bash_history" 16 20 (tramp-default t)) nil connected)
  tramp-sh-handle-verify-visited-file-modtime(#<buffer .bash_history>)
  apply(tramp-sh-handle-verify-visited-file-modtime #<buffer .bash_history>)
  tramp-sh-file-name-handler(verify-visited-file-modtime #<buffer .bash_history>)
  apply(tramp-sh-file-name-handler verify-visited-file-modtime #<buffer .bash_history>)
  tramp-file-name-handler(verify-visited-file-modtime #<buffer .bash_history>)
  verify-visited-file-modtime(#<buffer .bash_history>)
  find-file-noselect("/ssh:cubox|sudo:cubox:/root/.bash_history" nil nil nil)
  find-file("/ssh:cubox|sudo:cubox:/root/.bash_history")
  eval-buffer()  ; Reading at buffer position 1138
  funcall-interactively(eval-buffer)
  call-interactively(eval-buffer record nil)
  command-execute(eval-buffer record)
  execute-extended-command(nil "eval-buffer" "eval-bu")
  funcall-interactively(execute-extended-command nil "eval-buffer" "eval-bu")
  call-interactively(execute-extended-command nil nil)
  command-execute(execute-extended-command)

Edit: replaced the traceback with one from the minimal example and added `package-install 'doom-modeline) there.

@seagle0128
Copy link
Owner

Did you just try (find-file "/ssh:cubox|sudo:cubox:/root/.zshrc") in emacs -Q? I couldn't run it, either.

@iskur
Copy link
Author

iskur commented Oct 28, 2019

Yes, that works in emacs -Q without doom-modeline for me. You have to replace cubox with a hostname of a machine you have ssh-access to.

@seagle0128
Copy link
Owner

seagle0128 commented Oct 28, 2019

I can run (find-file "/ssh:cubox@cubox:/root/.zshrc"). Can you try it?

I cannot run it using sudo in emacs -Q.

Tramp: Opening connection for root@192.168.31.1 using sudo...failed

@iskur
Copy link
Author

iskur commented Oct 28, 2019

Using just a single hop in the form "/ssh:user@host:/somefile" works with doom-modeline (I checked it again). Only when doing a multihop like "/ssh:user@host|sudo:host:/somefile" the above infinite recursion occurs.

Multihop is really useful when doing sysadmin work. I can disable root-login at the server, but still edit there as root with emacs running locally.

Might it be the pipe character | that causes problems here?

@iskur
Copy link
Author

iskur commented Oct 29, 2019

I cannot run it using sudo in emacs -Q.

Tramp: Opening connection for root@192.168.31.1 using sudo...failed

It might be helpful to increase verbosity with (setq tramp-verbose 9) and take a look at the respective tramp buffer.
Or have you tried ssh-ing into 192.168.31.1 with a terminal?

@seagle0128 seagle0128 added the bug Something isn't working label Oct 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants