From 2035b82dfda34df58ca0dad40857ee00e2cba583 Mon Sep 17 00:00:00 2001 From: ron Date: Fri, 24 Sep 2010 00:47:43 +0000 Subject: [PATCH] Fixed a really tricky bug that I spent all evening chasing. Normally, during login, every account in the list (by default, guest and anonymous) are attempted. Unless something fails badly, anonymous will work. Unfortunately, if something DOES fail badly, after the first script runs this list is empty. That means if something bad is happening, and two or more scripts are running, every script after the first will have an empty list of accounts to use, and it would fail mysteriously. This patch checks the return value from the get_next_account() function properly to see if we've run out of accounts and report that to the user rather than an ugly stacktrace. --- nselib/smb.lua | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/nselib/smb.lua b/nselib/smb.lua index c08eb4b86..4dc21c770 100644 --- a/nselib/smb.lua +++ b/nselib/smb.lua @@ -1301,6 +1301,9 @@ function start_session_extended(smb, log_errors, overrides) local os, lanmanager local username, domain, password, password_hash, hash_type + -- Set a default status_name, in case everything fails + status_name = "An unknown error has occurred" + -- Get the first account, unless they overrode it if(overrides ~= nil and overrides['username'] ~= nil) then result = true @@ -1311,6 +1314,9 @@ function start_session_extended(smb, log_errors, overrides) hash_type = overrides['hash_type'] else result, username, domain, password, password_hash, hash_type = smbauth.get_account(smb['host']) + if(not(result)) then + return result, username + end end while result ~= false do @@ -1429,6 +1435,9 @@ function start_session_extended(smb, log_errors, overrides) if(overrides == nil or overrides['username'] == nil) then smbauth.next_account(smb['host']) result, username, domain, password, password_hash, hash_type = smbauth.get_account(smb['host']) + if(not(result)) then + return false, username + end else result = false end