1
0
mirror of synced 2026-04-16 07:56:15 +00:00

2005-12-19 18:14:47 by steve

Abort if executed by non-root users.
This commit is contained in:
steve
2005-12-19 18:14:47 +00:00
parent 36935cd75f
commit d77e4f499d

View File

@@ -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 <<E_O_ROOT;
In order to use this script you must be running with root privileges.
(This is necessary to mount the disk images to determine networking info.)
E_O_ROOT
exit;
}
my $dir = $CONFIG{'dir'} . "/domains/";