Skip to content

Commit 569426f

Browse files
authored
Merge pull request #56408 from lorengordon/lockoutduration
Uses correct zero value for lgpo LockoutDuration
2 parents 4d21cb5 + 8f79096 commit 569426f

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

salt/modules/win_lgpo.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2615,12 +2615,18 @@ def __init__(self):
26152615
"lgpo_section": self.account_lockout_policy_gpedit_path,
26162616
"Settings": {
26172617
"Function": "_in_range_inclusive",
2618-
"Args": {"min": 0, "max": 6000000},
2618+
"Args": {
2619+
"min": 0,
2620+
"max": 6000000,
2621+
"zero_value": 0xFFFFFFFF,
2622+
},
26192623
},
26202624
"NetUserModal": {"Modal": 3, "Option": "lockout_duration"},
26212625
"Transform": {
26222626
"Get": "_seconds_to_minutes",
26232627
"Put": "_minutes_to_seconds",
2628+
"GetArgs": {"zero_value": 0xFFFFFFFF},
2629+
"PutArgs": {"zero_value": 0xFFFFFFFF},
26242630
},
26252631
},
26262632
"LockoutThreshold": {
@@ -4252,7 +4258,10 @@ def _seconds_to_minutes(cls, val, **kwargs):
42524258
"""
42534259
converts a number of seconds to minutes
42544260
"""
4261+
zero_value = kwargs.get("zero_value", 0)
42554262
if val is not None:
4263+
if val == zero_value:
4264+
return 0
42564265
return val / 60
42574266
else:
42584267
return "Not Defined"
@@ -4262,7 +4271,10 @@ def _minutes_to_seconds(cls, val, **kwargs):
42624271
"""
42634272
converts number of minutes to seconds
42644273
"""
4274+
zero_value = kwargs.get("zero_value", 0)
42654275
if val is not None:
4276+
if val == 0:
4277+
return zero_value
42664278
return val * 60
42674279
else:
42684280
return "Not Defined"

tests/integration/modules/test_win_lgpo.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,27 @@ def test_set_computer_policy_ClipboardRedirection(self):
555555
],
556556
)
557557

558+
@destructiveTest
559+
def test_set_computer_policy_LockoutDuration(self):
560+
"""
561+
Test setting LockoutDuration
562+
"""
563+
# For LockoutDuration to be meaningful, first configure
564+
# LockoutThreshold
565+
self._testSeceditPolicy("LockoutThreshold", 3, [r"^LockoutBadCount = 3"])
566+
567+
# Next set the LockoutDuration non-zero value, as this is required
568+
# before setting LockoutWindow
569+
self._testSeceditPolicy("LockoutDuration", 60, [r"^LockoutDuration = 60"])
570+
571+
# Now set LockoutWindow to a valid value <= LockoutDuration. If this
572+
# is not set, then the LockoutDuration zero value is ignored by the
573+
# Windows API (leading to a false sense of accomplishment)
574+
self._testSeceditPolicy("LockoutWindow", 60, [r"^ResetLockoutCount = 60"])
575+
576+
# set LockoutDuration zero value, the secedit zero value is -1
577+
self._testSeceditPolicy("LockoutDuration", 0, [r"^LockoutDuration = -1"])
578+
558579
@destructiveTest
559580
def test_set_computer_policy_GuestAccountStatus(self):
560581
"""

0 commit comments

Comments
 (0)