From d77e4f499d08f6f418ce5fdae912d39cb20f1534 Mon Sep 17 00:00:00 2001 From: steve Date: Mon, 19 Dec 2005 18:14:47 +0000 Subject: [PATCH] 2005-12-19 18:14:47 by steve Abort if executed by non-root users. --- xen-list-images | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/xen-list-images b/xen-list-images index 584001f..d313d9f 100755 --- a/xen-list-images +++ b/xen-list-images @@ -27,8 +27,6 @@ Show the script help =item B<--manual> Read the manual - - =back =cut @@ -40,6 +38,29 @@ Read the manual xen-list-images is a simple script which will display all the images which have been created in a given directory. + The script follows the same pattern as the other scripts, it + assumes that all images are stored beneath a prefix directory + in a layout such as this: + + $dir/domains/vm01.my.flat/ + $dir/domains/vm01.my.flat/disk.img + $dir/domains/vm01.my.flat/swap.img + + $dir/domains/vm02.my.flat/ + $dir/domains/vm02.my.flat/disk.img + $dir/domains/vm02.my.flat/swap.img + + For each subdirectory found beneath $dir/domains the image will + be tested if: + + 1. The disk.img file exists. + 2. The swap.img file exists. + 3. A configuration file /etc/xen/$name.cfg exists. + + If these conditions are met the name will be output, along with + networking information. + + =cut @@ -50,7 +71,7 @@ Read the manual -- http://www.steve.org.uk/ - $Id: xen-list-images,v 1.2 2005-12-19 18:05:47 steve Exp $ + $Id: xen-list-images,v 1.3 2005-12-19 18:14:47 steve Exp $ =cut @@ -68,6 +89,7 @@ The LICENSE file contains the full text of the license. use strict; +use English; use File::Temp qw/ tempdir /; use Getopt::Long; use Pod::Usage; @@ -104,6 +126,23 @@ if ( -e $ENV{'HOME'} . ".xen-tools.conf" ) parseCommandLineArguments(); +# +# If we're not root stop here - root can't do the mounting which +# is required to find the networking details. +# +if ( $EFFECTIVE_USER_ID != 0 ) +{ + print <