From ce42f6e03e79e0936a764b8da64f58e2c0a02eb1 Mon Sep 17 00:00:00 2001 From: cxhong Date: Thu, 26 Jul 2018 22:52:24 -0400 Subject: [PATCH] block the command if run by non-root users (#5438) --- xCAT-server/share/xcat/scripts/configBNT | 7 +++++++ xCAT-server/share/xcat/scripts/configMellanox | 7 +++++++ xCAT-server/share/xcat/scripts/configonie | 7 +++++++ 3 files changed, 21 insertions(+) diff --git a/xCAT-server/share/xcat/scripts/configBNT b/xCAT-server/share/xcat/scripts/configBNT index 328acd16d..7fbf4ec59 100755 --- a/xCAT-server/share/xcat/scripts/configBNT +++ b/xCAT-server/share/xcat/scripts/configBNT @@ -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; diff --git a/xCAT-server/share/xcat/scripts/configMellanox b/xCAT-server/share/xcat/scripts/configMellanox index 6a085abf6..4c6010574 100755 --- a/xCAT-server/share/xcat/scripts/configMellanox +++ b/xCAT-server/share/xcat/scripts/configMellanox @@ -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 ); diff --git a/xCAT-server/share/xcat/scripts/configonie b/xCAT-server/share/xcat/scripts/configonie index b47aa0957..3d7494af7 100755 --- a/xCAT-server/share/xcat/scripts/configonie +++ b/xCAT-server/share/xcat/scripts/configonie @@ -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) {