Skip to content
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

Fix problems with SASL and Kerberos #260

Closed

Conversation

jlisickigog
Copy link

Hello,

PR solves two problems we encountered when trying to use this tool to interact with our cluster. We have HortonWorks with Kerberos.

  • The first problem was "unexpected sequence number" when trying to connect to NameNode. We have now solved it by selecting the highest possible QOP during SASL negotiation, but I cannot find a convincing explanation on the web that the highest should indeed be selected. It does not seem logical, whereas for some reason it works correctly.
  • The second problem occurred when trying to upload a file, where we received an "unexpected EOF" error instead of success and an empty file on the cluster. Similarly, the file download failed. This behaviour is caused by improper SASL negotiation when connecting to a DataNode running on a privileged port. According to the https://hadoop.apache.org/docs/r3.1.0/hadoop-project-dist/hadoop-hdfs/hdfs-default.xml documentation, the dfs.data.transfer.protection parameter should be ignored when DataNode is listening on privileged port, which should cause the connection negotiation process to not send a SASL Handshake.
    Here is the link to a code which i believe is used by HDFS server.

@colinmarc
Copy link
Owner

Hi @jlisickigog, thanks for the report. This sheds some light on some of the issues people have encountered. What version of HDP are you running, out of curiosity?

@@ -49,6 +50,17 @@ func (d *SaslDialer) DialContext(ctx context.Context, network, addr string) (net
// then returns a wrapped connection or any error encountered. In the case of
// a protection setting of 'authentication', the bare connection is returned.
func (d *SaslDialer) wrapDatanodeConn(conn net.Conn) (net.Conn, error) {
if d.SkipSaslForRemotePrivilegedPort {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than making this configurable, let's just match the behavior of the java code (however objectionable) and leave a long comment.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reproducing the behavior of the java client requires explicit separation for Hadoop dfs.encrypt.data.transfer and dfs.data.transfer.protection options in the client options. When dfs.encrypt.data.transfer is set the privileged port feature is disabled and dfs.data.transfer.protection setting is ignored. I can also imagine that the calculation of the Qop level could be delegated to a special strategy that calculates this on the fly taking into account the destination host address. This probably can also cover calculating HighestQopLevel. So in the end, the strategy will expose several methods for the different places where QOP level negotiation takes place.

@@ -65,3 +65,16 @@ func ParseChallenge(challenge []byte) (*Challenge, error) {

return &ch, nil
}

// HighestQopLevel extracts most secure Qop level from the list provided as an argument.
func HighestQopLevel(qopList []string) string {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of this function, maybe change the returned challenge to have sorted Qops?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! Thanks for this great implementation!
I am in exactly the same configuration (HDFS 3.1.1, HDP 3.1.4.0) but have to run on other clusters as well and would love to have this modification merged upstream.
Could you please explain how you would want this to be implemented? I'd happily try to contribute a patch.
BR

@jlisickigog
Copy link
Author

Hi @jlisickigog, thanks for the report. This sheds some light on some of the issues people have encountered. What version of HDP are you running, out of curiosity?

HDFS 3.1.1
HDP 3.1.4.0

@colinmarc
Copy link
Owner

Merged in 6d6efa3 and 1daceb8. Sorry for leaving this so long!

@colinmarc colinmarc closed this Feb 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants