hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject [28/50] [abbrv] hadoop git commit: HADOOP-12581. ShellBasedIdMapping needs suport for Solaris (Alan Burlison via aw)
Date Thu, 12 May 2016 23:02:20 GMT
HADOOP-12581. ShellBasedIdMapping needs suport for Solaris (Alan Burlison via aw)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/0f3d6bc6
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/0f3d6bc6
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/0f3d6bc6

Branch: refs/heads/HADOOP-12930
Commit: 0f3d6bc65e58513ee159d48daf026e64f6230bbc
Parents: 013000f
Author: Allen Wittenauer <aw@apache.org>
Authored: Thu May 12 14:42:04 2016 -0700
Committer: Allen Wittenauer <aw@apache.org>
Committed: Thu May 12 14:42:04 2016 -0700

----------------------------------------------------------------------
 .../hadoop/security/ShellBasedIdMapping.java    | 21 ++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/0f3d6bc6/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/ShellBasedIdMapping.java
----------------------------------------------------------------------
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 20bccd5..27761da 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"
-      + "<getent passwd | cut -d: -f1,3> and <getent group | cut -d: -f1,3> on
Linux systems,\n"
+      + "<getent passwd | cut -d: -f1,3> and <getent group | cut -d: -f1,3> on
Linux, BSD and Solaris systems,\n"
       + "<dscl . -list /Users UniqueID> and <dscl . -list /Groups PrimaryGroupID>
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 <name> | awk '{print "<name>:"$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 "<name>:<id>"
-  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 {


---------------------------------------------------------------------
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