After a bad accident with rsync deleting wrong files due to wrong destination parameter, I want to restrict rsync (or the bash script running it) to be able to delete/modify files only under a certain directory.
I thought of either:
create and run rsync/script under a user which has permissions only to that directory. The problem here is: How do I use/create a such user dynamically? (This is part of a build script that should "just run" for other users).
verify that destination paths given to rsync are under a certain directory. The direction seems to be using the
test
command, but I couldn't figure out how to use it correctly, and it's not as safe, since the test of the path parameter can still go out of sync with the actual path parameter being run, so I think (1) is more robust.