From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Michael Albinus Newsgroups: gmane.emacs.bugs 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 Message-ID: <87o9g3f1sp.fsf@gmx.de> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1529670133 10682 195.159.176.226 (22 Jun 2018 12:22:13 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 22 Jun 2018 12:22:13 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 28540@debbugs.gnu.org To: Yegor Timoshenko Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jun 22 14:22:09 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fWL4q-0002eX-Pd for geb-bug-gnu-emacs@m.gmane.org; Fri, 22 Jun 2018 14:22:09 +0200 Original-Received: from localhost ([::1]:33435 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fWL6w-0000mE-7s for geb-bug-gnu-emacs@m.gmane.org; Fri, 22 Jun 2018 08:24:18 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42719) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fWL6k-0000kg-Br for bug-gnu-emacs@gnu.org; Fri, 22 Jun 2018 08:24:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fWL6g-0001vi-Jn for bug-gnu-emacs@gnu.org; Fri, 22 Jun 2018 08:24:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:51837) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fWL6g-0001v6-Fq for bug-gnu-emacs@gnu.org; Fri, 22 Jun 2018 08:24:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fWL6g-0008IT-5j for bug-gnu-emacs@gnu.org; Fri, 22 Jun 2018 08:24:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Michael Albinus Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 22 Jun 2018 12:24:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 28540 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 28540-submit@debbugs.gnu.org id=B28540.152967019331823 (code B ref 28540); Fri, 22 Jun 2018 12:24:02 +0000 Original-Received: (at 28540) by debbugs.gnu.org; 22 Jun 2018 12:23:13 +0000 Original-Received: from localhost ([127.0.0.1]:59733 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fWL5t-0008HD-I0 for submit@debbugs.gnu.org; Fri, 22 Jun 2018 08:23:13 -0400 Original-Received: from mout.gmx.net ([212.227.15.18]:39369) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fWL5r-0008Gq-S5 for 28540@debbugs.gnu.org; Fri, 22 Jun 2018 08:23:12 -0400 Original-Received: from detlef.gmx.de ([212.86.50.101]) by mail.gmx.com (mrgmx001 [212.227.17.190]) with ESMTPSA (Nemesis) id 0MNqfr-1fZN6K22TT-007WME; Fri, 22 Jun 2018 14:23:03 +0200 In-Reply-To: (Yegor Timoshenko's message of "Thu, 21 Sep 2017 15:25:40 +0000") X-Provags-ID: V03:K1:LY0fzjON/a2G55D9ZLUpQMTMh2nEVmFpSMQ+fxyIknH3cOTQZd/ p7fswl0aiWgSH3S7EPgMWC/6WU+fnecJJx7jTCJXHkF7DZNC/EvgF4MXWgCqS5lMrN1svfX 81Ix79iEGETBX/ZNDLwKFA8m5c6AqHHNLzK+fbYaXPGOc+fXAu/YR3dseaRQwW2/ALN6nBy /zVnQ+IG9XX7UUtNqiUEA== X-UI-Out-Filterresults: notjunk:1;V01:K0:pWXvDYWKRoI=:fL3ylwgWAYHY7S9n2HhvVx QCI8rcTp0SLL1r1kgmT4u784Jjqh2YfQB99z1GVAyPj9Jc1MD6/iDVCq/UzIHmL0/XsV5AAlq FoPZnte1Ou2g2RCZdFwWWvfSJnM5bv3JgKff0PggsST6I5jbW8qbQMjEtYf5qy4xlrw6HAlLP P80SKq5oBf6cwveBSL1iMziNwzzzYSxr0Btww+lrSuL0kecgLPUyQ+6NNZCIYIrAu58G+q7Iu h8qZ/BspKdseIruiNjRmmKV5I0ttcriQd+1pfC9yUkDc22AwGSUDGX+Tq6UCaaWXy6uWA4zv9 E/EjF65n6z0PMQajQCUeuTzsNHgoSlFPQ9s+aDURGDPI+HceyboT2NoA2+1quoyLsdodsv/tb rTb1wVnh4bgC4hf5qU2H+JO5BfR6gw6YN6sH8O8Y9oc8Kv4koB6+kiYEsB054VGVMNEnNxdyk aN0iV4/bN1ifdaVEqvjciQOjORTwBtmQ2REZGejxXGMh/XWEG4PLA6iwSQyQB/AHo0Gxa1KPe AfMS7juwip9YrICIdLZq8YSXAs7Tr2tFmGHAYB6aodUVDBQGPhG5T9CLObwFPu0IjEuGpNmrk mQzHgTXZBJQBj4HFvJr8r0J2t8w3mmMloeJwkKeas99DrvyJNTtKFtrlptzOeDAS31dQmafL+ T2Xrwjvf1B/7PV4UGTD9fL4RfqzofxABlWnZr+ahi6pgFTaymaU7jNZbUiWwATP2tn6ZDEVkp T1RXPHAzArhXKPlYuaM8jkugumdqewUrcI8ACMvOFRMH6mfUB5NFSrQSQDP6NDFDZEFonfNj X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:147737 Archived-At: Yegor Timoshenko 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.