Subject: bug#77402: 31.0.50; Tramp: file-writable-p broken

From: Michael Albinus <[email-masked]>
Date: Mon, 31 Mar 2025 16:42:28 +0200

Michael Albinus <[email-masked]> writes:

Hi Gerd,

> Then I'm lost. We could try it with tramp-verbose 11, which gives
> additional call traces.
>
> Or you could give me temporary access to the remote machine, that I can
> debug.

Just wait! There's another nuisance worth to fix. Could you, pls, check?

Best regards, Michael.

diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 5e79d4be41e..06613873925 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -1789,7 +1789,8 @@ tramp-sh-handle-file-executable-p
       ;; satisfied without remote operation.
       (if (tramp-use-file-attributes v)
 	  (or (tramp-check-cached-permissions v ?x)
-	      (tramp-check-cached-permissions v ?s))
+	      (tramp-check-cached-permissions v ?s)
+              (tramp-check-cached-permissions v ?t))
 	(tramp-run-test v "-x" localname)))))

 (defun tramp-sh-handle-file-readable-p (filename)
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 91ba71510e1..4b9bf2be677 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -4372,9 +4372,7 @@ tramp-handle-file-readable-p
 	  ;; `tramp-check-cached-permissions' doesn't handle symbolic
 	  ;; links.
 	  (and-let* ((symlink (file-symlink-p filename))
-		     ((stringp symlink))
-		     ((file-readable-p
-		       (concat (file-remote-p filename) symlink)))))))))
+		     ((file-readable-p (file-truename filename)))))))))

 (defun tramp-handle-file-regular-p (filename)
   "Like `file-regular-p' for Tramp files."
@@ -6480,14 +6478,13 @@ tramp-check-cached-permissions
                        ((eq ?r access) 1)
                        ((eq ?w access) 2)
                        ((eq ?x access) 3)
-                       ((eq ?s access) 3)))
+                       ((eq ?s access) 3)
+                       ((eq ?t access) 3)))
 	      (file-attr (file-attributes (tramp-make-tramp-file-name vec)))
+              ;; Not a symlink.
+              ((not (stringp (file-attribute-type file-attr))))
 	      (remote-uid (tramp-get-remote-uid vec 'integer))
 	      (remote-gid (tramp-get-remote-gid vec 'integer)))
-    (or
-     ;; Not a symlink.
-     (eq t (file-attribute-type file-attr))
-     (null (file-attribute-type file-attr)))
     (or
      ;; World accessible.
      (eq access (aref (file-attribute-modes file-attr) (+ offset 6)))