I'm trying to use the https://unix.stackexchange.com/a/315667/21372 workaround to the cp bug using rsync, and I can't get it to work. Essentially, I need to copy files or directories recursively using rsync similar to what rsync -a would do, but create files and directories with normal umask conditions. But trying this on a single file shows that it is still preserving permissions on the destination file even though I have specified the --no-perms option:
bash-4.1$ cd /tmp
bash-4.1$ touch afile
bash-4.1$ chmod a-w afile
bash-4.1$ ls -ld afile
-r--r--r-- 1 theuser thegroup 0 Jul 24 16:50 afile
bash-4.1$ rsync --copy-links --recursive --times --group --no-perms afile afile2
bash-4.1$ ls -ld afile*
-r--r--r-- 1 theuser thegroup 0 Jul 24 16:50 afile
-r--r--r-- 1 theuser thegroup 0 Jul 24 16:50 afile2
bash-4.1$
What I want is the afile2 to have the same permissions as afile3 created normally:
bash-4.1$ touch afile3
bash-4.1$ ls -ld afile3
-rw-rw-r-- 1 theuser thegroup 0 Jul 24 16:51 afile3
I can use the "harsh" find command as given in https://unix.stackexchange.com/a/315667/21372 but I'd rather not have the overhead of a subsequent find command to do what I believe the rsync --no-perms option should do.
This needs to work in userspace (not require root).
Is this an rsync bug or user error?
OS and version of rsync involved are:
bash-4.1$ lsb_release -r -i
Distributor ID: RedHatEnterpriseWorkstation
Release: 6.8
bash-4.1$ rsync --version
rsync version 3.0.6 protocol version 30
Copyright (C) 1996-2009 by Andrew Tridgell, Wayne Davison, and others.
Web site: http://rsync.samba.org/
Capabilities:
64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,
socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,
append, ACLs, xattrs, iconv, symtimes
rsync comes with ABSOLUTELY NO WARRANTY. This is free software, and you
are welcome to redistribute it under certain conditions. See the GNU
General Public Licence for details.
bash-4.1$