Tramp cannot access files via sudo

Bug #181399 reported by Phil Sung
22
This bug affects 4 people
Affects Status Importance Assigned to Milestone
emacs-snapshot (Ubuntu)
Opinion
Undecided
Unassigned

Bug Description

Binary package hint: emacs-snapshot

Steps to reproduce:
1. $ emacs -Q
2. C-x C-f /sudo::/etc/apt/sources.list RET

What happens: Emacs hangs with the message "Tramp: Found remote shell prompt on `phil.mit.edu'"

What was expected: Emacs opens the file /etc/apt/sources.list

Revision history for this message
Phil Sung (psung) wrote :

After setting debug-on-quit, I got a backtrace, printed below (sorry, I had trouble copying the special characters in the line which starts with "byte-code").

I've attached the contents of the Tramp debug buffer with `tramp-verbose' set to 6.

Workaround: everything works if I set `tramp-methods' (net/tramp.el) so that sudo uses "/bin/bash --norc" rather than "/bin/sh". It appears that Tramp is doing things that work in bash but not in dash.

----

Backtrace:

Debugger entered--Lisp error: (quit)
  accept-process-output(#<process *tramp/sudo <email address hidden>*> 1 nil)
  byte-code("..." [timeout with-timeout-tag with-timeout-timer with-timeout-timers proc timeout-msecs run-with-timer 1 nil with-timeout-handler accept-process-output with-timeout-value] 6)
  tramp-accept-process-output(#<process *tramp/sudo <email address hidden>*> 1)
  tramp-wait-for-regexp(#<process *tramp/sudo <email address hidden>*> nil "^[^$\n]*///c73bab5635304c1f929c0ec3ee7e6764
?$")
  tramp-wait-for-output(#<process *tramp/sudo <email address hidden>*>)
  tramp-send-command(["sudo" "root" "phil.mit.edu" "/etc/apt/sources.list"] "PROMPT_COMMAND=''; PS1='\n///c73bab5635304c1f929c0ec3ee7e6764\n'; PS2=''; PS3=''" t)
  tramp-open-connection-setup-interactive-shell(#<process *tramp/sudo <email address hidden>*> ["sudo" "root" "phil.mit.edu" "/etc/apt/sources.list"])
  tramp-maybe-open-connection(["sudo" "root" "phil.mit.edu" "/etc/apt/sources.list"])
  tramp-send-command(["sudo" "root" "phil.mit.edu" "/etc/apt/sources.list"] "test 0 2>/dev/null; echo tramp_exit_status $? ")
  tramp-send-command-and-check(["sudo" "root" "phil.mit.edu" "/etc/apt/sources.list"] "test 0")
  tramp-get-test-command(["sudo" "root" "phil.mit.edu" "/etc/apt/sources.list"])
  tramp-run-test("-d" "/sudo:<email address hidden>:/etc/apt/sources.list")
  tramp-handle-file-directory-p("/sudo:<email address hidden>:/etc/apt/sources.list")
  apply(tramp-handle-file-directory-p "/sudo:<email address hidden>:/etc/apt/sources.list")
  tramp-sh-file-name-handler(file-directory-p "/sudo:<email address hidden>:/etc/apt/sources.list")
  apply(tramp-sh-file-name-handler file-directory-p "/sudo:<email address hidden>:/etc/apt/sources.list")
  tramp-file-name-handler(file-directory-p "/sudo:<email address hidden>:/etc/apt/sources.list")
  file-directory-p("/sudo:<email address hidden>:/etc/apt/sources.list")
  find-file-noselect("/sudo::/etc/apt/sources.list" nil nil t)
  find-file("/sudo::/etc/apt/sources.list" t)
  call-interactively(find-file)

Revision history for this message
Phil Sung (psung) wrote :

Closing; problem seems to have gone away with most recent emacs-snapshot on Hardy.

Changed in emacs-snapshot:
status: New → Invalid
Revision history for this message
Juhamatti Niemelä (iiska) wrote :

This issue seems to be present in Jaunty version of emacs-snapshot. Opening new file through C-X f /sudo::/somefile hangs after inputting password for sudo with message "Tramp: Waiting for prompts from remote shell".

Tried to apply workaround proposed by Phil Sung with following steps, but it didn't work:

$ cd /usr/share/emacs/23.0.91/lisp/net
$ sudo gunzip tramp.el.gz
Changed tramp-remote-sh for sudo command to "/bin/bash --norc" and then byte-compiled it with:
$ sudo emacs -batch -f batch-byte-compile tramp.el

Revision history for this message
Allen Knutson (allenk) wrote :

Similar woes. I am running Ubuntu 9.04, emacs-snapshot, and the single line
"(require 'tramp)" in my .emacs brings

Warning (initialization): An error occurred while loading `/home/allenk/.emacs':

Invalid read syntax: invalid multibyte form

then with emacs --debug-init,

͂͂͂Debugger entered--Lisp error: (invalid-read-syntax "invalid multibyte form")
  require(comint)
  byte-code("..." [require comint custom-declare-group shell nil "Running shell from within Emacs buffers." :group processes unix shell-directories "Directory support in shell mode." shell-faces "Faces in shell buffers."] 8)
  require(shell)
  byte-code("..." [load-in-progress current-message message "Loading tramp..." require trampver add-hook tramp-unload-hook (lambda nil (when ... ...)) tramp-compat (lambda nil (when ... ...)) format-spec password-cache nil noerror password shell advice auth-source autoload tramp-get-file-property "tramp-cache" tramp-set-file-property tramp-flush-file-property tramp-flush-directory-property tramp-get-connection-property tramp-set-connection-property tramp-flush-connection-property tramp-parse-connection-properties (lambda nil (when ... ...))] 4)
  require(tramp)
  eval-buffer(#<buffer *load*> nil "/home/allenk/.emacs" nil t) ; Reading at buffer position 402
  load-with-code-conversion("/home/allenk/.emacs" "/home/allenk/.emacs" t t)
  load("~/.emacs" t t)
  #[nil "..." [init-file-user system-type user-init-file-1 user-init-file otherfile source ms-dos "~" "/_emacs" windows-nt directory-files nil "^\\.emacs\\(\\.elc?\\)?$" "~/.emacs" "^_emacs\\(\\.elc?\\)?$" "~/_emacs" "/.emacs" t load expand-file-name "init" file-name-as-directory "/.emacs.d" file-name-extension "elc" file-name-sans-extension ".el" file-exists-p file-newer-than-file-p message "Warning: %s is newer than %s" sit-for 1 "default" alt inhibit-default-init inhibit-startup-screen] 7]()
  command-line()
  normal-top-level()

where I removed some of the \300s etc. I tried Phil Sung's workaround, also to no effect.

Revision history for this message
Allen Knutson (allenk) wrote :

Just to say: uninstalling older emacsen and reinstalling emacs-snapshot didn't help either.

Revision history for this message
biiont (biiont) wrote :

Emacs-24.3.50.1 installed from "http://emacs.naquadah.org/" on Debian.

During sudoing with tramp "/sudo::" it asks for a password with a prompt like:
"Password for /sudo:root@mynetworkhostname:"

So tramp is trying to ssh to remote host with name "mynetworkhostname" as this is not localhost. This operation fails as I don't have sshd running.

My fix is to set "tramp-default-host" to localhost:
(setq tramp-default-host "localhost")

So it works now.

Changed in emacs-snapshot (Ubuntu):
status: Invalid → Opinion
Revision history for this message
biiont (biiont) wrote :

Previous solution is broken. It helped to use "/su::" instead of sudo.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.