@@ -7,26 +7,32 @@ module ModulePaths
7
7
#
8
8
# @return [void]
9
9
def init_module_paths ( opts = { } )
10
- # Ensure the module cache is accurate
11
- self . modules . refresh_cache_from_database
10
+ if @module_paths_inited
11
+ fail "Module paths already initialized. To add more module paths call `modules.add_module_path`"
12
+ else
13
+ # Ensure the module cache is accurate
14
+ self . modules . refresh_cache_from_database
12
15
13
- add_engine_module_paths ( Rails . application , opts )
16
+ add_engine_module_paths ( Rails . application , opts )
14
17
15
- Rails . application . railties . engines . each do |engine |
16
- add_engine_module_paths ( engine , opts )
17
- end
18
+ Rails . application . railties . engines . each do |engine |
19
+ add_engine_module_paths ( engine , opts )
20
+ end
18
21
19
- # Initialize the user module search path
20
- if ( Msf ::Config . user_module_directory )
21
- self . modules . add_module_path ( Msf ::Config . user_module_directory , opts )
22
- end
22
+ # Initialize the user module search path
23
+ if ( Msf ::Config . user_module_directory )
24
+ self . modules . add_module_path ( Msf ::Config . user_module_directory , opts )
25
+ end
26
+
27
+ # If additional module paths have been defined globally, then load them.
28
+ # They should be separated by semi-colons.
29
+ if self . datastore [ 'MsfModulePaths' ]
30
+ self . datastore [ 'MsfModulePaths' ] . split ( ";" ) . each { |path |
31
+ self . modules . add_module_path ( path , opts )
32
+ }
33
+ end
23
34
24
- # If additional module paths have been defined globally, then load them.
25
- # They should be separated by semi-colons.
26
- if self . datastore [ 'MsfModulePaths' ]
27
- self . datastore [ 'MsfModulePaths' ] . split ( ";" ) . each { |path |
28
- self . modules . add_module_path ( path , opts )
29
- }
35
+ @module_paths_inited = true
30
36
end
31
37
end
32
38
0 commit comments