GNU bug report logs - #28540
eshell/sudo find-file doesn't work as expected with files only readable by root

Previous Next

Package: emacs;

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

Date: Thu, 21 Sep 2017 15:26:02 UTC

Severity: normal

Tags: wontfix

Done: Stefan Kangas <stefan <at> marxist.se>

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 28540 in the body.
You can then email your comments to 28540 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#28540; Package emacs. (Thu, 21 Sep 2017 15:26:02 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. (Thu, 21 Sep 2017 15:26:02 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 find-file doesn't work as expected with files only
 readable by root
Date: Thu, 21 Sep 2017 15:25:40 +0000
To reproduce, M-x eshell and compare behavior of these two commands:

$ ff /sudo::/etc/sudoers
$ sudo ff /etc/sudoers

In the first case the buffer is editable (and can be saved), while in
the latter it is opened read-only. Switching read-only flag with C-x
C-q doesn't help: I can edit the buffer, but not save it (results in
"Doing chmod: operation not permitted" error).

GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, Xaw scroll bars)
 of 2017-09-21 (198ba449845ffa557ac272c3219c703148648f53)

Reproducible in Emacs 25.3 as well.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28540; Package emacs. (Thu, 21 Sep 2017 15:32:01 GMT) Full text and rfc822 format available.

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

From: Yegor Timoshenko <yegortimoshenko <at> gmail.com>
To: 28540 <at> debbugs.gnu.org
Subject: Re: bug#28540: Acknowledgement (eshell/sudo find-file doesn't work as
 expected with files only readable by root)
Date: Thu, 21 Sep 2017 15:30:53 +0000
Sorry, two assumptions in the previous email:

(defalias 'ff 'find-file)
(eval-after-load 'esh-module
  '(add-to-list 'eshell-modules-list 'eshell-tramp))

On Thu, Sep 21, 2017 at 3:26 PM, GNU bug Tracking System
<help-debbugs <at> gnu.org> wrote:
> Thank you for filing a new bug report with debbugs.gnu.org.
>
> This is an automatically generated reply to let you know your message
> has been received.
>
> Your message is being forwarded to the package maintainers and other
> interested parties for their attention; they will reply in due course.
>
> Your message has been sent to the package maintainer(s):
>  bug-gnu-emacs <at> gnu.org
>
> If you wish to submit further information on this problem, please
> send it to 28540 <at> debbugs.gnu.org.
>
> Please do not send mail to help-debbugs <at> gnu.org unless you wish
> to report a problem with the Bug-tracking system.
>
> --
> 28540: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=28540
> GNU Bug Tracking System
> Contact help-debbugs <at> gnu.org with problems




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28540; Package emacs. (Fri, 22 Jun 2018 12:24:02 GMT) Full text and rfc822 format available.

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

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Yegor Timoshenko <yegortimoshenko <at> gmail.com>
Cc: 28540 <at> debbugs.gnu.org
Subject: Re: bug#28540: eshell/sudo find-file doesn't work as expected with
 files only readable by root
Date: Fri, 22 Jun 2018 14:23:02 +0200
Yegor Timoshenko <yegortimoshenko <at> gmail.com> writes:

Hi Yegor,

[sorry for the late reply; this bug flew under my radar]

> To reproduce, M-x eshell and compare behavior of these two commands:
>
> $ ff /sudo::/etc/sudoers
> $ sudo ff /etc/sudoers
>
> In the first case the buffer is editable (and can be saved), while in
> the latter it is opened read-only. Switching read-only flag with C-x
> C-q doesn't help: I can edit the buffer, but not save it (results in
> "Doing chmod: operation not permitted" error).
>
> GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, Xaw scroll bars)
>  of 2017-09-21 (198ba449845ffa557ac272c3219c703148648f53)
>
> Reproducible in Emacs 25.3 as well.
>
> Sorry, two assumptions in the previous email:
>
> (defalias 'ff 'find-file)
> (eval-after-load 'esh-module
>   '(add-to-list 'eshell-modules-list 'eshell-tramp))

I believe this behavior is correct. In your first test, the file has
been opened as "/sudo::/etc/sudoers". But in the second test, the file
has been opened as "/etc/sudoers" (you will see this, when you try to
pen another file via "C-x C-f": "/etc/" is offered to you as default
directory).

The point is, that the "sudo" command changes the default directory
internally to "/sudo:root <at> localhost:...", but the following Lisp code
(expanding your alias) evaluates as (find-file "/etc/passwd"). And
although the current default directory is remote, just the local
"/etc/passwd" is opened. And you have no write permissions there.

In order to change this behavior, ehsell would need to analyze the
command given after the leading "sudo". For shell commands like "sudo
*cat /etc/sudoers", the file name must be kept literally, because it is
evalled in the shell command. But for Lisp commands, like your "sudo ff
/etc/sudoers", the file name must be expanded internally to "sudo ff
/sudo::/etc/sudoers".

This requires much knowledge about what a command like "cat" or "ff" is
intended to do. I doubt we will go such far in eshell.

Best regards, Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28540; Package emacs. (Sun, 29 Sep 2019 01:08:01 GMT) Full text and rfc822 format available.

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

From: Stefan Kangas <stefan <at> marxist.se>
To: Michael Albinus <michael.albinus <at> gmx.de>
Cc: 28540 <at> debbugs.gnu.org, Yegor Timoshenko <yegortimoshenko <at> gmail.com>
Subject: Re: bug#28540: eshell/sudo find-file doesn't work as expected with
 files only readable by root
Date: Sun, 29 Sep 2019 03:07:25 +0200
tags 28540 + wontfix
close 28540
quit

Michael Albinus <michael.albinus <at> gmx.de> writes:

> Yegor Timoshenko <yegortimoshenko <at> gmail.com> writes:
>
> Hi Yegor,
>
> [sorry for the late reply; this bug flew under my radar]
>
>> To reproduce, M-x eshell and compare behavior of these two commands:
>>
>> $ ff /sudo::/etc/sudoers
>> $ sudo ff /etc/sudoers
>>
>> In the first case the buffer is editable (and can be saved), while in
>> the latter it is opened read-only. Switching read-only flag with C-x
>> C-q doesn't help: I can edit the buffer, but not save it (results in
>> "Doing chmod: operation not permitted" error).
>>
>> GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, Xaw scroll bars)
>>  of 2017-09-21 (198ba449845ffa557ac272c3219c703148648f53)
>>
>> Reproducible in Emacs 25.3 as well.
>>
>> Sorry, two assumptions in the previous email:
>>
>> (defalias 'ff 'find-file)
>> (eval-after-load 'esh-module
>>   '(add-to-list 'eshell-modules-list 'eshell-tramp))
>
> I believe this behavior is correct. In your first test, the file has
> been opened as "/sudo::/etc/sudoers". But in the second test, the file
> has been opened as "/etc/sudoers" (you will see this, when you try to
> pen another file via "C-x C-f": "/etc/" is offered to you as default
> directory).
>
> The point is, that the "sudo" command changes the default directory
> internally to "/sudo:root <at> localhost:...", but the following Lisp code
> (expanding your alias) evaluates as (find-file "/etc/passwd"). And
> although the current default directory is remote, just the local
> "/etc/passwd" is opened. And you have no write permissions there.
>
> In order to change this behavior, ehsell would need to analyze the
> command given after the leading "sudo". For shell commands like "sudo
> *cat /etc/sudoers", the file name must be kept literally, because it is
> evalled in the shell command. But for Lisp commands, like your "sudo ff
> /etc/sudoers", the file name must be expanded internally to "sudo ff
> /sudo::/etc/sudoers".
>
> This requires much knowledge about what a command like "cat" or "ff" is
> intended to do. I doubt we will go such far in eshell.

I agree.  To do this right in general would be a significant
undertaking for a very minor benefit.  I'm therefore closing this as
wontfix.

If anyone disagrees with that, feel free to reopen.

Best regards,
Stefan Kangas




Added tag(s) wontfix. Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Sun, 29 Sep 2019 01:08:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 28540 <at> debbugs.gnu.org and Yegor Timoshenko <yegortimoshenko <at> gmail.com> Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Sun, 29 Sep 2019 01:08: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. (Sun, 27 Oct 2019 11:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 183 days ago.

Previous Next


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