I have a shell script which syncs some files from a remote source and I have a pretty typical HTTP server set-up. There is a user who owns the files served by the HTTP server and a user which runs the HTTP server - both of which belong to the same group.
I want the synced files to be owned by the "owner" user and I don't want the HTTP server user to be able to write to them. However, I want the HTTP server user to be able to invoke the sync script.
One option is to wrap the shell script in a small C application and use setuid so the HTTP server user can run it as the "owner" user.
Given that:
- There will be no input to the script - the remote location, destination location, etc. are all constant.
- The setuid script won't be owned/run by root.
Is this a safe and sensible thing to do?
Edit:
For the sake of explaining things you can use the following names:
- deploy-user: The user who should own the files
- www-user: The user running the HTTP server
- www-group: The group deploy-user and www-user belong to
- sync.sh: The script which updates the file
- sync.txt: The target file