[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH OSSTEST] PDU/xenuse: Support xenuse on machine not locked by current user



Ian Campbell writes ("[PATCH OSSTEST] PDU/xenuse: Support xenuse on machine not 
locked by current user"):
> xenuse checks that whoever is trying to reboot a machine "owns" that machine
> via a locking mechanism. This is usually fine doesn't work well when one 
> want...
> I used eval + save/restore the original user so as not to pollute the whole
> process, it might have been better to actually fork?

Well, I can think of two better ways:

1. Perl dynamic scoping ("local"):

   {
       local $ENV{USER} = $user;
       system_checked($xenuse, "--$onoff", "$mo->{Host}{Name}");
   }

IMO this is idiomatic Perl.

2. env(1) from coreutils:

   my @cmd = ($xenuse, "--$onoff", "$mo->{Host}{Name}");
   if ($user) {
       unshift @cmd, 'env', "'USER=$user";
   }
   system_checked(@cmd);

Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.