GNU bug report logs - #27169
eshell/sudo doesn't work with protected directories

Previous Next

Package: emacs;

Reported by: Yegor Timoshenko <yegortimoshenko <at> gmail.com>

Date: Wed, 31 May 2017 16:49:01 UTC

Severity: normal

Tags: moreinfo, unreproducible

Merged with 27168

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 27169 in the body.
You can then email your comments to 27169 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#27169; Package emacs. (Wed, 31 May 2017 16:49:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Yegor Timoshenko <yegortimoshenko <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 31 May 2017 16:49:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Yegor Timoshenko <yegortimoshenko <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: eshell/sudo doesn't work with protected directories 
Date: Wed, 31 May 2017 19:47:04 +0300
Example (In M-x eshell):

cd /tmp
mkdir a
touch a/b
sudo chmod 700 a
sudo chown root:wheel a
sudo ls a

Expected output:

b

Instead I get:

/bin/ls: cannot open directory 'a': Permission denied

sudo cat a/b, etc. also don't work. I've found this problem while trying to cat my /etc/sudoers file:

$ sudo cat /etc/sudoers
Opening input file: Permission denied, /etc/sudoers



Merged 27168 27169. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Wed, 31 May 2017 16:54:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27169; Package emacs. (Wed, 07 Jun 2017 12:58:01 GMT) Full text and rfc822 format available.

Message #10 received at 27169 <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: Yegor Timoshenko <yegortimoshenko <at> gmail.com>
Cc: 27169 <at> debbugs.gnu.org
Subject: Re: bug#27169: eshell/sudo doesn't work with protected directories
Date: Wed, 07 Jun 2017 08:59:09 -0400
tags 27169 unreproducible
quit

Yegor Timoshenko <yegortimoshenko <at> gmail.com> writes:

> Expected output:
>
> b
>
> Instead I get:
>
> /bin/ls: cannot open directory 'a': Permission denied
>
> sudo cat a/b, etc. also don't work. I've found this problem while trying to cat my /etc/sudoers file:
>
> $ sudo cat /etc/sudoers
> Opening input file: Permission denied, /etc/sudoers

Works for me, can you reproduce this from 'emacs -Q'?  What Emacs
version are you using?

    Welcome to the Emacs shell

    ~/src $ cd /tmp
    /tmp $ mkdir a
    /tmp $ touch a/b
    /tmp $ sudo chmod 700 a
    [sudo] password for npostavs: 
    /tmp $ sudo chown root:wheel a
    [sudo] password for npostavs: 
    /tmp $ sudo ls a
    [sudo] password for npostavs: 
    b
    /tmp $ 




Added tag(s) unreproducible. Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Wed, 07 Jun 2017 12:58:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27169; Package emacs. (Wed, 07 Jun 2017 18:44:02 GMT) Full text and rfc822 format available.

Message #15 received at 27169 <at> debbugs.gnu.org (full text, mbox):

From: Yegor Timoshenko <yegortimoshenko <at> gmail.com>
To: 27169 <at> debbugs.gnu.org
Subject: Re: bug#27169: eshell/sudo doesn't work with protected directories
Date: Wed, 7 Jun 2017 21:43:18 +0300
> Works for me, can you reproduce this from 'emacs -Q'?  What Emacs
> version are you using?

GNU Emacs 25.2.1 (x86_64-apple-darwin13.4.0, NS appkit-1265.21 Version 10.9.5 (Build 13F1911)) of 2017-04-21

Yes, it's reproducible with -Q flag, provided that you execute (require 'em-tramp) in *scratch* buffer.

I believe it can be a platform-specific bug (I use macOS). Patched old Emacs version bundled with my system
(Emacs 22) doesn't have this bug. I've also just built Emacs 25.2 from scratch (using Gentoo Prefix) and tried it with
`emacs -Q` and it is still reproducible:

~ $ cd /tmp
/tmp $ sudo ls a/b
/Users/yegortimoshenko/Documents/Gentoo/bin/ls: cannot access 'a/b': Permission\
denied
/tmp $ emacs-version
GNU Emacs 25.2.1 (x86_64-apple-darwin16, NS appkit-1504.83 Version 10.12.5 (Bui\
ld 16F73))
of 2017-06-07

The same applies to bug#27167.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27169; Package emacs. (Thu, 08 Jun 2017 00:20:01 GMT) Full text and rfc822 format available.

Message #18 received at 27169 <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: Yegor Timoshenko <yegortimoshenko <at> gmail.com>
Cc: 27169 <at> debbugs.gnu.org
Subject: Re: bug#27169: eshell/sudo doesn't work with protected directories
Date: Wed, 07 Jun 2017 20:20:47 -0400
[Message part 1 (text/plain, inline)]
tags 27169 = patch
quit

Yegor Timoshenko <yegortimoshenko <at> gmail.com> writes:

> GNU Emacs 25.2.1 (x86_64-apple-darwin13.4.0, NS appkit-1265.21 Version 10.9.5 (Build 13F1911)) of 2017-04-21
>
> Yes, it's reproducible with -Q flag, provided that you execute (require 'em-tramp) in *scratch* buffer.

Hmm, for some reason that doesn't work for me (possibly another bug),
but if I use 'eshell/sudo' instead of plain 'sudo' I can reproduce your problem.

The following fixes it:

[v1-0001-Let-eshell-sudo-handle-absolute-command-names-Bug.patch (text/x-diff, inline)]
From e3d96af45b85a9ed9b96a12cae3e68eb21a2de47 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs <at> gmail.com>
Date: Wed, 7 Jun 2017 18:48:39 -0400
Subject: [PATCH v1] Let eshell/sudo handle absolute command names (Bug#27167)

* lisp/eshell/esh-ext.el (eshell-find-interpreter): Don't change
absolute paths into relative ones.
---
 lisp/eshell/esh-ext.el | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/lisp/eshell/esh-ext.el b/lisp/eshell/esh-ext.el
index fb1fedc9c5..2a495225dc 100644
--- a/lisp/eshell/esh-ext.el
+++ b/lisp/eshell/esh-ext.el
@@ -299,11 +299,13 @@ (defun eshell-find-interpreter (file args &optional no-examine-p)
       (let ((fullname (if (file-name-directory file) file
 			(eshell-search-path file)))
 	    (suffixes eshell-binary-suffixes))
-	(if (and fullname
-		 (not (file-remote-p fullname))
-		 (file-remote-p default-directory))
-	    (setq fullname (expand-file-name
-			    (concat "./" fullname) default-directory)))
+	(when (and fullname
+                   (not (file-remote-p fullname))
+                   (file-remote-p default-directory))
+          (setq fullname
+                (if (file-name-absolute-p fullname)
+                    (concat (file-remote-p default-directory) fullname)
+                  (expand-file-name fullname default-directory))))
 	(if (and fullname (not (or eshell-force-execution
 				   (file-executable-p fullname))))
 	    (while suffixes
-- 
2.11.1


Added tag(s) patch; removed tag(s) unreproducible. Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Thu, 08 Jun 2017 00:20:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27169; Package emacs. (Thu, 08 Jun 2017 00:50:02 GMT) Full text and rfc822 format available.

Message #23 received at 27169 <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: Yegor Timoshenko <yegortimoshenko <at> gmail.com>
Cc: 27169 <at> debbugs.gnu.org
Subject: Re: bug#27169: eshell/sudo doesn't work with protected directories
Date: Wed, 07 Jun 2017 20:50:55 -0400
Yegor Timoshenko <yegortimoshenko <at> gmail.com> writes:

>> Works for me, can you reproduce this from 'emacs -Q'?  What Emacs
>> version are you using?
>
> GNU Emacs 25.2.1 (x86_64-apple-darwin13.4.0, NS appkit-1265.21 Version 10.9.5 (Build 13F1911)) of 2017-04-21
>
> Yes, it's reproducible with -Q flag, provided that you execute (require 'em-tramp) in *scratch* buffer.

Don't you also need (push 'eshell-tramp eshell-modules-list)?

Once I do that, I'm able to reproduce #27167, but not this bug:

    ~/src $ sudo /bin/cat foo
    /sudo:root <at> localhost:/home/npostavs/src/bin/cat: command not found
    ~/src $ cd /tmp
    /tmp $ sudo ls a/b
    a/b

> I believe it can be a platform-specific bug (I use macOS).

Possible.  Does this work from M-x shell?  Does C-x C-f /sudo::/tmp/a/
work?  Does it make a difference if you run from the terminal vs running
graphically (there's at least one macOS bug where this makes a
difference, #21573).




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27169; Package emacs. (Thu, 08 Jun 2017 22:22:02 GMT) Full text and rfc822 format available.

Message #26 received at 27169 <at> debbugs.gnu.org (full text, mbox):

From: Yegor Timoshenko <yegortimoshenko <at> gmail.com>
To: npostavs <at> users.sourceforge.net
Cc: 27169 <at> debbugs.gnu.org
Subject: Re: bug#27169: eshell/sudo doesn't work with protected directories
Date: Fri, 9 Jun 2017 01:21:05 +0300
> Don't you also need (push 'eshell-tramp eshell-modules-list)?

I never did that and it seemed to work fine (I had to manually alias
sudo to eshell/sudo, though). Hopefully this will fix some other
problems with eshell I had recently, but adding 'eshell-tramp to
eshell-modules-list didn't resolve the issue.

> Does this work from M-x shell?

No, this one is specific to eshell (actually, to em-tramp eshell/sudo).

> Does C-x C-f /sudo::/tmp/a/ work?

It works.

> Does it make a difference if you run from the terminal vs running
> graphically (there's at least one macOS bug where this makes a
> difference, #21573).

It is reproducible both in graphical and terminal environments.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27169; Package emacs. (Fri, 09 Jun 2017 00:48:01 GMT) Full text and rfc822 format available.

Message #29 received at 27169 <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: Yegor Timoshenko <yegortimoshenko <at> gmail.com>
Cc: 27169 <at> debbugs.gnu.org
Subject: Re: bug#27169: eshell/sudo doesn't work with protected directories
Date: Thu, 08 Jun 2017 20:49:01 -0400
Yegor Timoshenko <yegortimoshenko <at> gmail.com> writes:

>> Don't you also need (push 'eshell-tramp eshell-modules-list)?
>
> I never did that and it seemed to work fine (I had to manually alias
> sudo to eshell/sudo, though).

Aha, that explains it.

>> Does this work from M-x shell?
>
> No, this one is specific to eshell (actually, to em-tramp
> eshell/sudo).

So by "No" you mean "Yes" (it works)? ;)

>> Does C-x C-f /sudo::/tmp/a/ work?
>
> It works.
>
>> Does it make a difference if you run from the terminal vs running
>> graphically (there's at least one macOS bug where this makes a
>> difference, #21573).
>
> It is reproducible both in graphical and terminal environments.

Hmm, if you step through eshell-plain-command does it call
eshell-lisp-command or eshell-external-command to run "ls"?  (for me it
goes through eshell-lisp-command)




Added tag(s) unreproducible; removed tag(s) patch. Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Sun, 11 Jun 2017 12:48:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27169; Package emacs. (Fri, 04 Sep 2020 06:06:02 GMT) Full text and rfc822 format available.

Message #34 received at 27169 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: npostavs <at> users.sourceforge.net
Cc: 27168 <at> debbugs.gnu.org, 27169 <at> debbugs.gnu.org,
 Yegor Timoshenko <yegortimoshenko <at> gmail.com>
Subject: Re: bug#27169: eshell/sudo doesn't work with protected directories
Date: Fri, 04 Sep 2020 08:04:59 +0200
npostavs <at> users.sourceforge.net writes:

>>> Does this work from M-x shell?
>>
>> No, this one is specific to eshell (actually, to em-tramp
>> eshell/sudo).
>
> So by "No" you mean "Yes" (it works)? ;)

Reading this thread, it seems like Noam was unable to reproduce this
bug.  I've tried the given recipe, but I'm not able to reproduce it
either (on Macos Catalina).

Yegor, are you still seeing this problem?  If so, do you have a complete
recipe?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) moreinfo. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Fri, 04 Sep 2020 06:06:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27169; Package emacs. (Wed, 07 Oct 2020 03:30:02 GMT) Full text and rfc822 format available.

Message #39 received at 27169 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: npostavs <at> users.sourceforge.net
Cc: Yegor Timoshenko <yegortimoshenko <at> gmail.com>, 27169 <at> debbugs.gnu.org,
 27168 <at> debbugs.gnu.org
Subject: Re: bug#27168: bug#27169: eshell/sudo doesn't work with protected
 directories
Date: Wed, 07 Oct 2020 05:29:29 +0200
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Reading this thread, it seems like Noam was unable to reproduce this
> bug.  I've tried the given recipe, but I'm not able to reproduce it
> either (on Macos Catalina).
>
> Yegor, are you still seeing this problem?  If so, do you have a complete
> recipe?

This was four weeks ago, and there was no response, so I'm closing this
bug report.  If this is still an issue, please respond to the debbugs
address and we'll reopen the report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug closed, send any further explanations to 27168 <at> debbugs.gnu.org and Yegor Timoshenko <yegortimoshenko <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Wed, 07 Oct 2020 03:30:03 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 04 Nov 2020 12:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 167 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.