Land #10717, Enhance msfdb to check path for required commands
commit
c23e6cce5a
36
msfdb
36
msfdb
|
@ -12,6 +12,17 @@ require 'sysrandom/securerandom'
|
||||||
require 'uri'
|
require 'uri'
|
||||||
require 'yaml'
|
require 'yaml'
|
||||||
|
|
||||||
|
msfbase = __FILE__
|
||||||
|
while File.symlink?(msfbase)
|
||||||
|
msfbase = File.expand_path(File.readlink(msfbase), File.dirname(msfbase))
|
||||||
|
end
|
||||||
|
|
||||||
|
$:.unshift(File.expand_path(File.join(File.dirname(msfbase), 'lib')))
|
||||||
|
$:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']
|
||||||
|
|
||||||
|
require 'msf/util/helper'
|
||||||
|
|
||||||
|
|
||||||
@script_name = File.basename(__FILE__)
|
@script_name = File.basename(__FILE__)
|
||||||
@framework = File.expand_path(File.dirname(__FILE__))
|
@framework = File.expand_path(File.dirname(__FILE__))
|
||||||
|
|
||||||
|
@ -906,6 +917,27 @@ def invoke_command(commands, component, command)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def has_requirements
|
||||||
|
ret_val = true
|
||||||
|
postgresql_cmds = %w(psql pg_ctl initdb createdb)
|
||||||
|
other_cmds = %w(bundle thin)
|
||||||
|
missing_msg = 'Missing requirement: %<name>s does not appear to be installed or is not in the environment path'
|
||||||
|
|
||||||
|
unless postgresql_cmds.all? { |cmd| !Msf::Util::Helper.which(cmd).nil? }
|
||||||
|
puts missing_msg % { name: 'PostgreSQL' }
|
||||||
|
ret_val = false
|
||||||
|
end
|
||||||
|
|
||||||
|
other_cmds.each do |cmd|
|
||||||
|
if Msf::Util::Helper.which(cmd).nil?
|
||||||
|
puts missing_msg % { name: "'#{cmd}'" }
|
||||||
|
ret_val = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
ret_val
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if $PROGRAM_NAME == __FILE__
|
if $PROGRAM_NAME == __FILE__
|
||||||
|
@ -915,6 +947,10 @@ if $PROGRAM_NAME == __FILE__
|
||||||
abort
|
abort
|
||||||
end
|
end
|
||||||
|
|
||||||
|
unless has_requirements
|
||||||
|
abort
|
||||||
|
end
|
||||||
|
|
||||||
# map component commands to methods
|
# map component commands to methods
|
||||||
commands = {
|
commands = {
|
||||||
database: {
|
database: {
|
||||||
|
|
Loading…
Reference in New Issue