I have a user with limited access on the system (that is, he is not a sudoer); let's call him Bob.
I have a script or a binary which I, the system administrator, trust, and would have no problems running it as root; let's call the script
get-todays-passphrase.sh. The job of this script is to read data from a "private" (owned by a user/group other than Bob, or even root) file located in
/srv/daily-passphrases, and only output a specific line from the file: the line that corresponds with today's date.
Users like Bob are not allowed to know tomorrow's passphrase, even though it is listed in the file. For this reason, the file
/srv/daily-passphrases is protected by Unix permissions, so non-root users like Bob are not allowed to access the file directly. They are, however, allowed to run the
get-todays-passphrase.sh script at any time, which returns the "filtered" data.
To summarize (the TL;DR version):
- Bob can't read the protected file
- The script can read the protected file
- At any time, Bob can run the script which can read the file
Is it possible to do this within Unix file permissions? Or if Bob starts a script, will the script always be doomed to run with the same permissions as Bob?