diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/ShellBasedIdMapping.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/ShellBasedIdMapping.java index 20bccd5e86..27761da9b0 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/ShellBasedIdMapping.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/ShellBasedIdMapping.java @@ -179,7 +179,7 @@ public class ShellBasedIdMapping implements IdMappingServiceProvider { + "The host system with duplicated user/group name or id might work fine most of the time by itself.\n" + "However when NFS gateway talks to HDFS, HDFS accepts only user and group name.\n" + "Therefore, same name means the same user or same group. To find the duplicated names/ids, one can do:\n" - + " and on Linux systems,\n" + + " and on Linux, BSD and Solaris systems,\n" + " and on MacOS."; private static void reportDuplicateEntry(final String header, @@ -273,7 +273,8 @@ public class ShellBasedIdMapping implements IdMappingServiceProvider { } private boolean checkSupportedPlatform() { - if (!OS.startsWith("Linux") && !OS.startsWith("Mac")) { + if (!OS.startsWith("Linux") && !OS.startsWith("Mac") + && !OS.equals("SunOS") && !OS.contains("BSD")) { LOG.error("Platform is not supported:" + OS + ". Can't update user map and group map and" + " 'nobody' will be used for any user and group."); @@ -385,7 +386,7 @@ public class ShellBasedIdMapping implements IdMappingServiceProvider { // OR // id -u | awk '{print ":"$1 }' // - private String getName2IdCmdLinux(final String name, final boolean isGrp) { + private String getName2IdCmdNIX(final String name, final boolean isGrp) { String cmd; if (isGrp) { cmd = "getent group " + name + " | cut -d: -f1,3"; @@ -396,7 +397,7 @@ public class ShellBasedIdMapping implements IdMappingServiceProvider { } // search for name with given id, return ":" - private String getId2NameCmdLinux(final int id, final boolean isGrp) { + private String getId2NameCmdNIX(final int id, final boolean isGrp) { String cmd = "getent "; cmd += isGrp? "group " : "passwd "; cmd += String.valueOf(id) + " | cut -d: -f1,3"; @@ -466,14 +467,14 @@ public class ShellBasedIdMapping implements IdMappingServiceProvider { boolean updated = false; updateStaticMapping(); - if (OS.startsWith("Linux")) { + if (OS.startsWith("Linux") || OS.equals("SunOS") || OS.contains("BSD")) { if (isGrp) { updated = updateMapInternal(gidNameMap, "group", - getName2IdCmdLinux(name, true), ":", + getName2IdCmdNIX(name, true), ":", staticMapping.gidMapping); } else { updated = updateMapInternal(uidNameMap, "user", - getName2IdCmdLinux(name, false), ":", + getName2IdCmdNIX(name, false), ":", staticMapping.uidMapping); } } else { @@ -502,14 +503,14 @@ public class ShellBasedIdMapping implements IdMappingServiceProvider { boolean updated = false; updateStaticMapping(); - if (OS.startsWith("Linux")) { + if (OS.startsWith("Linux") || OS.equals("SunOS") || OS.contains("BSD")) { if (isGrp) { updated = updateMapInternal(gidNameMap, "group", - getId2NameCmdLinux(id, true), ":", + getId2NameCmdNIX(id, true), ":", staticMapping.gidMapping); } else { updated = updateMapInternal(uidNameMap, "user", - getId2NameCmdLinux(id, false), ":", + getId2NameCmdNIX(id, false), ":", staticMapping.uidMapping); } } else {