mirror of
				https://github.com/xcat2/xcat-core.git
				synced 2025-11-03 21:02:34 +00:00 
			
		
		
		
	block the command if run by non-root users (#5438)
This commit is contained in:
		@@ -67,6 +67,13 @@ if ($::HELP)
 | 
			
		||||
    exit(0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
my $current_usr = getpwuid($>);
 | 
			
		||||
if ($current_usr ne "root")
 | 
			
		||||
{
 | 
			
		||||
    print "Can't run this command for non-root user\n";
 | 
			
		||||
    exit(1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
my $switchestab;
 | 
			
		||||
my $switchhash;
 | 
			
		||||
my $passwdtab;
 | 
			
		||||
 
 | 
			
		||||
@@ -62,6 +62,13 @@ if ($::HELP)
 | 
			
		||||
    exit(0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
my $current_usr = getpwuid($>);
 | 
			
		||||
if ($current_usr ne "root")
 | 
			
		||||
{
 | 
			
		||||
    print "Can't run this command for non-root user\n";
 | 
			
		||||
    exit(1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
if ($::SWITCH)
 | 
			
		||||
{
 | 
			
		||||
    my @filternodes = xCAT::NodeRange::noderange( $::SWITCH );
 | 
			
		||||
 
 | 
			
		||||
@@ -61,6 +61,13 @@ if ($::HELP)
 | 
			
		||||
    exit(0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
my $current_usr = getpwuid($>);
 | 
			
		||||
if ($current_usr ne "root")
 | 
			
		||||
{
 | 
			
		||||
    print "Can't run this command for non-root user\n";
 | 
			
		||||
    exit(1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
if ($::SWITCH) {
 | 
			
		||||
    my @filternodes = xCAT::NodeRange::noderange( $::SWITCH );
 | 
			
		||||
    if (nodesmissed) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user