Skip to content

Commit db68c13

Browse files
committed
Clean up module option assignment and defaults
1 parent 8d432a5 commit db68c13

1 file changed

Lines changed: 16 additions & 17 deletions

File tree

nxc/modules/daclread.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,12 @@ class NXCModule:
209209
def __init__(self, context=None, module_options=None):
210210
self.context = context
211211
self.module_options = module_options
212+
self.principal_sAMAccountName = None
213+
self.principal_sid = None
214+
self.action = "read"
215+
self.ace_type = "allowed"
216+
self.rights = None
217+
self.rights_guid = None
212218

213219
def options(self, context, module_options):
214220
"""
@@ -235,7 +241,7 @@ def options(self, context, module_options):
235241
self.target_SID = None
236242

237243
for option in "TARGET", "TARGET_DN":
238-
if module_options and option in module_options:
244+
if option in module_options:
239245
context.log.debug("There is a target specified!")
240246
if isfile(module_options[option]):
241247
try:
@@ -253,28 +259,21 @@ def options(self, context, module_options):
253259
context.log.fail("No target specified, please specify at least one target with the TARGET or TARGET_DN options.")
254260
sys.exit(1)
255261

256-
if module_options and "PRINCIPAL" in module_options:
262+
if "PRINCIPAL" in module_options:
257263
self.principal_sAMAccountName = module_options["PRINCIPAL"]
258-
else:
259-
self.principal_sAMAccountName = None
260-
self.principal_sid = None
261264

262-
if module_options and "ACTION" in module_options:
265+
if "ACTION" in module_options:
263266
self.action = module_options["ACTION"]
264-
else:
265-
self.action = "read"
266-
if module_options and "ACE_TYPE" in module_options:
267+
268+
if "ACE_TYPE" in module_options:
267269
self.ace_type = module_options["ACE_TYPE"]
268-
else:
269-
self.ace_type = "allowed"
270-
if module_options and "RIGHTS" in module_options:
270+
271+
if "RIGHTS" in module_options:
271272
self.rights = module_options["RIGHTS"]
272-
else:
273-
self.rights = None
274-
if module_options and "RIGHTS_GUID" in module_options:
273+
274+
if "RIGHTS_GUID" in module_options:
275275
self.rights_guid = module_options["RIGHTS_GUID"]
276-
else:
277-
self.rights_guid = None
276+
278277

279278
def on_login(self, context, connection):
280279
"""On a successful LDAP login we perform a search for the targets' SID, their Security Descriptors and the principal's SID if there is one specified"""

0 commit comments

Comments
 (0)