From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Thompson Subject: Re: [PATCH] provide real error message when trying to run xm as non root Date: Tue, 26 Jul 2005 10:52:35 -0400 Message-ID: <42E64E33.5030507@aktzero.com> References: <20050726144156.GA22926@underhill.no-ip.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------000709070001020709080803" Return-path: In-Reply-To: <20050726144156.GA22926@underhill.no-ip.org> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. --------------000709070001020709080803 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sean Dague wrote: > This patch prevents you from getting a screen full of stack trace when > trying to run commands like xm list as a normal user, and instead provides a > helpful error message. +1, Admirable. (non-binding/non-voter/non-commiter) > Signed-off-by: Sean Dague > > Diffstat output: > main.py | 7 +++++++ > 1 files changed, 7 insertions(+) > > diff -r 48aed1403fe3 tools/python/xen/xm/main.py > --- a/tools/python/xen/xm/main.py Fri Jul 22 16:44:33 2005 > +++ b/tools/python/xen/xm/main.py Tue Jul 26 10:31:24 2005 > @@ -11,6 +11,13 @@ > > from xen.xend import PrettyPrint > from xen.xend import sxp > +# this is a nasty place to stick this in, but required because > +# log file access is set up via a 5 deep import chain. This > +# ensures the user sees a useful message instead of a stack trace > +if os.getuid() != 0: > + print "xm requires root access to execute, please try again as root" > + sys.exit(1) > + > from xen.xend.XendClient import XendError, server > from xen.xend.XendClient import main as xend_client_main > from xen.xm import create, destroy, migrate, shutdown, sysrq Please allow me to show my possible ignorance... Is there no better way to test for elevated privileges? Would it be unreasonable to think xm maintenance tasks could be handed off to members of a non-root group? -- Andrew Thompson http://aktzero.com/ --------------000709070001020709080803 Content-Type: text/x-vcard; charset=utf-8; name="andrewkt.vcf" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="andrewkt.vcf" begin:vcard fn:Andrew Thompson n:Thompson;Andrew email;internet:andrewkt@aktzero.com x-mozilla-html:FALSE url:http://aktzero.com/ version:2.1 end:vcard --------------000709070001020709080803 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --------------000709070001020709080803--