From: Tony Arcieri Date: 2010-10-19T09:01:25+09:00 Subject: Re: su {block of code.} --001485f423e44e614d0492ecfefc Content-Type: text/plain; charset=ISO-8859-1 On Mon, Oct 18, 2010 at 5:20 PM, Guido De Rosa wrote: > o.instance_eval do > ::File.open('/TEST', 'w'){|f| f.puts 'hello'} > end > > I keep getting a Permission Denied error (Errno::EACCES) > > And if I change '/TEST' into '/tmp/TEST', It's clearly seen that the > file has been created by the normal user, not by root. Well yes, this isn't going to work, because you're talking to the File singleton object here, not to the main object over DRb. I guess my question is what exactly are you trying to accomplish? Do you want a small DSL of commands to work with files as root, or are you expecting everything to be executed in the context of the setuid root VM? If it's the former, try this: include FileUtils cp "somefile", "anotherfile" That should operate as expected. Beyond that, you would need to use ParseTree or ripper to extract the Ruby code you want executed on the remote VM or something like that, but then you need to ensure that all the classes/objects it's using are actually loaded on the new VM. For practicality's sake I'd suggest exposing a small DSL for doing what you want to do as root. FileUtils provides everything I'd think you need, but perhaps you have a use case I'm not envisioning. -- Tony Arcieri Medioh! A Kudelski Brand --001485f423e44e614d0492ecfefc--