all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Michael Albinus <michael.albinus@gmx.de>
Cc: 28264@debbugs.gnu.org
Subject: bug#28264: Accessing source directory through symlink produces false warnings
Date: Tue, 29 Aug 2017 19:20:47 -0700	[thread overview]
Message-ID: <f957e613-dc7e-7a6e-692a-d081e258815a@cs.ucla.edu> (raw)
In-Reply-To: <87378a9kds.fsf@detlef>

[-- Attachment #1: Type: text/plain, Size: 1195 bytes --]

Michael Albinus wrote:

> This special problem does not seem to affect Tramp, tramp-tests tell.

The problem I was thinking of does not seem to be covered by Tramp tests. If, 
for example, I do these shell commands:

$ ln -s "../penguin:motd" /tmp/foo
$ ls -l /tmp/foo
lrwxrwxrwx 1 eggert eggert 15 Aug 29 19:00 /tmp/foo -> ../penguin:motd

then (file-truename "/tmp/foo") returns "/penguin:motd" which is not /tmp/foo's 
true name as far as Emacs file-oriented commands are concerned. Admittedly this 
is an improvement over Emacs 25.2 where the same file-truename call ssh'es into 
penguin to resolve the name, which is a clear security issue. Still, it doesn't 
seem right, if file-truename is expected to quote its result if necessary.

Sorry about all this confusion, but I do not know the general principle that 
Emacs is supposed to be using with file names, and to some extent I fear that 
there isn't one alas.

> However, the following code is unclear to me:
> 
>> +	(concat "/:" file))
> 
> What, if file is already quoted? Shouldn't this be
> 
>          (file-name-quote file)

Quite possibly, and I'll take your word for it. I installed the attached.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Prefer-file-name-quote-to-concat.patch --]
[-- Type: text/x-patch; name="0001-Prefer-file-name-quote-to-concat.patch", Size: 1590 bytes --]

From 0eb9f21ded1b6aefcf0ac33f393b07ab6a543a05 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Tue, 29 Aug 2017 19:17:54 -0700
Subject: [PATCH] Prefer file-name-quote to concat "/:"

Suggested by Michael Albinus (Bug#28264#13).
* lisp/files.el (files--splice-dirname-file): Use file-name-quote
rather than attempting to do it by hand.
---
 lisp/files.el | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lisp/files.el b/lisp/files.el
index 5f55aa7..7754be2 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -1156,16 +1156,16 @@ files--name-absolute-system-p
 (defun files--splice-dirname-file (dirname file)
   "Splice DIRNAME to FILE like the operating system would.
 If FILENAME is relative, return DIRNAME concatenated to FILE.
-Otherwise return FILE, quoted with `/:' if DIRNAME and FILE have
+Otherwise return FILE, quoted as needed if DIRNAME and FILE have
 different handlers; although this quoting is dubious if DIRNAME
-is remote, it is not clear what would be better.  This function
+is magic, it is not clear what would be better.  This function
 differs from `expand-file-name' in that DIRNAME must be a
 directory name and leading `~' and `/:' are not special in FILE."
   (if (files--name-absolute-system-p file)
       (if (eq (find-file-name-handler dirname 'file-symlink-p)
 	      (find-file-name-handler file 'file-symlink-p))
 	  file
-	(concat "/:" file))
+	(file-name-quote file))
     (concat dirname file)))
 
 (defun file-truename (filename &optional counter prev-dirs)
-- 
2.7.4


  reply	other threads:[~2017-08-30  2:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-28 18:25 bug#28264: Accessing source directory through symlink produces false warnings Glenn Morris
2017-08-29  4:57 ` Paul Eggert
2017-08-29 20:41   ` Michael Albinus
2017-08-30  2:20     ` Paul Eggert [this message]
2017-08-30  8:37       ` Michael Albinus

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=f957e613-dc7e-7a6e-692a-d081e258815a@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=28264@debbugs.gnu.org \
    --cc=michael.albinus@gmx.de \
    /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.