On 24/09/2024 20:09, Ross Burton wrote:
So the greater context of this is that I'm trying to copy a file from a NFS server, preserving mode and timestamp. The current script does `cp -a` which as discussed here breaks when it tries to preserve the mode. Looking at our use case, the only things we actually care about is the timestamp and user executable bit. In my testing the u+x bit is always preserved and --preserve=mode mainly impacts whether the umask is respected or not. Am I missing any fine details or is --preserve=timestamps sufficient for our needs?
The full online documentation is informative on all these points: https://www.gnu.org/software/coreutils/cp " --preserve=mode Preserve attributes relevant to access permissions, including file mode bits and (if possible) access control lists (ACLs). ACL preservation is system-dependent, and ACLs are not necessarily translated when the source and destination are on file systems with different ACL formats (e.g., NFSv4 versus POSIX formats). ... In the absence of this option, the permissions of existing destination files are unchanged. Each new file is created with the mode of the corresponding source file minus the set-user-ID, set-group-ID, and sticky bits as the create mode; the operating system then applies either the umask or a default ACL, possibly resulting in a more restrictive file mode. " cheers, Pádraig