On Mon, Jan 17, 2011 at 07:26:36PM -0800, pl wrote:
> Process.uid was telling me 500, which was the intended user. whoami
> inside the execpipe was root though.
>
> I've ended up doing this
>
> def self.exec_as_user(op, pkg)
>
> Puppet::Util::SUIDManager.asuser("node", "node") do
> s = execute ["my", "command", "and", "args"]
> s.split("\n").collect do | line |
> yield line
> end
> end
> end
>
>
> which is doing what I want
You can also pass arguments to execute to run the command as a different
user. It should work like that
output = execute(['command','arg1], {uid => 'node', gid => 'node'})
What operatingsystem are you running? Looking at the source asuser will
just change euid and egid and from the manpage of whoami it should
return the euid. So I dont really understand why whoami is reporting
root and I dont really see why execute should behave
differently from execpipe.
-Stefan
pgpvHFRYmAUPA.pgp
Description: PGP signature
