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

checkHost returns FAILURE instead of MISMATCH, MATCH or NOTFOUND #53

Open
dmp1ce opened this issue Jul 29, 2019 · 2 comments
Open

checkHost returns FAILURE instead of MISMATCH, MATCH or NOTFOUND #53

dmp1ce opened this issue Jul 29, 2019 · 2 comments

Comments

@dmp1ce
Copy link

dmp1ce commented Jul 29, 2019

I noticed that withSSH2User doesn't error when known_hosts doesn't have the hosts key. I tested in GHCi and checkHost returned FAILURE instead of NOTFOUND or MATCH. I tested with a host which is in known_hosts and a host which was not in known_hosts. I would expect checkHost to return NOTFOUND and MATCH instead of FAILURE for the two cases.

I am running Arch Linux and version 1.8.2 of libssh2 and version 0.2.0.7 of libssh2-hs library.

Is the intention for withSSH2User to only fail if MISMATCH is found? I would also expect NOTFOUND to cause an error too.

@portnov
Copy link
Owner

portnov commented Jul 29, 2019

As far as I see, there are actually two questions.

  1. Why does checkKnownHost return FAILURE and not NOTFOUND in this case? This I do not know; checkKnownHost is a trivial wrapper around libssh2's function; I assume this is expected behaivour of that function. You can consult libssh2 documentation.
  2. Why does withSSH2User (and other withSSH2* functions) check for MISMATCH only and not for other types of errors? It seems that I've seen only this type of errors while testing bindings, so I've checked only for it. I can add check for NOTFOUND and FAILURE easily. I hope noone will say this is unexpected behaivour...

@dmp1ce
Copy link
Author

dmp1ce commented Jul 29, 2019

I don't think FAILURE is the expected behavior. I think FAILURE is returned when something has gone wrong. I've looked at the documentation but I'll need to do more testing to determine how to get the other results. https://www.libssh2.org/libssh2_knownhost_check.html

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

No branches or pull requests

2 participants