HADOOP-12581. ShellBasedIdMapping needs suport for Solaris (Alan Burlison via aw)
This commit is contained in:
parent
013000fbc2
commit
0f3d6bc65e
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue