WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] provide real error message when trying to run xm as

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] provide real error message when trying to run xm as non root
From: Sean Dague <sean@xxxxxxxxx>
Date: Tue, 26 Jul 2005 10:41:56 -0400
Delivery-date: Tue, 26 Jul 2005 14:40:27 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Mail-followup-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.6i
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.


Signed-off-by: Sean Dague <sean@xxxxxxxxx>

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


        -Sean

-- 
__________________________________________________________________

Sean Dague                                       Mid-Hudson Valley
sean at dague dot net                            Linux Users Group
http://dague.net                                 http://mhvlug.org

There is no silver bullet.  Plus, werewolves make better neighbors
than zombies, and they tend to keep the vampire population down.
__________________________________________________________________

Attachment: pgpYbP8CcujMU.pgp
Description: PGP signature

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel