0

Tramp works fine when I try to edit with sudo or ssh, but when I try to edit with doas it will hang (while also maxing out my cpu). Here is some tramp output:

  backtrace()
  tramp-signal-hook-function(quit (""))
  signal(quit (""))
  tramp-maybe-open-connection((tramp-file-name "doas" "root" nil "localhost" nil "/etc/doas.conf" nil))
  tramp-send-command((tramp-file-name "doas" "root" nil "localhost" nil "/etc/doas.conf" nil) "test 0 2>/dev/null; echo tramp_exit_status $?")
  tramp-send-command-and-check((tramp-file-name "doas" "root" nil "localhost" nil "/etc/doas.conf" nil) "test 0")
  tramp-get-test-command((tramp-file-name "doas" "root" nil "localhost" nil "/etc/doas.conf" nil))
  tramp-run-test("-d" "/doas:root@localhost:/etc/doas.conf")
  tramp-sh-handle-file-directory-p("/doas:root@localhost:/etc/doas.conf")
  apply(tramp-sh-handle-file-directory-p "/doas:root@localhost:/etc/doas.conf")
  tramp-sh-file-name-handler(file-directory-p "/doas:root@localhost:/etc/doas.conf")
  apply(tramp-sh-file-name-handler file-directory-p "/doas:root@localhost:/etc/doas.conf")
  tramp-file-name-handler(file-directory-p "/doas:root@localhost:/etc/doas.conf")
  file-directory-p("/doas:root@localhost:/etc/doas.conf")
  find-file-noselect("/doas:root@localhost:/etc/doas.conf" nil nil nil)
  find-alternate-file("/doas:root@localhost:/etc/doas.conf")
  (if (or arg (not buffer-file-name)) (find-file (concat "/doas:root@localhost:" (ido-read-file-name "Find file(as root): "))) (find-alternate-file (concat "/doas:root@localhost:" buffer-file-name)))
  er-doas-edit(nil)
  funcall-interactively(er-doas-edit nil)
  call-interactively(er-doas-edit record nil)
  command-execute(er-doas-edit record)
  execute-extended-command(nil "er-doas-edit" "er-do")
  funcall-interactively(execute-extended-command nil "er-doas-edit" "er-do")
  call-interactively(execute-extended-command nil nil)
  command-execute(execute-extended-command)

Tramp also made another buffer called debug Tramp/ doas root@Southpark which only contains this line:

11:05:44.458693 tramp-get-connection-property (7) # process-buffer nil

Here is Tramp's output to the message buffer:

Tramp: Opening connection for root@Southpark using doas...
Tramp: Sending command ‘exec doas -u root -s’
Tramp: Waiting for prompts from remote shell...failed
Tramp: Opening connection for root@Southpark using doas...failed

I set tramp-verbose to 10 and this was the output:

  backtrace()
  tramp-signal-hook-function(quit (""))
  signal(quit (""))
  tramp-maybe-open-connection((tramp-file-name "doas" #("root" 0 4 (tramp-default t)) nil #("Southpark" 0 9 (tramp-default t)) nil "/lol" nil))
  tramp-send-command((tramp-file-name "doas" #("root" 0 4 (tramp-default t)) nil #("Southpark" 0 9 (tramp-default t)) nil "/lol" nil) "/bin/test -e / 2>/dev/null; echo tramp_exit_status...")
  tramp-send-command-and-check((tramp-file-name "doas" #("root" 0 4 (tramp-default t)) nil #("Southpark" 0 9 (tramp-default t)) nil "/lol" nil) "/bin/test -e /")
  tramp-find-file-exists-command((tramp-file-name "doas" #("root" 0 4 (tramp-default t)) nil #("Southpark" 0 9 (tramp-default t)) nil "/lol" nil))
  tramp-get-file-exists-command((tramp-file-name "doas" #("root" 0 4 (tramp-default t)) nil #("Southpark" 0 9 (tramp-default t)) nil "/lol" nil))
  tramp-sh-handle-file-exists-p(#("/doas:root@Southpark:/lol" 6 10 (tramp-default t) 11 20 (tramp-default t)))
  apply(tramp-sh-handle-file-exists-p #("/doas:root@Southpark:/lol" 6 10 (tramp-default t) 11 20 (tramp-default t)))
  tramp-sh-file-name-handler(file-exists-p #("/doas:root@Southpark:/lol" 6 10 (tramp-default t) 11 20 (tramp-default t)))
  apply(tramp-sh-file-name-handler file-exists-p #("/doas:root@Southpark:/lol" 6 10 (tramp-default t) 11 20 (tramp-default t)))
  tramp-file-name-handler(file-exists-p #("/doas:root@Southpark:/lol" 6 10 (tramp-default t) 11 20 (tramp-default t)))
  file-exists-p(#("/doas:root@Southpark:/lol" 6 10 (tramp-default t) 11 20 (tramp-default t)))
  completion-file-name-table(#("/doas:root@Southpark:/lol" 6 10 (tramp-default t) 11 20 (tramp-default t)) file-exists-p lambda)
  test-completion(#("/doas:root@Southpark:/lol" 6 10 (tramp-default t) 11 20 (tramp-default t)) completion-file-name-table file-exists-p)
  completion--file-name-table("/doas::/lol" file-exists-p lambda)
  complete-with-action(lambda completion--file-name-table "/doas::/lol" file-exists-p)
  #f(compiled-function (table) #<bytecode 0x156dc8a263a1>)(completion--file-name-table)
  completion--some(#f(compiled-function (table) #<bytecode 0x156dc8a263a1>) (completion--embedded-envvar-table completion--file-name-table))
  read-file-name-internal("/doas::/lol" file-exists-p lambda)
  test-completion("/doas::/lol" read-file-name-internal file-exists-p)
  completion--complete-and-exit(12 23 exit-minibuffer #f(compiled-function () #<bytecode 0x156dc8a26381>))
  completion-complete-and-exit(12 23 exit-minibuffer)
  minibuffer-complete-and-exit()
  funcall-interactively(minibuffer-complete-and-exit)
  call-interactively(minibuffer-complete-and-exit nil nil)
  command-execute(minibuffer-complete-and-exit)
  read-from-minibuffer("Find file: " "~/" (keymap (keymap (32)) keymap (10 . minibuffer-complete-and-exit) (13 . minibuffer-complete-and-exit) keymap (menu-bar keymap (minibuf "Minibuf" keymap (tab menu-item "Complete" minibuffer-complete :help "Complete as far as possible") (space menu-item "Complete Word" minibuffer-complete-word :help "Complete at most one word") (63 menu-item "List Completions" minibuffer-completion-help :help "Display all possible completions") "Minibuf")) (27 keymap (118 . switch-to-completions)) (prior . switch-to-completions) (63 . minibuffer-completion-help) (32 . minibuffer-complete-word) (9 . minibuffer-complete) keymap (menu-bar keymap (minibuf "Minibuf" keymap (previous menu-item "Previous History Item" previous-history-element :help "Put previous minibuffer history element in the min...") (next menu-item "Next History Item" next-history-element :help "Put next minibuffer history element in the minibuf...") (isearch-backward menu-item "Isearch History Backward" isearch-backward :help "Incrementally search minibuffer history backward") (isearch-forward menu-item "Isearch History Forward" isearch-forward :help "Incrementally search minibuffer history forward") (return menu-item "Enter" exit-minibuffer :key-sequence "\15" :help "Terminate input and exit minibuffer") (quit menu-item "Quit" abort-recursive-edit :help "Abort input and exit minibuffer") "Minibuf")) (10 . exit-minibuffer) (13 . exit-minibuffer) (7 . minibuffer-keyboard-quit) (C-tab . file-cache-minibuffer-complete) (9 . self-insert-command) (XF86Back . previous-history-element) (up . previous-line-or-history-element) (prior . previous-history-element) (XF86Forward . next-history-element) (down . next-line-or-history-element) (next . next-history-element) (27 keymap (60 . minibuffer-beginning-of-buffer) (114 . previous-matching-history-element) (115 . next-matching-history-element) (112 . previous-history-element) (110 . next-history-element))) nil file-name-history "~/" nil)
  completing-read-default("Find file: " read-file-name-internal file-exists-p confirm-after-completion "~/" file-name-history "~/" nil)
  completing-read("Find file: " read-file-name-internal file-exists-p confirm-after-completion "~/" file-name-history "~/")
  read-file-name-default("Find file: " nil "~/" confirm-after-completion nil nil)
  read-file-name("Find file: " nil "~/" confirm-after-completion)
  find-file-read-args("Find file: " confirm-after-completion)
  byte-code("\300\301\302 \"\207" [find-file-read-args "Find file: " confirm-nonexistent-file-or-buffer] 3)
  call-interactively(joe-edit nil nil)
  command-execute(joe-edit)

And the debug tramp/doas root@Southpark buffer was enormous, se here's the first few dozen lines

;; Emacs: 27.1 Tramp: 2.4.3.27.1 -*- mode: outline; -*-
;; Location: /usr/share/emacs/27.1/lisp/net/tramp.elc Git: /
11:05:39.354574 tramp-get-file-property (8) # /lol file-exists-p undef
11:05:39.354639 tramp-get-file-property (8) # /lol file-attributes-integer nil
11:05:39.354685 tramp-get-file-property (8) # /lol file-attributes-string nil
11:05:39.354721 tramp-get-connection-property (7) # file-exists undef
11:05:39.354752 tramp-get-file-exists-command (5) # Finding command to check if file exists
11:05:39.354812 tramp-get-connection-property (7) # test undef
11:05:39.354847 tramp-get-test-command (5) # Finding a suitable ‘test’ command
11:05:39.354886 tramp-get-connection-property (7) # process-name nil
11:05:39.354921 tramp-get-connection-property (7) # process-name nil
11:05:39.354952 tramp-get-connection-property (7) # process-buffer nil
11:05:39.354990 tramp-get-connection-property (7) # process-buffer nil
11:05:39.355020 tramp-set-connection-property (7) # process-buffer nil
11:05:39.355090 tramp-maybe-open-connection (3) # Opening connection for root@Southpark using doas...
11:05:39.355176 tramp-call-process (6) # ‘locale -a’ nil  *temp*
11:05:39.355887 tramp-call-process (6) # 0
C
en_US.utf8
ja_JP
ja_JP.eucjp
ja_JP.ujis
ja_JP.utf8
japanese
japanese.euc
POSIX
11:05:39.355948 tramp-get-local-locale (7) # locale en_US.utf8
11:05:39.356016 tramp-get-connection-property (7) # login-args undef
11:05:39.356063 tramp-get-connection-property (7) # login-args undef
11:05:39.356112 tramp-get-connection-property (7) # process-name nil
11:05:39.356151 tramp-get-connection-property (7) # process-buffer nil
11:05:39.356394 tramp-maybe-open-connection (6) # /bin/sh -i
11:05:39.356447 tramp-get-connection-property (7) # check-remote-echo nil
11:05:39.356482 tramp-get-connection-property (7) # check-remote-echo nil
11:05:39.362229 tramp-accept-process-output (10) # *tramp/doas root@Southpark* nil run t
#$ 
11:05:39.362301 tramp-get-connection-property (7) # check-remote-echo nil
11:05:39.362341 tramp-get-connection-property (7) # check-remote-echo nil
11:05:39.362390 tramp-wait-for-regexp (6) # 
#$ 
11:05:39.362439 tramp-get-connection-property (7) # login-program undef
11:05:39.362485 tramp-get-connection-property (7) # login-args undef
11:05:39.362529 tramp-get-connection-property (7) # remote-shell undef
11:05:39.362574 tramp-get-connection-property (7) # async-args undef
11:05:39.362618 tramp-get-connection-property (7) # connection-timeout undef
11:05:39.362658 tramp-get-connection-property (7) # temp-file undef
11:05:39.362738 tramp-set-connection-property (7) # temp-file /tmp/tramp.LaiDu1
11:05:39.362779 tramp-set-connection-property (7) # password-vector (tramp-file-name doas root nil Southpark nil nil nil)
11:05:39.362829 tramp-get-connection-property (7) # session-timeout undef
11:05:39.362872 tramp-get-connection-property (7) # session-timeout undef
11:05:39.362910 tramp-set-connection-property (7) # session-timeout 300
11:05:39.363072 tramp-maybe-open-connection (3) # Sending command ‘exec doas -u root -s’
11:05:39.363120 tramp-get-connection-property (7) # process-name nil
11:05:39.363162 tramp-get-connection-property (7) # remote-echo nil
11:05:39.363197 tramp-send-command (6) # exec doas -u root -s
11:05:39.363240 tramp-get-connection-property (7) # process-name nil
11:05:39.363280 tramp-get-connection-property (7) # chunksize nil
11:05:39.363317 tramp-set-connection-property (7) # last-cmd-time (24604 17795 363305 774000)
11:05:39.363358 tramp-send-string (10) # exec doas -u root -s
11:05:39.363397 tramp-get-connection-property (7) # process-buffer nil
11:05:39.363454 tramp-get-connection-property (7) # password-vector (tramp-file-name doas root nil Southpark nil nil nil)
11:05:39.363499 tramp-set-connection-property (7) # first-password-request 
11:05:39.363548 tramp-process-actions (3) # Waiting for prompts from remote shell...
11:05:39.363641 tramp-accept-process-output (10) # *tramp/doas root@Southpark* 0 run nil

This happens when I try to run the following er-doas-edit edit function on the (already opened) /etc/doas.conf.

(defun er-doas-edit (&optional arg)
  "Edit currently visited file as root With a prefix ARG prompt for a file to visit.
Will also prompt for a file to visit if current buffer is not visiting a file."
  (interactive "P")
  (if (or arg (not buffer-file-name))
      (find-file (concat "/doas:root@localhost:"
                         (ido-read-file-name "Find file(as root): ")))
    (find-alternate-file (concat "/doas:root@localhost:" buffer-file-name))))

The same error happens no matter how I try to open the file with doas.

I'm on Arch Linux.

emacs --version reports: GNU Emacs 27.1

Here is the full tramp debug buffer

4
  • What happens if you increase tramp-verbose, and consult the debug buffer? What is the contents of the connection buffer? Maybe an unknown password prompt? Feb 4, 2021 at 15:13
  • @MichaelAlbinus I made some edits with tramp-verbose set to 10. I thought I had done that originally, but I guess not! Also, shouldda mentioned this in my edits, but the debug tramp/doas root@Soutpark buffer is 18,000 lines long when running with verbosity level 10 and allowed to run for 10 seconds.
    – ryan
    Feb 4, 2021 at 19:18
  • If you don't see anything useful, send it to me. Pls as attachment. And no, 18,000 debug lines are nothing for Tramp :-) Feb 4, 2021 at 20:12
  • @MichaelAlbinus I added a link to a dropbox download in the op. Thanks a lot.
    – ryan
    Feb 4, 2021 at 21:30

1 Answer 1

1

See line 178058 of the debug output. Your prompt is not understandable by Tramp, I suppose zsh is in game. Pls read the Tramp manual how to configure zsh properly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.