Browse Source

msfenv compatibility with Pro

MSP-9653

lib/msfenv.rb should only load the framework environment to initialize
Metasploit::Framework::Application if a Rails.application is not
defined, otherwise it will clash with the Rails application in prosvc.
Luke Imhoff 5 years ago
parent
commit
b436aeff01
No account linked to committer's email address
1 changed files with 7 additions and 1 deletions
  1. 7
    1
      lib/msfenv.rb

+ 7
- 1
lib/msfenv.rb View File

@@ -10,4 +10,10 @@ require 'pathname'
10 10
 root = Pathname.new(__FILE__).expand_path.parent.parent
11 11
 config = root.join('config')
12 12
 require config.join('boot')
13
-require config.join('environment')
13
+
14
+# Requiring environment will define the Metasploit::Framework::Application as the one and only Rails::Application in
15
+# this process and cause an error if a Rails.application is already defined, such as when loading msfenv through
16
+# msfconsole in Metasploit Pro.
17
+unless defined?(Rails) && !Rails.application.nil?
18
+  require config.join('environment')
19
+end

Loading…
Cancel
Save