hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [hadoop] branch trunk updated: HDFS-14176. Replace incorrect use of system property user.name. Contributed by Dinesh Chitlangia.
Date Wed, 20 Mar 2019 19:19:28 GMT
This is an automated email from the ASF dual-hosted git repository.

ajay pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 399563f  HDFS-14176. Replace incorrect use of system property user.name. Contributed
by Dinesh Chitlangia.
399563f is described below

commit 399563fec607a8c2ddc5d1a46b94a60389bef68c
Author: Ajay Kumar <ajay@apache.org>
AuthorDate: Wed Mar 20 11:20:45 2019 -0700

    HDFS-14176. Replace incorrect use of system property user.name. Contributed by Dinesh
Chitlangia.
---
 .../hdfs/server/federation/router/RouterClientProtocol.java  | 10 ++++++++--
 .../hadoop/fs/swift/snative/SwiftNativeFileSystem.java       | 12 ++++++++++--
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterClientProtocol.java
b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterClientProtocol.java
index 344401f..d603947 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterClientProtocol.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterClientProtocol.java
@@ -113,7 +113,7 @@ public class RouterClientProtocol implements ClientProtocol {
   private final ActiveNamenodeResolver namenodeResolver;
 
   /** Identifier for the super user. */
-  private final String superUser;
+  private String superUser;
   /** Identifier for the super group. */
   private final String superGroup;
   /** Erasure coding calls. */
@@ -126,7 +126,13 @@ public class RouterClientProtocol implements ClientProtocol {
     this.namenodeResolver = rpcServer.getNamenodeResolver();
 
     // User and group for reporting
-    this.superUser = System.getProperty("user.name");
+    try {
+      this.superUser = UserGroupInformation.getCurrentUser().getShortUserName();
+    } catch (IOException ex) {
+      LOG.warn("Unable to get user name. Fall back to system property " +
+          "user.name", ex);
+      this.superUser = System.getProperty("user.name");
+    }
     this.superGroup = conf.get(
         DFSConfigKeys.DFS_PERMISSIONS_SUPERUSERGROUP_KEY,
         DFSConfigKeys.DFS_PERMISSIONS_SUPERUSERGROUP_DEFAULT);
diff --git a/hadoop-tools/hadoop-openstack/src/main/java/org/apache/hadoop/fs/swift/snative/SwiftNativeFileSystem.java
b/hadoop-tools/hadoop-openstack/src/main/java/org/apache/hadoop/fs/swift/snative/SwiftNativeFileSystem.java
index 191d56f..510cb98 100644
--- a/hadoop-tools/hadoop-openstack/src/main/java/org/apache/hadoop/fs/swift/snative/SwiftNativeFileSystem.java
+++ b/hadoop-tools/hadoop-openstack/src/main/java/org/apache/hadoop/fs/swift/snative/SwiftNativeFileSystem.java
@@ -18,6 +18,7 @@
 
 package org.apache.hadoop.fs.swift.snative;
 
+import org.apache.hadoop.security.UserGroupInformation;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.hadoop.classification.InterfaceAudience;
@@ -100,7 +101,7 @@ public class SwiftNativeFileSystem extends FileSystem {
   }
 
   /**
-   * default class initialization
+   * default class initialization.
    *
    * @param fsuri path to Swift
    * @param conf  Hadoop configuration
@@ -115,7 +116,14 @@ public class SwiftNativeFileSystem extends FileSystem {
       store = new SwiftNativeFileSystemStore();
     }
     this.uri = fsuri;
-    String username = System.getProperty("user.name");
+    String username;
+    try {
+      username = UserGroupInformation.getCurrentUser().getShortUserName();
+    } catch (IOException ex) {
+      LOG.warn("Unable to get user name. Fall back to system property " +
+          "user.name", ex);
+      username = System.getProperty("user.name");
+    }
     this.workingDir = new Path("/user", username)
       .makeQualified(uri, new Path(username));
     if (LOG.isDebugEnabled()) {


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message