Make AR a soft dependency again

Ensures that the absence of activerecord does not prevent msfconsole
from loading. This returns us to the previous state of affairs where it
is possible to use the framework entirely without a database.

To test:
  1. rm -rf lib/gemcache/ruby/1.9.1/gems/activerecord*
  2. remove any locally installed versions of activerecord
  3. msfconsole

msfconsole should load up with a warning like so:

[-] ***
[-] * WARNING: No database support: LoadError cannot load such file -- active_record
[-] ***

... and should still be functional.
unstable
James Lee 2012-10-08 23:07:04 -05:00
parent 3888c5212f
commit 227418bd11
1 changed files with 18 additions and 19 deletions

View File

@ -1,5 +1,4 @@
# -*- coding: binary -*-
require "active_record"
require 'msf/core'
require 'msf/core/db'
@ -7,14 +6,6 @@ require 'msf/core/task_manager'
require 'fileutils'
require 'shellwords'
# Provide access to ActiveRecord models shared w/ commercial versions
require "metasploit_data_models"
# Patches issues with ActiveRecord
require "msf/core/patches/active_record"
module Msf
###
@ -36,16 +27,6 @@ class DBManager
end
end
# Only include Mdm if we're not using Metasploit commercial versions
# If Mdm::Host is defined, the dynamically created classes
# are already in the object space
begin
include MetasploitDataModels unless defined? Mdm::Host
rescue NameError => e
warn_about_rubies
raise e
end
# Provides :framework and other accessors
include Framework::Offspring
@ -117,6 +98,14 @@ class DBManager
# Database drivers can reset our KCODE, do not let them
$KCODE = 'NONE' if RUBY_VERSION =~ /^1\.8\./
require "active_record"
# Provide access to ActiveRecord models shared w/ commercial versions
require "metasploit_data_models"
# Patches issues with ActiveRecord
require "msf/core/patches/active_record"
@usable = true
rescue ::Exception => e
@ -125,6 +114,16 @@ class DBManager
return false
end
# Only include Mdm if we're not using Metasploit commercial versions
# If Mdm::Host is defined, the dynamically created classes
# are already in the object space
begin
include MetasploitDataModels unless defined? Mdm::Host
rescue NameError => e
warn_about_rubies
raise e
end
#
# Determine what drivers are available
#