Paste number 54881: TRAMP 2.1 Second Rant (draft)

Paste number 54881: TRAMP 2.1 Second Rant (draft)
Pasted by: twb
When:2 years, 6 months ago
Share:Tweet this! | http://paste.lisp.org/+16CH
Channel:#emacs
Paste contents:
Raw Source | XML | Display As
I am having difficulty with my normal workflow due to changes between
TRAMP 2.0 and 2.1, and I have identified a number of issues.


Multi-hop now hides initial hops
================================

The initial hops are no longer shown in the path, nor on the first
line of dired buffers.  Already I have been VERY confused because
a bad tramp-default-proxies-alist resulted in no proxy being used for

    /sudo:root@leek:/etc

...so that instead of editing leek's /etc as root, I was editing my
laptop's /etc as root!  Since the path claims that I'm on root@leek, I
would have made disastrous changes to my local system if I hadn't
noticed that there was no /etc/ssh/sshd_config (because sshd is not
installed on my laptop).

This accident makes me *extremely* afraid to trust TRAMP 2.1-style
multi-hops for anything at all, since there I'm bound to make alist
mistakes that I won't pick up on so readily.


Shell-command is no longer a shell
==================================

It seems that shell-command (M-!) no longer uses a shell in TRAMP
buffers.  For example, in /sudo::/ if I do M-! whoami && pwd RET or
M-! sh -c 'whoami && pwd' I get the following errors:

    whoami: extra operand `&&'
    Try `whoami --help' for more information.

    &&: 1: Syntax error: Unterminated quoted string

Another example was running M-! find -name \*~ -delete RET in
/ssh:leek:, which should have deleted backup files in my home
directory.  In Emacs 22, it behaves correctly.  In CVS Emacs, it
silently fails.

This means I can no longer trust basic sh commands to evaluate
correctly, and thus cannot use this feature safely in TRAMP buffers.


Multi-hop now requires tedious alist editing
============================================

It is often the case that I need to access a customer site that I have
never accessed before, or whose network layout has changed since I
last accessed it.  On Emacs 22 I would therefore by trial and error
modify a multi: path until it was correct, do the job, and then forget
the path.  In the short term, I can switch back to an open dired for
that site, or use M-p at the C-x C-f prompt.

In the long term, by the time I need to access that customer's site
again, their network will probably have changed.  Writing it down
would be at best bloat, and at worst misleading, since the correct
information is stored elsewhere in a text file that is maintained by
other staff who are in charge of that customer's network.

Now, the trial and error step must be done by editing a setq in .emacs
and repeatedly doing C-M-x, then trying C-x C-f again (possibly
killing *tramp foo* buffers after each attempt to make sure no stale
connections cause problems.)  To remove this bloaty, misleading
information I must remember to edit .emacs again after successfully
connecting.  This is quite tedious compared to editing a single multi:
string at the C-x C-f prompt.


sudo -s (without -H) now aborts connection
==========================================

My .bashrc (et al) is mode 0600 (readable only by me).  If I run "sudo
-u zippy -s" in a shell, I get the (ignorable) error

    bash: /home/twb/.bashrc: Permission denied

Because $HOME is still /home/twb.  For this reason I use sudo -i or
(on legacy systems) sudo -H -s in interactive shells.  In Emacs 22,
TRAMP ignores this error and /sudo:zippy@: works fine.  In CVS Emacs
it seems this error aborts the connection entirely:

    $ emacs -batch -Q -nw /sudo:zippy@: -f kill-emacs
    Tramp: Opening connection for zippy@Clio.twb.ath.cx using sudo...
    Tramp: Waiting 60s for local shell to come up...
    Tramp: Sending command `sudo -u zippy -s -p Password: && exit || exit'
    Tramp: Waiting for prompts from remote shell
    File error: Permission denied
    [hangs]

I have worked around this problem successfully with the following code
in my .emacs.  Note that deleting "-H" is merely for potential
forwards compatibility.

    (eval-after-load "tramp"
      '(progn
         (add-to-list 'tramp-methods
           (cons "sudoHs" (copy-tree (cdr (assoc "sudo" tramp-methods)))))
         (let ((x (cdr (cadr (assoc 'tramp-login-args (cdr (assoc "sudo" tramp-methods)))))))
           (setcar x (cons "-i" (delete "-H" (delete "-s" (car x))))))
         (let ((x (cdr (cadr (assoc 'tramp-login-args (cdr (assoc "sudoHs" tramp-methods)))))))
           (setcar x (cons "-H" (delete "-H" (car x)))))))

This paste has no annotations.

Colorize as:
Show Line Numbers

Lisppaste pastes can be made by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively.