all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Michael Albinus <michael.albinus@gmx.de>
To: Ian D <dunni@gnu.org>, Aidan Gauland <aidalgol@no8wireless.co.nz>
Cc: emacs-devel@gnu.org
Subject: Re: Eshell and Sudo
Date: Sun, 17 Feb 2013 18:47:29 +0100	[thread overview]
Message-ID: <87wqu6u91q.fsf@gmx.de> (raw)
In-Reply-To: <87txpc3wnn.fsf@gmx.de> (Michael Albinus's message of "Sat, 16 Feb 2013 20:07:24 +0100")

Michael Albinus <michael.albinus@gmx.de> 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:%s@%s:%s"
 				  (substring prefix 0 -1) user host dir)
 			(format "/sudo:%s@%s:%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---
[albinus@arthur 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.



  parent reply	other threads:[~2013-02-17 17:47 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-16 16:06 Eshell and Sudo Ian D
2013-02-16 19:07 ` Michael Albinus
2013-02-16 19:44   ` Aidan Gauland
2013-02-16 22:25     ` Aidan Gauland
2013-02-17  8:22     ` John Wiegley
2013-02-17  9:08       ` Aidan Gauland
2013-02-17 18:00         ` Michael Albinus
2013-02-17 17:47   ` Michael Albinus [this message]
2013-02-17 18:47     ` Aidan Gauland
2013-02-17 19:29       ` Michael Albinus
2013-02-17 23:28         ` Aidan Gauland
2013-02-18  5:07           ` Michael Albinus
2013-02-18 13:48             ` Stefan Monnier
2013-02-18 14:01               ` Michael Albinus
2013-02-18 16:24                 ` Stefan Monnier
2013-02-18 19:20                   ` Michael Albinus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wqu6u91q.fsf@gmx.de \
    --to=michael.albinus@gmx.de \
    --cc=aidalgol@no8wireless.co.nz \
    --cc=dunni@gnu.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.