2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-22 03:32:04 +00:00

block the command if run by non-root users (#5438)

This commit is contained in:
cxhong 2018-07-26 22:52:24 -04:00 committed by yangsong
parent 9e161adf7c
commit ce42f6e03e
3 changed files with 21 additions and 0 deletions

View File

@ -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;

View File

@ -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 );

View File

@ -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) {