I recently started using gokrazy/rsync to copy some files between hosts as part of a particular workflow. While I did want the sync to work recursively and preserve timestamps, my use case requires that these files be group writable, so I was hoping to be able to just change the umask on the receiving end and have everything work.
Instead, I found that the files were being created with mode 0644, despite the umask being set to 0002.
My sender uses a client configured like this, which with other rsync implementations would default to not copying permissions:
client, err := rsyncclient.New([]string{"-rlt"}, rsyncclient.WithSender())
The receiving end works over SSH with a forced command of gokr-rsync --daemon --server.
After some investigation, it looks like this issue happens on the receiver side. In internal/receiver, the only place where rt.Opts.PreservePerms is checked is when opening a file that already exists (in openLocalFile). The setPerms function does not have a check for rt.Opts.PreservePerms and instead always calls Chmod if the permissions differ between the the sender and receiver.
I think the simplest fix for this is probably to just add a rt.Opts.PreservePerms check in internal/receiver/generator.go at line 131 similar to what is done a few lines above for rt.Opts.PreserveTimes.
I recently started using gokrazy/rsync to copy some files between hosts as part of a particular workflow. While I did want the sync to work recursively and preserve timestamps, my use case requires that these files be group writable, so I was hoping to be able to just change the umask on the receiving end and have everything work.
Instead, I found that the files were being created with mode 0644, despite the umask being set to 0002.
My sender uses a client configured like this, which with other rsync implementations would default to not copying permissions:
The receiving end works over SSH with a forced command of
gokr-rsync --daemon --server.After some investigation, it looks like this issue happens on the receiver side. In internal/receiver, the only place where
rt.Opts.PreservePermsis checked is when opening a file that already exists (inopenLocalFile). ThesetPermsfunction does not have a check forrt.Opts.PreservePermsand instead always callsChmodif the permissions differ between the the sender and receiver.I think the simplest fix for this is probably to just add a
rt.Opts.PreservePermscheck in internal/receiver/generator.go at line 131 similar to what is done a few lines above forrt.Opts.PreserveTimes.