-
Notifications
You must be signed in to change notification settings - Fork 8.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HDFS-17668 Treat null SASL negotiated QOP as auth in DataTransferSasl… #7171
Conversation
💔 -1 overall
This message was automatically generated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a corner case that isn't typically encountered. There is debug log message to print negotiatedQop so i think it's this is good.
Thanks, In itself, this is likely to break the SCRAM + encrypted*Stream case. This should only be committed after after #7175 (which still needs work) |
…Util#checkSaslComplete()
On closer inspection, breaking the SCRAM + encrypted*Stream case is exactly what we need to do. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stoty , thanks for working on this! The change looks good.
I have some ideas to improve the current code below. Could you also include them in this PR?
- Change conf to have a higher precedence than env (you are right that conf is more convenient:
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/SaslMechanismFactory.java
@@ -48,9 +48,9 @@ private static synchronized String getSynchronously() {
HADOOP_SECURITY_SASL_MECHANISM_DEFAULT);
LOG.debug("{} = {} (conf)", HADOOP_SECURITY_SASL_MECHANISM_KEY, confValue);
- // env has a higher precedence than conf
- mechanism = envValue != null ? envValue
- : confValue != null ? confValue
+ // conf has a higher precedence than env
+ mechanism = confValue != null ? confValue
+ : envValue != null ? envValue
: HADOOP_SECURITY_SASL_MECHANISM_DEFAULT;
LOG.debug("SASL_MECHANISM = {} (effective)", mechanism);
return mechanism;
- Add a new
isDigestMechanism
method toSaslMechanismFactory
and use it instead ofisDefaultMechanism
:
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java
index cda502681c4..5b7abdb2a52 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java
@@ -2313,7 +2313,7 @@ private RpcSaslProto buildSaslNegotiateResponse()
// accelerate token negotiation by sending initial challenge
// in the negotiation response
if (enabledAuthMethods.contains(AuthMethod.TOKEN)
- && SaslMechanismFactory.isDefaultMechanism(AuthMethod.TOKEN.getMechanismName())) {
+ && SaslMechanismFactory.isDigestMechanism(AuthMethod.TOKEN.getMechanismName())) {
saslServer = createSaslServer(AuthMethod.TOKEN);
byte[] challenge = saslServer.evaluateResponse(new byte[0]);
RpcSaslProto.Builder negotiateBuilder =
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/SaslMechanismFactory.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/SaslMechanismFactory.java
index 5b529e2a605..c12126844cd 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/SaslMechanismFactory.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/SaslMechanismFactory.java
@@ -65,5 +65,9 @@ public static boolean isDefaultMechanism(String saslMechanism) {
return HADOOP_SECURITY_SASL_MECHANISM_DEFAULT.equals(saslMechanism);
}
+ public static boolean isDigestMechanism(String saslMechanism) {
+ return saslMechanism.startsWith("DIGEST-");
+ }
+
private SaslMechanismFactory() {}
}
\ No newline at end of file
diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/datatransfer/sasl/SaslParticipant.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/datatransfer/sasl/SaslParticipant.java
index 8743c0ccfa9..24691d74f18 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/datatransfer/sasl/SaslParticipant.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/datatransfer/sasl/SaslParticipant.java
@@ -107,7 +107,7 @@ private SaslParticipant(SaslClient saslClient) {
}
byte[] createFirstMessage() throws SaslException {
- return SaslMechanismFactory.isDefaultMechanism(MECHANISM_ARRAY[0]) ? EMPTY_BYTE_ARRAY
+ return SaslMechanismFactory.isDigestMechanism(MECHANISM_ARRAY[0]) ? EMPTY_BYTE_ARRAY
: evaluateChallengeOrResponse(EMPTY_BYTE_ARRAY);
}
Your suggested changes look fine to me, @szetszwo , but they are only tangetially related to this ticket, and there is no dependency either way. IMO those changes should be tracked in a different JIRA. I could open a JIRA for you, but since you have the patch ready, it would be better if it was in your name. |
Also, the heuristics to treat the DIGEST mechanisms differently is unneccessary. SaslClient has a dedicated method exactly for this purpose. |
Opened #7201 to replace the DIGEST name based heuristic. |
I agree with the config priority change, but again, that is outside the scope of this patch. |
Sure, let's do it separately. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 the change looks good.
…Util#checkSaslComplete()
Description of PR
HDFS-17668
Fixes handling of null negotiated QOP value for HDFS
How was this patch tested?
The specific test was not tested beyond the test suite, but the issues was detected on a cluster configured with a broken SASL mechanism.
For code changes:
LICENSE
,LICENSE-binary
,NOTICE-binary
files?