add requirements check
This commit is contained in:
@@ -32,4 +32,8 @@ class DbInterface
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
||||
def self.requirements
|
||||
Array.new
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -102,4 +102,8 @@ class PgCtl < DbInterface
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.requirements
|
||||
%w(psql pg_ctl initdb createdb)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -97,6 +97,10 @@ class PgCtlcluster < DbInterface
|
||||
end
|
||||
end
|
||||
|
||||
def self.requirements
|
||||
%w(psql pg_ctlcluster pg_dropcluster pg_createcluster pg_config)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def get_postgres_version
|
||||
|
||||
@@ -956,9 +956,8 @@ def installed?(cmd)
|
||||
!Msf::Util::Helper.which(cmd).nil?
|
||||
end
|
||||
|
||||
def has_requirements
|
||||
def has_requirements(postgresql_cmds)
|
||||
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 '%<prog>s' is not in the environment path"
|
||||
|
||||
@@ -1019,10 +1018,9 @@ if $PROGRAM_NAME == __FILE__
|
||||
abort
|
||||
end
|
||||
|
||||
if installed?("pg_ctl")
|
||||
abort unless has_requirements
|
||||
if installed?("pg_ctl") && has_requirements(PgCtl.requirements)
|
||||
@db_driver = PgCtl.new(db_path: @db, options: @options, localconf: @localconf, db_conf: @db_conf)
|
||||
elsif installed?("pg_ctlcluster")
|
||||
elsif installed?("pg_ctlcluster") && has_requirements(PgCtlcluster.requirements)
|
||||
@db_driver = PgCtlcluster.new(db_path: @db, options: @options, localconf: @localconf, db_conf: @db_conf)
|
||||
else
|
||||
abort
|
||||
|
||||
Reference in New Issue
Block a user