On Dec 11, 2006, at 8:33 PM, Luke Kanies wrote:

> Hi,
>
> I'm having inconsistent behaviour with running external commands as  
> other users, and the time has apparently come to use something akin  
> to a fork and popen3 to get something approximating consistent  
> bahaviour.

This ended up being my solution:

http://madstop.com/articles/2006/12/19/shell-commands-and-uid

     def execute(command, user = nil, group = nil)
         IO.popen("-") do |f|
             if f
                 text = f.read
                 return text
             else
                 $stderr.close
                 $stderr = $stdout.dup
                 Process.uid = user if user
                 Process.gid = group if group
                 system(*command)
                 exit!
             end
         end
     end


  --
  Men never do evil so completely and cheerfully as when they do it  
from a
  religious conviction.          --Blaise Pascal
  ---------------------------------------------------------------------
  Luke Kanies | http://reductivelabs.com | http://madstop.com