emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Eshell and Sudo


From: Michael Albinus
Subject: Re: Eshell and Sudo
Date: Sun, 17 Feb 2013 18:47:29 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux)

Michael Albinus <address@hidden> writes:

>> Eshell Developers,

Hi Ian & Aidan,

Finally, we have two problems.

>>        Recursive load:
>>  "EMACS_BUILD_DIR/share/emacs/24.3.50/lisp/net/tramp.elc",
>>  "EMACS_BUILD_DIR/share/emacs/24.3.50/lisp/net/tramp.elc",
>>  "EMACS_BUILD_DIR/share/emacs/24.3.50/lisp/net/tramp.elc",
>>  "EMACS_BUILD_DIR/share/emacs/24.3.50/lisp/net/tramp.elc",
>>  "EMACS_BUILD_DIR/share/emacs/24.3.50/lisp/net/tramp.elc"
>>         I tried running Emacs without a configuration file, using -q,
>>         and got the same thing.  Does anyone know why it's doing this?
>
> I guess you mean -Q. Anyway, same result here.

I've debugged it in Tramp. According to the backtrace, in
`tramp-file-name-handler' there is a call of `file-truename', which
causes the recursion. But I cannot see such a call :-(

However, the following patch cures the problem:

--8<---------------cut here---------------start------------->8---
=== modified file 'lisp/eshell/em-unix.el'
--- lisp/eshell/em-unix.el      2013-01-02 16:13:04 +0000
+++ lisp/eshell/em-unix.el      2013-02-17 16:26:24 +0000
@@ -1041,6 +1041,7 @@
 (defun eshell/su (&rest args)
   "Alias \"su\" to call Tramp."
   (setq args (eshell-stringify-list (eshell-flatten-list args)))
+  (require 'tramp)
   (let ((orig-args (copy-tree args)))
     (eshell-eval-using-options
      "su" args
@@ -1077,6 +1078,7 @@

 (defun eshell/sudo (&rest args)
   "Alias \"sudo\" to call Tramp."
+  (require 'tramp)
   (setq args (eshell-stringify-list (eshell-flatten-list args)))
   (let ((orig-args (copy-tree args)))
     (eshell-eval-using-options
@@ -1111,8 +1113,6 @@
                          (format "%s|sudo:address@hidden:%s"
                                  (substring prefix 0 -1) user host dir)
                        (format "/sudo:address@hidden:%s" user host dir))))
-               ;; Ensure, that Tramp has connected to that construct already.
-               (ignore (file-exists-p default-directory))
                (eshell-named-command (car orig-args) (cdr orig-args))))))))

 (put 'eshell/sudo 'eshell-no-numeric-conversions t)
--8<---------------cut here---------------end--------------->8---

I've added the require also for `eshell/su', just in case.

> Even stranger, if I preload tramp by "emacs -Q -l tramp", I get random
> results:
>
> ~/src/emacs $ sudo id
> uid=0(root) gid=0(root) groups=0(root)
> ~/src/emacs $ sudo id
> Wrong type argument: processp, nil

This is a Tramp error. As defense mechanism, Tramp detects how often a
new connection is opened. If it happens too often in a short time frame,
it refuses to work. This shall avoid yo-yo effects on instable
connections.

If you call an external command several times, this mechanism applies. A
false alarm, obviously. The following patch solves this:

--8<---------------cut here---------------start------------->8---
address@hidden emacs]$ bzr diff lisp/net/tramp-sh.el
=== modified file 'lisp/net/tramp-sh.el'
--- lisp/net/tramp-sh.el        2013-02-16 17:44:00 +0000
+++ lisp/net/tramp-sh.el        2013-02-17 16:52:48 +0000
@@ -2784,7 +2784,11 @@
           (or (null program) tramp-process-connection-type))
          (bmp (and (buffer-live-p buffer) (buffer-modified-p buffer)))
          (name1 name)
-         (i 0))
+         (i 0)
+         ;; We do not want to raise an error when
+         ;; `start-file-process' has been started several time in
+         ;; `eshell' and friends.
+         (tramp-current-connection nil))

       (unless buffer
        ;; BUFFER can be nil.  We use a temporary buffer.
--8<---------------cut here---------------end--------------->8---

Both patches are pretty simple. I would like to install them in the
emacs-24 branch. Objections?

>> Ian D

Best regards, Michael.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]