[clue] sudo and sudoers: force changing working directory
chris fedde
chris at fedde.us
Tue Oct 18 11:43:54 MDT 2011
I typically make wrapper scripts for jobs that require average users
to use sudo:
#!/bin/bash
user=mysql
if test $EUID -ne `id -u $user`
then
exec sudo -u $user $0 "$@"
fi
# stand in for real work
id
On Mon, Oct 17, 2011 at 2:21 PM, Sean LeBlanc <seanleblanc at comcast.net> wrote:
> So, I want to be able to have a certain user sudo to a specific user and
> run a specific command.
>
> Preferably, I'd like to NOT have to remember to change working directory
> to the target user's home dir prior to running that specific command.
>
> I have always_set_home in sudoers as the default, but setting home is
> not enough - working directory has to be changed.
>
> I thought I'd try out giving sudo the "-i" flag, but that then seems to
> result in having to type in password, even though that is not desired
> for this scenario.
>
> Any ideas on how to achieve this?
>
> right now, the command looks like this:
>
> sudo -u targetuser "cd /home/targetuser; thecommand"
>
>
>
> _______________________________________________
> clue mailing list: clue at cluedenver.org
> For information, account preferences, or to unsubscribe see:
> http://cluedenver.org/mailman/listinfo/clue
>
More information about the clue
mailing list