From: Mark Hubbart Date: 2004-02-06T16:55:52+09:00 Subject: Re: impersonating ruby On Feb 5, 2004, at 3:35 PM, Robert K. wrote: > Hi, > can I somehow change a ruby interpreters uid from 0 to something and > then back again? I may be wrong, but I think you can't do this in pure ruby. You'll need outside utils of some sort. > I intend to write a little program, wich traverses all users dirs and > 'executes' whatever a user has written in his conf-file but in the > context of the corresponding user. > > What is the ruby mehtod to accomplish that? > > Reinvoking my script? I would do something like this: if Process.uid == 0 # find each conf file and run this with # it's associated filename and username: `sudo -u #{username} #{File.expand_path $0} #{filename}` else # it's not root; the you need to parse the conf file # get the filename filename = ARGV.unshift # process the file... end This is, of course, assuming that you are on a *nix based system. cheers, mark