bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#58132: 29.0.50; Tramp: not preserving remote chmod attributes when c


From: Michael Albinus
Subject: bug#58132: 29.0.50; Tramp: not preserving remote chmod attributes when copy
Date: Mon, 31 Oct 2022 09:32:44 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

Jean Louis <bugs@gnu.support> writes:

Hi Jean,

> Normal behavior with local `copy' command is to preserve attributes of
> the destination file, if such file exists.
>
> Normal behavior of ssh/scp is to preserve file attributes of destination
> file if such file exists:
>
> $ ssh stw1 ls -l /home/admin/diff.sql
> -rwxr-xr-x 1 admin admin 6240 Sep 27 20:22 /home/admin/diff.sql
> ~
> $ ls -l diff.sql
> -rw-r--r-- 1 admin admin 6240 Jun 20  2021 diff.sql
> ~
> $ scp diff.sql stw1:~/
> diff.sql                                                          100% 6240   
>  20.6KB/s   00:00    
> ~
> $ ssh stw1 ls -l /home/admin/diff.sql
> -rwxr-xr-x 1 admin admin 6240 Sep 27 20:23 /home/admin/diff.sql
> ~
>
> I have noticed that Tramp transfers file attributes from local file to
> remote file. This causes server errors, as it is out of the habit that
> file attributes on existing file are to be preserved.

Tramp does what it is instructed. Copying a file is triggered by the
`copy-file' function. If the argument PRESERVE-PERMISSIONS is non-nil,
Tramp tries to preserve the permissions. See the docstring of `copy-file':

--8<---------------cut here---------------start------------->8---
copy-file is an interactive built-in function in ‘src/fileio.c’.

(copy-file FILE NEWNAME &optional OK-IF-ALREADY-EXISTS KEEP-TIME
PRESERVE-UID-GID PRESERVE-PERMISSIONS)

Copy FILE to NEWNAME.  Both args must be strings.
If NEWNAME is a directory name, copy FILE to a like-named file under
NEWNAME.  For NEWNAME to be recognized as a directory name, it should
end in a slash.

This function always sets the file modes of the output file to match
the input file.

The optional third argument OK-IF-ALREADY-EXISTS specifies what to do
if file NEWNAME already exists.  If OK-IF-ALREADY-EXISTS is nil,
signal a ‘file-already-exists’ error without overwriting.  If
OK-IF-ALREADY-EXISTS is an integer, request confirmation from the user
about overwriting; this is what happens in interactive use with M-x.
Any other value for OK-IF-ALREADY-EXISTS means to overwrite the
existing file.

Fourth arg KEEP-TIME non-nil means give the output file the same
last-modified time as the old one.  (This works on only some systems.)

A prefix arg makes KEEP-TIME non-nil.

If PRESERVE-UID-GID is non-nil, try to transfer the uid and gid of
FILE to NEWNAME.

If PRESERVE-PERMISSIONS is non-nil, copy permissions of FILE to NEWNAME;
this includes the file modes, along with ACL entries and SELinux
context if present.  Otherwise, if NEWNAME is created its file
permission bits are those of FILE, masked by the default file
permissions.
--8<---------------cut here---------------end--------------->8---

So it isn't an error per se.

Best regards, Michael.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]