On 10/18/2010 06:32 PM, Guido De Rosa wrote: > Hi! > > Scenario: on a Unix-like system I run a ruby program under a > non-privileged user. Occasionally I need to gain root privileges. > > For external commands it's just a matter of installing sudo, editing > /etc/sudoers properly, and going: > > system "sudo command..." > > But what if I want to do the same for a block of code? > > Something like this would be really, really cool: > > include Sudo > su do > # ruby code... > end > > There's a way to get this? A gem? Any idea on how to implement it? You cannot do that in a single process since Unix permissions and user identity are managed on a per process basis. And then there's the issue of authentication, i.e. you probably need a user to enter his password. Kind regards robert