From 2fbe17c49ab8c413f5036e60ee31a56c3ed435da Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Fri, 25 Jun 2021 14:18:28 +0200 Subject: [PATCH] Fix Tramp bug#49178 * lisp/net/tramp.el (tramp-handle-find-backup-file-name) (tramp-handle-make-auto-save-file-name): Adapt checks. (Bug#49178) --- lisp/net/tramp.el | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 5284981961a..0f15e4a20b5 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -3648,17 +3648,17 @@ User is always nil." (cdr x)))) tramp-backup-directory-alist) backup-directory-alist)) - (uid (tramp-compat-file-attribute-user-id - (file-attributes filename 'integer))) result) (prog1 ;; Run plain `find-backup-file-name'. (setq result (tramp-run-real-handler #'find-backup-file-name (list filename))) ;; Protect against security hole. - (when (and (natnump uid) (zerop uid) + (when (and (not tramp-allow-unsafe-temporary-files) (file-in-directory-p (car result) temporary-file-directory) - (not tramp-allow-unsafe-temporary-files) + (zerop (or (tramp-compat-file-attribute-user-id + (file-attributes filename 'integer)) + tramp-unknown-id-integer)) (not (with-tramp-connection-property (tramp-get-process v) "unsafe-temporary-file" (yes-or-no-p @@ -5264,8 +5264,7 @@ this file, if that variable is non-nil." (auto-save-file-name-transforms (if (null tramp-auto-save-directory) auto-save-file-name-transforms)) - (uid (tramp-compat-file-attribute-user-id - (file-attributes buffer-file-name 'integer))) + (filename buffer-file-name) (buffer-file-name (if (null tramp-auto-save-directory) buffer-file-name @@ -5283,9 +5282,11 @@ this file, if that variable is non-nil." (prog1 ;; Run plain `make-auto-save-file-name'. (setq result (tramp-run-real-handler #'make-auto-save-file-name nil)) ;; Protect against security hole. - (when (and (natnump uid) (zerop uid) + (when (and (not tramp-allow-unsafe-temporary-files) (file-in-directory-p result temporary-file-directory) - (not tramp-allow-unsafe-temporary-files) + (zerop (or (tramp-compat-file-attribute-user-id + (file-attributes filename 'integer)) + tramp-unknown-id-integer)) (not (with-tramp-connection-property (tramp-get-process v) "unsafe-temporary-file" (yes-or-no-p -- 2.39.2