fixes #20, re-import default options when flushing all options
git-svn-id: file:///home/svn/framework3/trunk@4448 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
a94179aac4
commit
fbd91e48d4
|
@ -125,12 +125,9 @@ class Module
|
|||
|
||||
# Create and initialize the data store for this module
|
||||
self.datastore = ModuleDataStore.new(self)
|
||||
self.datastore.import_options(self.options, 'self', true)
|
||||
|
||||
# If there are default options, import their values into the datastore
|
||||
if (module_info['DefaultOptions'])
|
||||
self.datastore.import_options_from_hash(module_info['DefaultOptions'], true, 'self')
|
||||
end
|
||||
# Import default options into the datastore
|
||||
import_defaults
|
||||
|
||||
self.privileged = module_info['Privileged'] || false
|
||||
self.license = module_info['License'] || MSF_LICENSE
|
||||
|
@ -366,6 +363,22 @@ class Module
|
|||
self.datastore.import_options(self.options)
|
||||
end
|
||||
|
||||
#
|
||||
# Imports default options into the module's datastore, optionally clearing
|
||||
# all of the values currently set in the datastore.
|
||||
#
|
||||
def import_defaults(clear_datastore = true)
|
||||
# Clear the datastore if the caller asked us to
|
||||
self.datastore.clear if clear_datastore
|
||||
|
||||
self.datastore.import_options(self.options, 'self', true)
|
||||
|
||||
# If there are default options, import their values into the datastore
|
||||
if (module_info['DefaultOptions'])
|
||||
self.datastore.import_options_from_hash(module_info['DefaultOptions'], true, 'self')
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
# This method ensures that the options associated with this module all
|
||||
# have valid values according to each required option in the option
|
||||
|
|
|
@ -965,7 +965,15 @@ class Core
|
|||
# If all was specified, then flush all of the entries
|
||||
if args[0] == 'all'
|
||||
print_line("Flushing datastore...")
|
||||
datastore.clear
|
||||
|
||||
# Re-import default options into the module's datastore
|
||||
if (active_module and global == false)
|
||||
active_module.import_defaults
|
||||
# Or simply clear the global datastore
|
||||
else
|
||||
datastore.clear
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue