Skip to content
This repository has been archived by the owner on Jun 7, 2018. It is now read-only.

Implement support for --chmod and --chown rsync flags (supersedes PR #46) #49

Merged
merged 6 commits into from Jul 5, 2017

Conversation

dkasak
Copy link

@dkasak dkasak commented Jul 5, 2017

I've implemented most of the things you asked for, except testing the new features. I'm not sure how to approach testing the --chown functionality since I don't know which users/groups I can rely on being present in the testing environment.

Regarding --chmod, I have started implementing tests but I'm not sure what's the best way to organize them. I've thought about making a new test_chmod sync dir with a single file inside it with certain permissions set up, then adding a new test case test_afl_rsync_chmod which tests push/sync by using --chmod to change permissions and verifying they are correct (by calling AflRsync directly). How does that sound?

I'm in a bit of a hurry, so sorry if something's unclear.

By default, afl-sync behaves the same as before, running rsync in
archive mode (-a) and trasferring local permissions and owner/group.
However, --chmod PERMS and --chown USER:GROUP can now be specified,
which passes these flags to rsync, enabling the user to specify the
permissions, owner and group of the remote files.

This is useful when ensuring the remote storage dir is readable and/or
writable on the server for all processes that need to access it.

The new flags are only supported when pushing and in the push phase of
syncing, not pulling. The support for the flags was implemented by
the introduction of a new parameter for AflRsync, which represents the
options for rsync, both its get and put modes.
rsync seems to internally convert --chown=foo:bar to --usermap=*:foo
--groupmap=*:bar. Due to a bug[*], it passes this to a shell at some
point without properly escaping it. The shell then globs the wildcard,
which is not correct and likely makes the shell complain about
nonexistent matches. A workaround is to pass --protect-args to rsync
which makes makes it work as intended but may have other consequences.

[*] https://bugzilla.samba.org/show_bug.cgi?id=10705
@coveralls
Copy link

coveralls commented Jul 5, 2017

Coverage Status

Coverage decreased (-0.3%) to 91.958% when pulling 8da548c on dkasak:experimental into f743ef0 on rc0r:experimental.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 91.958% when pulling 8da548c on dkasak:experimental into f743ef0 on rc0r:experimental.

@rc0r
Copy link
Owner

rc0r commented Jul 5, 2017

Thanks for your continued effort! :)

I think the best way to test this beast (afl-utils as a whole) is to use Python's unittest.Mock API. Back in the day when I started to write the test suite I didn't know mocking existed, so that's the reason it's not used yet. So don't worry too much about the missing tests. I'll take a closer look at your PR and deal with testing the new feature.

@rc0r rc0r merged commit 8da548c into rc0r:experimental Jul 5, 2017
@rc0r
Copy link
Owner

rc0r commented Jul 5, 2017

I fixed some minor issues in afl-sync (see 6eb3fd2). May I ask you to test the updated version a bit when you find the time. No need to hurry.

Thanks again!

@dkasak
Copy link
Author

dkasak commented Jul 16, 2017

I've switched to the experimental branch in my setup and have been using it for a few days. So far everything seems to be working.

@rc0r
Copy link
Owner

rc0r commented Jul 18, 2017

Cool, thanks for your feedback!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants