From: Ian Jackson Subject: Re: [PATCH OSSTEST] PDU/xenuse: Support xenuse on machine not locked by current user Date: Thu, 17 Oct 2013 11:25:47 +0100 Message-ID: <21087.47915.599553.193298@mariner.uk.xensource.com> References: <1381939110-30213-1-git-send-email-ian.campbell@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1381939110-30213-1-git-send-email-ian.campbell@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Campbell Cc: xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org 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.