From eb3d6640aa4d0c863f9e3941bd1b94fa69493bf6 Mon Sep 17 00:00:00 2001 From: steve Date: Fri, 23 Feb 2007 08:15:02 +0000 Subject: [PATCH] 2007-02-23 08:15:02 by steve Don't add/modify users if we're not root. Never touch the root user. --- bin/xt-create-xen-config | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/bin/xt-create-xen-config b/bin/xt-create-xen-config index 8953830..8dc4efc 100755 --- a/bin/xt-create-xen-config +++ b/bin/xt-create-xen-config @@ -103,7 +103,7 @@ xt-create-config - Create a Xen configuration file for a new guest -- http://www.steve.org.uk/ - $Id: xt-create-xen-config,v 1.32 2007-02-22 19:42:49 steve Exp $ + $Id: xt-create-xen-config,v 1.33 2007-02-23 08:15:02 steve Exp $ =cut @@ -121,6 +121,7 @@ The LICENSE file contains the full text of the license. use strict; +use English; use Env; use Getopt::Long; use Pod::Usage; @@ -222,7 +223,7 @@ sub parseCommandLineArguments if ( $VERSION ) { - my $REVISION = '$Revision: 1.32 $'; + my $REVISION = '$Revision: 1.33 $'; if ( $REVISION =~ /1.([0-9.]+) / ) { $REVISION = $1; @@ -422,6 +423,11 @@ sub createXenConfig sub setupAdminUsers { + # + # If we're not root we can't modify users. + # + return if ( $EFFECTIVE_USER_ID != 0 ); + # # Find the path to the xen-login-shell # @@ -441,6 +447,9 @@ sub setupAdminUsers $user =~ s/^\s+//; $user =~ s/\s+$//; + # Ignore root + next if ( $user =~ /^root$/i ); + # Does the user exist? if ( getpwnam($user) ) {