Forráskód Böngészése

HADOOP-19401: Improve error message when OS can't identify the current user.

Closes #7325

Signed-off-by: Shilun Fan <slfan1989@apache.org>
Signed-off-by: Steve Loughran <stevel@apache.org>
Signed-off-by: Ayush Saxena <ayushsaxena@apache.org>
(cherry picked from commit b6916ebe905eb8fac2b2b4d820bf88a5854cbec1)
(cherry picked from commit 7d699e5ffb7dee613ac6bc6bccb529ef6bb4a2a6)
Chris Nauroth 4 hónapja
szülő
commit
6305ef023c

+ 1 - 0
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/UGIExceptionMessages.java

@@ -27,6 +27,7 @@ final class UGIExceptionMessages {
   public static final String FOR_USER = " for user: ";
   public static final String FOR_PRINCIPAL = " for principal: ";
   public static final String FROM_KEYTAB = " from keytab ";
+  public static final String INVALID_UID = "Invalid UID, could not determine effective user";
   public static final String LOGIN_FAILURE = "Login failure";
   public static final String LOGOUT_FAILURE = "Logout failure";
   public static final String MUST_FIRST_LOGIN =

+ 6 - 0
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/UserGroupInformation.java

@@ -2009,6 +2009,12 @@ public class UserGroupInformation {
       }
       return ugi;
     } catch (LoginException le) {
+      String msg = le.getMessage();
+      if (msg != null && msg.contains("invalid null input")) {
+        // This error from the JDK indicates that the OS couldn't map the UID of this process to an
+        // actual user. Throw this as an IOException, because it's not related to Kerberos.
+        throw new IOException(INVALID_UID, le);
+      }
       KerberosAuthException kae =
         new KerberosAuthException(FAILURE_TO_LOGIN, le);
       if (params != null) {