|
22 | 22 | import org.apache.hadoop.conf.Configuration;
|
23 | 23 | import org.apache.hadoop.conf.Configured;
|
24 | 24 | import org.apache.hadoop.io.Text;
|
25 |
| -import org.apache.hadoop.security.authentication.util.KerberosName; |
26 | 25 | import org.apache.hadoop.security.token.Token;
|
27 | 26 | import org.apache.hadoop.security.token.TokenIdentifier;
|
28 | 27 | import org.apache.hadoop.util.ExitUtil;
|
|
55 | 54 | import java.util.Date;
|
56 | 55 | import java.util.LinkedList;
|
57 | 56 | import java.util.List;
|
58 |
| -import java.util.regex.Pattern; |
59 | 57 |
|
60 | 58 | import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.*;
|
61 | 59 | import static org.apache.hadoop.security.UserGroupInformation.*;
|
@@ -131,12 +129,6 @@ public class KDiag extends Configured implements Tool, Closeable {
|
131 | 129 | private boolean nofail = false;
|
132 | 130 | private boolean nologin = false;
|
133 | 131 | private boolean jaas = false;
|
134 |
| - private boolean checkShortName = false; |
135 |
| - |
136 |
| - /** |
137 |
| - * A pattern that recognizes simple/non-simple names. Per KerberosName |
138 |
| - */ |
139 |
| - private static final Pattern nonSimplePattern = Pattern.compile("[/@]"); |
140 | 132 |
|
141 | 133 | /**
|
142 | 134 | * Flag set to true if a {@link #verify(boolean, String, String, Object...)}
|
@@ -165,8 +157,6 @@ public class KDiag extends Configured implements Tool, Closeable {
|
165 | 157 |
|
166 | 158 | public static final String ARG_SECURE = "--secure";
|
167 | 159 |
|
168 |
| - public static final String ARG_VERIFYSHORTNAME = "--verifyshortname"; |
169 |
| - |
170 | 160 | @SuppressWarnings("IOResourceOpenedButNotSafelyClosed")
|
171 | 161 | public KDiag(Configuration conf,
|
172 | 162 | PrintWriter out,
|
@@ -210,7 +200,6 @@ public int run(String[] argv) throws Exception {
|
210 | 200 | nofail = popOption(ARG_NOFAIL, args);
|
211 | 201 | jaas = popOption(ARG_JAAS, args);
|
212 | 202 | nologin = popOption(ARG_NOLOGIN, args);
|
213 |
| - checkShortName = popOption(ARG_VERIFYSHORTNAME, args); |
214 | 203 |
|
215 | 204 | // look for list of resources
|
216 | 205 | String resource;
|
@@ -256,9 +245,7 @@ private String usage() {
|
256 | 245 | + arg(ARG_NOLOGIN, "", "Do not attempt to log in")
|
257 | 246 | + arg(ARG_OUTPUT, "<file>", "Write output to a file")
|
258 | 247 | + arg(ARG_RESOURCE, "<resource>", "Load an XML configuration resource")
|
259 |
| - + arg(ARG_SECURE, "", "Require the hadoop configuration to be secure") |
260 |
| - + arg(ARG_VERIFYSHORTNAME, ARG_PRINCIPAL + " <principal>", |
261 |
| - "Verify the short name of the specific principal does not contain '@' or '/'"); |
| 248 | + + arg(ARG_SECURE, "", "Require the hadoop configuration to be secure"); |
262 | 249 | }
|
263 | 250 |
|
264 | 251 | private String arg(String name, String params, String meaning) {
|
@@ -291,7 +278,6 @@ public boolean execute() throws Exception {
|
291 | 278 | println("%s = %d", ARG_KEYLEN, minKeyLength);
|
292 | 279 | println("%s = %s", ARG_KEYTAB, keytab);
|
293 | 280 | println("%s = %s", ARG_PRINCIPAL, principal);
|
294 |
| - println("%s = %s", ARG_VERIFYSHORTNAME, checkShortName); |
295 | 281 |
|
296 | 282 | // Fail fast on a JVM without JCE installed.
|
297 | 283 | validateKeyLength();
|
@@ -391,10 +377,6 @@ public boolean execute() throws Exception {
|
391 | 377 | validateJAAS(jaas);
|
392 | 378 | validateNTPConf();
|
393 | 379 |
|
394 |
| - if (checkShortName) { |
395 |
| - validateShortName(); |
396 |
| - } |
397 |
| - |
398 | 380 | if (!nologin) {
|
399 | 381 | title("Logging in");
|
400 | 382 | if (keytab != null) {
|
@@ -448,32 +430,6 @@ protected void validateKeyLength() throws NoSuchAlgorithmException {
|
448 | 430 | aesLen, minKeyLength);
|
449 | 431 | }
|
450 | 432 |
|
451 |
| - /** |
452 |
| - * Verify whether auth_to_local rules transform a principal name |
453 |
| - * <p> |
454 |
| - * Having a local user name "[email protected]" may be harmless, so it is noted at |
455 |
| - * info. However if what was intended is a transformation to "bar" |
456 |
| - * it can be difficult to debug, hence this check. |
457 |
| - */ |
458 |
| - protected void validateShortName() { |
459 |
| - failif(principal == null, CAT_KERBEROS, "No principal defined"); |
460 |
| - |
461 |
| - try { |
462 |
| - KerberosName kn = new KerberosName(principal); |
463 |
| - String result = kn.getShortName(); |
464 |
| - if (nonSimplePattern.matcher(result).find()) { |
465 |
| - warn(CAT_KERBEROS, principal + " short name: " + result |
466 |
| - + " still contains @ or /"); |
467 |
| - } |
468 |
| - } catch (IOException e) { |
469 |
| - throw new KerberosDiagsFailure(CAT_KERBEROS, e, |
470 |
| - "Failed to get short name for " + principal, e); |
471 |
| - } catch (IllegalArgumentException e) { |
472 |
| - error(CAT_KERBEROS, "KerberosName(" + principal + ") failed: %s\n%s", |
473 |
| - e, StringUtils.stringifyException(e)); |
474 |
| - } |
475 |
| - } |
476 |
| - |
477 | 433 | /**
|
478 | 434 | * Get the default realm.
|
479 | 435 | * <p>
|
|
0 commit comments