Skip to content

Commit b3e8987

Browse files
committed
Land 3694, msfconsole.rc wasn't loading, add yard
2 parents 97754af + 19d6fec commit b3e8987

File tree

1 file changed

+24
-30
lines changed

1 file changed

+24
-30
lines changed

lib/msf/ui/console/driver.rb

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,9 @@ module Msf
1515
module Ui
1616
module Console
1717

18-
###
1918
#
20-
# This class implements a user interface driver on a console interface.
19+
# A user interface driver on a console interface.
2120
#
22-
###
23-
2421
class Driver < Msf::Ui::Driver
2522

2623
ConfigCore = "framework/core"
@@ -44,21 +41,18 @@ class Driver < Msf::Ui::Driver
4441
# prompt character. The optional hash can take extra values that will
4542
# serve to initialize the console driver.
4643
#
47-
# The optional hash values can include:
48-
#
49-
# AllowCommandPassthru
50-
#
51-
# Whether or not unknown commands should be passed through and executed by
52-
# the local system.
53-
#
54-
# RealReadline
55-
#
56-
# Whether or to use the system Readline or the RBReadline (default)
57-
#
58-
# HistFile
59-
#
60-
# Name of a file to store command history
61-
#
44+
# @option opts [Boolean] 'AllowCommandPassthru' (true) Whether to allow
45+
# unrecognized commands to be executed by the system shell
46+
# @option opts [Boolean] 'RealReadline' (false) Whether to use the system's
47+
# readline library instead of RBReadline
48+
# @option opts [String] 'HistFile' (Msf::Config.history_file) Path to a file
49+
# where we can store command history
50+
# @option opts [Array<String>] 'Resources' ([]) A list of resource files to
51+
# load. If no resources are given, will load the default resource script,
52+
# 'msfconsole.rc' in the user's {Msf::Config.config_directory config
53+
# directory}
54+
# @option opts [Boolean] 'SkipDatabaseInit' (false) Whether to skip
55+
# connecting to the database and running migrations
6256
def initialize(prompt = DefaultPrompt, prompt_char = DefaultPromptChar, opts = {})
6357

6458
# Choose a readline library before calling the parent
@@ -253,14 +247,14 @@ def initialize(prompt = DefaultPrompt, prompt_char = DefaultPromptChar, opts = {
253247
# Process things before we actually display the prompt and get rocking
254248
on_startup(opts)
255249

256-
# Process the resource script
257-
if opts['Resource'] and opts['Resource'].kind_of? Array
250+
# Process any resource scripts
251+
if opts['Resource'].empty?
252+
# None given, load the default
253+
load_resource(File.join(Msf::Config.config_directory, 'msfconsole.rc'))
254+
else
258255
opts['Resource'].each { |r|
259256
load_resource(r)
260257
}
261-
else
262-
# If the opt is nil here, we load ~/.msf3/msfconsole.rc
263-
load_resource(opts['Resource'])
264258
end
265259

266260
# Process any additional startup commands
@@ -433,11 +427,11 @@ def save_config
433427
end
434428
end
435429

430+
# Processes a resource script file for the console.
436431
#
437-
# Processes the resource script file for the console.
438-
#
439-
def load_resource(path=nil)
440-
path ||= File.join(Msf::Config.config_directory, 'msfconsole.rc')
432+
# @param path [String] Path to a resource file to run
433+
# @return [void]
434+
def load_resource(path)
441435
return if not ::File.readable?(path)
442436
resource_file = ::File.read(path)
443437

@@ -605,9 +599,9 @@ def on_variable_unset(glob, var)
605599
# The framework instance associated with this driver.
606600
#
607601
attr_reader :framework
608-
#
602+
#
609603
# Whether or not to confirm before exiting
610-
#
604+
#
611605
attr_reader :confirm_exit
612606
#
613607
# Whether or not commands can be passed through.

0 commit comments

Comments
 (0)