[clue] sudo and sudoers: force changing working directory
Jim Ockers
ockers at ockers.net
Mon Oct 17 16:08:52 MDT 2011
Hi Sean,
Sean LeBlanc 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"
>
>
Maybe I'm missing something, but couldn't you make "thecommand" be a
shell script incorporating those two lines, where the second line runs
"thecommand.real" ?
Jim
--
Jim Ockers, P.Eng. (ockers at ockers.net)
Contact info: http://www.ockers.net/msi.html
More information about the clue
mailing list