[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



On Thu, 2013-10-17 at 11:25 +0100, Ian Jackson wrote:
> 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.

I tried this and it didn't work. I think local causes $ENV to loose its
magic properties. That kind of makes sense I think since you can't
actually create a local copy of your actual environment so it would have
to jump through what I imagine would be some clever hoops to unwind when
the local $ENV went out of scope, I've no idea if that's even possible
in Perl.

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

I can do this one assuming I'm right about method #1.

> 
> 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®.