From 8ed8818e7484d8b4de88226e7fcf3a9b4aacc3aa Mon Sep 17 00:00:00 2001 From: bybai Date: Thu, 24 Sep 2015 04:13:24 -0400 Subject: [PATCH] fix issue pping cannot connect sqlsite under non-root user --- xCAT-client/bin/pping | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/xCAT-client/bin/pping b/xCAT-client/bin/pping index 731a1f9f2..e82da4313 100755 --- a/xCAT-client/bin/pping +++ b/xCAT-client/bin/pping @@ -54,6 +54,8 @@ unless (@ARGV) { } my $noderange = $ARGV[0]; my @nodes=(); +my $cmd="id -u"; +my $userid = xCAT::Utils->runcmd("$cmd", -1); if ($::NOEXPAND) { # this is when ppping is calling us and has already expanded the noderange @nodes = split(/,/, $noderange); @@ -170,16 +172,23 @@ sub fping_pping { } sub nmap_pping { - my $nodes = shift; + my $nodes = shift; my %deadnodes; + my @nmap_options; + my $more_options; + my $tcmd; foreach (@$nodes) { $deadnodes{$_}=1; } - # get additional options from site table - my @nmap_options = xCAT::TableUtils->get_site_attribute("nmapoptions"); - my $more_options = $nmap_options[0]; - - open (FPING, "nmap -PE --unprivileged --system-dns --send-ip -sP $more_options ".join(' ',@$nodes). " 2> /dev/null|") or die("Cannot open nmap pipe: $!"); + if ( $userid != 0 ) { + $tcmd ="tabdump site|grep nmapoptions|awk -F, '{print $2}'|sed -e 's/\"//g'|awk -F, '{print $1}'"; + $more_options = xCAT::Utils->runcmd($tcmd, -1); + } else { + # get additional options from site table + @nmap_options = xCAT::TableUtils->get_site_attribute("nmapoptions"); + $more_options = $nmap_options[0]; + } + open (FPING, "nmap -PE --system-dns --send-ip -sP $more_options ".join(' ',@$nodes). " 2> /dev/null|") or die("Cannot open nmap pipe: $!"); my $node; while () { if (/Host (.*) \(.*\) appears to be up/) {