bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#28540: eshell/sudo find-file doesn't work as expected with files onl


From: Michael Albinus
Subject: 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
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Yegor Timoshenko <yegortimoshenko@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@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.





reply via email to

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