unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Greg Pfeil <greg@technomadic.org>
To: Michael Albinus <michael.albinus@gmx.de>
Cc: 60943@debbugs.gnu.org
Subject: bug#60943: 28.2; ‘tramp-handle-file-regular-p’ misses symlinks
Date: Thu, 19 Jan 2023 10:55:45 -0700	[thread overview]
Message-ID: <8B66E6A4-13D0-49B1-B2B5-52A561960C39@technomadic.org> (raw)
In-Reply-To: <87fsc6llc7.fsf@gmx.de>

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

I think sockets (where the 0th char is ?s) are also considered regular files. Also, I think that patch checks whether the truename is a regular file, but I believe /all/ symlinks are considered regular.

How about this version?


[-- Attachment #2: tramp-file-regular-p.patch --]
[-- Type: application/octet-stream, Size: 584 bytes --]

diff --git a/lisp/tramp.el b/lisp/tramp.el
index 351def66..82fa2b61 100644
--- a/lisp/tramp.el
+++ b/lisp/tramp.el
@@ -4039,7 +4039,7 @@ Let-bind it when necessary.")
        ;; Sometimes, `file-attributes' does not return a proper value
        ;; even if `file-exists-p' does.
        (when-let ((attr (file-attributes filename)))
-	 (eq ?- (aref (file-attribute-modes attr) 0)))))
+	 (memq (aref (tramp-compat-file-attribute-modes attr) 0) '(?- ?l ?s)))))

 (defun tramp-handle-file-remote-p (filename &optional identification connected)
   "Like `file-remote-p' for Tramp files."

[-- Attachment #3: Type: text/plain, Size: 1366 bytes --]



It just changes the equality check to check for the set of valid values. If we had the mode as a number, we could just check the one bit for regular files (which I think is what ‘file-regular-p’ does).


> On Jan 19, 2023, at 06:12, Michael Albinus <michael.albinus@gmx.de> wrote:
> 
> Greg Pfeil <greg@technomadic.org> writes:
> 
> Hi Greg,
> 
>> I was having an issue where .dir-locals.el on remote machines weren’t getting picked up when they were a symlink. Local symlinks worked fine, and remote non-symlinks also worked.
>> 
>> Digging in, ‘tramp-handle-regular-file-p’ explicitly checks that the first character in ‘file-attribute-mode’ is ?-. However, for symlinks, that character will be ?l.
>> 
>> Modifying ‘dir-locals--all-files’ to check
>> 
>>  (or (file-regular-p f) (file-symlink-p f))
>> 
>> \(which is ostensibly redundant) instead of simply
>> 
>>  (file-regular-p f)
> 
> Indeed, there's a bug. Thanks for the report!
> 
>> fixes the behavior, since TRAMP will now check with both ‘tramp-handle-file-regular-p’ and ‘tramp-handle-file-symlink-p’. The correct fix is to make ‘tramp-handle-file-regular-p’ match the behavior of ‘file-regular-p’.
> 
> The appended patch fixes this. Eli, is it OK to push to the emacs-29 branch?
> 
> Best regards, Michael.
> 
> <Mail Attachment>


  reply	other threads:[~2023-01-19 17:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-19  6:03 bug#60943: 28.2; ‘tramp-handle-file-regular-p’ misses symlinks Greg Pfeil
2023-01-19 13:12 ` Michael Albinus
2023-01-19 17:55   ` Greg Pfeil [this message]
2023-01-20 10:56     ` Michael Albinus
2023-01-20 14:16       ` Greg Pfeil
2023-01-21 11:13         ` 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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8B66E6A4-13D0-49B1-B2B5-52A561960C39@technomadic.org \
    --to=greg@technomadic.org \
    --cc=60943@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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).