all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Kangas <stefan@marxist.se>
To: Michael Albinus <michael.albinus@gmx.de>
Cc: 28540@debbugs.gnu.org, Yegor Timoshenko <yegortimoshenko@gmail.com>
Subject: 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	[thread overview]
Message-ID: <CADwFkm=_uhM6_g3ECE6MHkmZisU6dDrS7fX8dsLrfq3RJMBvfQ@mail.gmail.com> (raw)
In-Reply-To: <CAF4sQCOR4dpMYHaiwMX1t7fCHvtnYPdSCLeacqbxFndbddFw1w@mail.gmail.com>

tags 28540 + wontfix
close 28540
quit

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

> 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.

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





      parent reply	other threads:[~2019-09-29  1:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-21 15:25 bug#28540: eshell/sudo find-file doesn't work as expected with files only readable by root Yegor Timoshenko
     [not found] ` <handler.28540.B.150600755726250.ack@debbugs.gnu.org>
2017-09-21 15:30   ` bug#28540: Acknowledgement (eshell/sudo find-file doesn't work as expected with files only readable by root) Yegor Timoshenko
2018-06-22 12:23 ` bug#28540: eshell/sudo find-file doesn't work as expected with files only readable by root Michael Albinus
2019-09-29  1:07 ` Stefan Kangas [this message]

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='CADwFkm=_uhM6_g3ECE6MHkmZisU6dDrS7fX8dsLrfq3RJMBvfQ@mail.gmail.com' \
    --to=stefan@marxist.se \
    --cc=28540@debbugs.gnu.org \
    --cc=michael.albinus@gmx.de \
    --cc=yegortimoshenko@gmail.com \
    /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.