From b9e449f5e27544e55a45b011c6c5d445a1fe986f Mon Sep 17 00:00:00 2001 From: James Lee Date: Mon, 18 Aug 2014 12:40:57 -0500 Subject: [PATCH] Fix crash when database.yml doesn't exist --- lib/metasploit/framework/require.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/metasploit/framework/require.rb b/lib/metasploit/framework/require.rb index c493c834e6..760771c488 100644 --- a/lib/metasploit/framework/require.rb +++ b/lib/metasploit/framework/require.rb @@ -49,10 +49,14 @@ module Metasploit # # @return [void] def self.optionally_active_record_railtie - optionally( + if ::File.exist?(Rails.application.config.paths['config/database'].first) + optionally( 'active_record/railtie', 'activerecord not in the bundle, so database support will be disabled.' - ) + ) + else + warn 'Could not find database.yml, so database support will be disabled.' + end end # Tries to `require 'metasploit/credential/creation'` and include it in the `including_module`. @@ -89,4 +93,4 @@ module Metasploit end end end -end \ No newline at end of file +end