This is an automated email from the ASF dual-hosted git repository.

rmani pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ranger.git


The following commit(s) were added to refs/heads/master by this push:
     new f937360  RANGER-2633:RangerYarnAuthorizer should get the 
remoteIPaddress from the accessRequest from YARN
f937360 is described below

commit f937360f06535afccac39da7e1212820f17cbda6
Author: rmani <rm...@hortonworks.com>
AuthorDate: Thu Oct 31 00:44:49 2019 -0700

    RANGER-2633:RangerYarnAuthorizer should get the remoteIPaddress from the 
accessRequest from YARN
---
 .../authorization/yarn/authorizer/RangerYarnAuthorizer.java      | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git 
a/plugin-yarn/src/main/java/org/apache/ranger/authorization/yarn/authorizer/RangerYarnAuthorizer.java
 
b/plugin-yarn/src/main/java/org/apache/ranger/authorization/yarn/authorizer/RangerYarnAuthorizer.java
index eb473c4..4f18619 100644
--- 
a/plugin-yarn/src/main/java/org/apache/ranger/authorization/yarn/authorizer/RangerYarnAuthorizer.java
+++ 
b/plugin-yarn/src/main/java/org/apache/ranger/authorization/yarn/authorizer/RangerYarnAuthorizer.java
@@ -26,6 +26,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
@@ -307,7 +308,13 @@ class RangerYarnAccessRequest extends 
RangerAccessRequestImpl {
                super.setUser(ugi.getShortUserName());
                super.setUserGroups(Sets.newHashSet(ugi.getGroupNames()));
                super.setAccessTime(new Date());
-               super.setClientIPAddress(getRemoteIp());
+
+               String clientIPAddress = remoteIpAddress;
+               if (StringUtils.isEmpty(clientIPAddress)) {
+                       clientIPAddress = getRemoteIp();
+               }
+               super.setClientIPAddress(clientIPAddress);
+
                super.setAction(action);
                super.setRemoteIPAddress(remoteIpAddress);
                super.setForwardedAddresses(forwardedAddresses);

Reply via email to