diff --git a/xCAT-server/lib/perl/xCAT/xcatd.pm b/xCAT-server/lib/perl/xCAT/xcatd.pm index e36e690e1..b98e05752 100644 --- a/xCAT-server/lib/perl/xCAT/xcatd.pm +++ b/xCAT-server/lib/perl/xCAT/xcatd.pm @@ -73,6 +73,11 @@ sub validate { return 0; } + my $remote_host = undef; + if ($request->{'remote_client'} && defined($request->{'remote_client'}->[0])) { + $remote_host = $request->{'remote_client'}->[0]; + } + my $policies = $policytable->getAllEntries; $policytable->close; my $rule; @@ -114,9 +119,20 @@ sub validate { #TODO: time ranges } if ($rule->{host} and $rule->{host} ne '*') { - #TODO: more complex matching (lists, noderanges?, wildcards) - next unless ($peerhost eq $rule->{host}); + if (defined($remote_host) and $remote_host ne '') { + my @tmp_hosts = split(",",$remote_host); + my $found = 0; + foreach my $tmp_host (@tmp_hosts) { + if ($tmp_host eq $rule->{host}) { + $found = 1; + last; + } + } + next unless ($found); + } else { + next unless ($peerhost eq $rule->{host}); + } } if ($rule->{commands} and $rule->{commands} ne '*') { my @commands = split(",", $rule->{commands}); diff --git a/xCAT-server/xCAT-wsapi/xcatws.cgi b/xCAT-server/xCAT-wsapi/xcatws.cgi index 84bd7c184..d08be512f 100755 --- a/xCAT-server/xCAT-wsapi/xcatws.cgi +++ b/xCAT-server/xCAT-wsapi/xcatws.cgi @@ -1373,6 +1373,10 @@ my @path = split(/\//, $pathInfo); # The uri path like /nodes/node1/... my $pageContent = ''; # Global var containing the ouptut back to the rest client my %header_info; #Global var containing the extra info to the http header my $request = { clienttype => 'ws' }; # Global var that holds the request to send to xcatd +my $remote_host = $q->remote_host(); +my ($client_name, $client_aliases) = gethostbyaddr(inet_aton($remote_host), AF_INET); +$request->{remote_client}->[0]= $client_name.','.$client_aliases; + my $format = 'json'; # The output format for a request invoke my $xmlinstalled; # Global var to speicfy whether the xml modules have been loaded