From c88c6c57aa79e8a1f33d2e075491656f472c858b Mon Sep 17 00:00:00 2001 From: Brandon Li Date: Mon, 29 Sep 2014 15:05:43 -0700 Subject: [PATCH] HADOOP-11130. NFS updateMaps OS check is reversed. Contributed by Brandon Li --- hadoop-common-project/hadoop-common/CHANGES.txt | 2 ++ .../org/apache/hadoop/nfs/nfs3/IdUserGroup.java | 17 ++++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index ea1d8fde58..9d0816f041 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -763,6 +763,8 @@ Release 2.6.0 - UNRELEASED HADOOP-1110. JavaKeystoreProvider should not report a key as created if it was not flushed to the backing file. + HADOOP-11130. NFS updateMaps OS check is reversed (brandonli) + BREAKDOWN OF HDFS-6134 AND HADOOP-10150 SUBTASKS AND RELATED JIRAS HADOOP-10734. Implement high-performance secure random number sources. diff --git a/hadoop-common-project/hadoop-nfs/src/main/java/org/apache/hadoop/nfs/nfs3/IdUserGroup.java b/hadoop-common-project/hadoop-nfs/src/main/java/org/apache/hadoop/nfs/nfs3/IdUserGroup.java index 1a7a3f442c..0098b47f4b 100644 --- a/hadoop-common-project/hadoop-nfs/src/main/java/org/apache/hadoop/nfs/nfs3/IdUserGroup.java +++ b/hadoop-common-project/hadoop-nfs/src/main/java/org/apache/hadoop/nfs/nfs3/IdUserGroup.java @@ -45,8 +45,8 @@ public class IdUserGroup { private final static String OS = System.getProperty("os.name"); /** Shell commands to get users and groups */ - static final String LINUX_GET_ALL_USERS_CMD = "getent passwd | cut -d: -f1,3"; - static final String LINUX_GET_ALL_GROUPS_CMD = "getent group | cut -d: -f1,3"; + static final String GET_ALL_USERS_CMD = "getent passwd | cut -d: -f1,3"; + static final String GET_ALL_GROUPS_CMD = "getent group | cut -d: -f1,3"; static final String MAC_GET_ALL_USERS_CMD = "dscl . -list /Users UniqueID"; static final String MAC_GET_ALL_GROUPS_CMD = "dscl . -list /Groups PrimaryGroupID"; @@ -223,17 +223,16 @@ synchronized public void updateMaps() throws IOException { + "' does not exist."); } - if (OS.startsWith("Linux")) { - updateMapInternal(uMap, "user", LINUX_GET_ALL_USERS_CMD, ":", - staticMapping.uidMapping); - updateMapInternal(gMap, "group", LINUX_GET_ALL_GROUPS_CMD, ":", - staticMapping.gidMapping); - } else { - // Mac + if (OS.startsWith("Mac")) { updateMapInternal(uMap, "user", MAC_GET_ALL_USERS_CMD, "\\s+", staticMapping.uidMapping); updateMapInternal(gMap, "group", MAC_GET_ALL_GROUPS_CMD, "\\s+", staticMapping.gidMapping); + } else { + updateMapInternal(uMap, "user", GET_ALL_USERS_CMD, ":", + staticMapping.uidMapping); + updateMapInternal(gMap, "group", GET_ALL_GROUPS_CMD, ":", + staticMapping.gidMapping); } uidNameMap = uMap;