Add a second_chance on cmd_use

This is a weak attempt to solve a race condition between modules loading
and cmd_use being fired. Upon startup, saved configurations, running
resource scripts, and running commands will sometimes jump ahead of the
module loading procedure.

I have not discovered where the race actually is and how to cause the
race to happen. However, the timing seems to be fairly close to a second;
by waiting three seconds after trying use again, we seem to be in the
clear, at least according to testing.

Fixes #4549, but better solutions are welcome!
This commit is contained in:
Tod Beardsley 2015-01-20 15:46:29 -06:00
parent 2cc44cc7c9
commit 63c66f66a0
No known key found for this signature in database
GPG Key ID: BD63D0A3EA19CAAC
1 changed files with 9 additions and 3 deletions

View File

@ -2418,9 +2418,15 @@ class Core
mod_name = args[0]
begin
if ((mod = framework.modules.create(mod_name)) == nil)
print_error("Failed to load module: #{mod_name}")
return false
mod = framework.modules.create(mod_name)
if mod.nil?
# Try one more time; see #4549
sleep 3
mod = framework.modules.create(mod_name)
if mod.nil?
print_error("Failed to load module: #{mod_name}")
return false
end
end
rescue Rex::AmbiguousArgumentError => info
print_error(info.to_s)