1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-09 14:11:29 +00:00

Fix SSH publickey auth checking: result was not returned.

This commit is contained in:
dmiller
2017-11-03 19:04:07 +00:00
parent 53e4e92e32
commit a33f6b7c61
2 changed files with 21 additions and 6 deletions

View File

@@ -163,12 +163,22 @@ end
--
-- @param username A username to authenticate as.
-- @param key Base64 decrypted public key.
-- @return true if the public key can be used to authenticate as the user, false otherwise
-- @return Error message if an error occurs.
function SSHConnection:publickey_canauth (username, key)
local status, err
if self.session then
libssh2.publickey_canauth(self.session, username, key)
status, err = pcall(libssh2.publickey_canauth, self.session, username, key)
if status then
-- no error thrown; return the actual result
status = err
err = nil
end
else
status = false
err = "No session established"
end
return status, err
end
return _ENV