I'm working on a system where no one (except me) has sudo root access. I'm running an action from a menu that edits a file using a bash script along with some input form the user. The file to be edited is owned by another user and my regular users know that password. I want to avoid changing file and directory ownership or adding anything to sudoers.
Here, let say it this way to make it clearer:
User BOB has limited system rights, but BOB knows TEDs password.
User TED has more system rights than BOB and owns a bunch of data files that BOB can read, but not edit.
They have the same primary group.
To edit the file SCRIPT, you must be TED because both the file and the directory it's in belong to TED.
I have written a bash script to edit SCRIPT but it has to be run as TED.
I have been trying for days to figure out a way to switch BOB to TED when the script is launched, but have failed. I settled on two scripts, the first one calls the other. It looks like:
This is called inside xterm so the output looks like:
Then the second scripts launches and works fine.. When I try to put this su command inside the second script, it opens a second terminal window and fails.
Having two scripts isn't the end of the world, I just wondered if there was a better way to do it.
Here, let say it this way to make it clearer:
User BOB has limited system rights, but BOB knows TEDs password.
User TED has more system rights than BOB and owns a bunch of data files that BOB can read, but not edit.
They have the same primary group.
To edit the file SCRIPT, you must be TED because both the file and the directory it's in belong to TED.
I have written a bash script to edit SCRIPT but it has to be run as TED.
I have been trying for days to figure out a way to switch BOB to TED when the script is launched, but have failed. I settled on two scripts, the first one calls the other. It looks like:
Code:
#!/bin/bash printf "Enter TEDs " su -c "/scripts/SCRIPT" TED
Code:
Enter TEDs Password:
Having two scripts isn't the end of the world, I just wondered if there was a better way to do it.
Comment