Add load_resource exception for msfconsole.rc

This prevents msfconsole from erroring on a nonexistent msfconsole.rc.
bug/bundler_fix
William Vu 2015-03-20 16:25:31 -05:00
parent 8cec8e68ac
commit 259e95ed21
2 changed files with 8 additions and 7 deletions

View File

@ -243,16 +243,16 @@ class Core
args.each do |res| args.each do |res|
good_res = nil good_res = nil
if (File.file? res and File.readable? res) if ::File.exists?(res)
good_res = res good_res = res
elsif elsif
# let's check to see if it's in the scripts/resource dir (like when tab completed) # let's check to see if it's in the scripts/resource dir (like when tab completed)
[ [
::Msf::Config.script_directory + File::SEPARATOR + "resource", ::Msf::Config.script_directory + ::File::SEPARATOR + "resource",
::Msf::Config.user_script_directory + File::SEPARATOR + "resource" ::Msf::Config.user_script_directory + ::File::SEPARATOR + "resource"
].each do |dir| ].each do |dir|
res_path = dir + File::SEPARATOR + res res_path = dir + ::File::SEPARATOR + res
if (File.file?(res_path) and File.readable?(res_path)) if ::File.exists?(res_path)
good_res = res_path good_res = res_path
break break
end end

View File

@ -235,7 +235,8 @@ class Driver < Msf::Ui::Driver
# Process any resource scripts # Process any resource scripts
if opts['Resource'].blank? if opts['Resource'].blank?
# None given, load the default # None given, load the default
load_resource(File.join(Msf::Config.config_directory, 'msfconsole.rc')) default_resource = ::File.join(Msf::Config.config_directory, 'msfconsole.rc')
load_resource(default_resource) if ::File.exists?(default_resource)
else else
opts['Resource'].each { |r| opts['Resource'].each { |r|
load_resource(r) load_resource(r)
@ -420,7 +421,7 @@ class Driver < Msf::Ui::Driver
if path == '-' if path == '-'
resource_file = $stdin.read resource_file = $stdin.read
path = 'stdin' path = 'stdin'
elsif ::File.readable?(path) elsif ::File.exists?(path)
resource_file = ::File.read(path) resource_file = ::File.read(path)
else else
print_error("Cannot find resource script: #{path}") print_error("Cannot find resource script: #{path}")