Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pamd: fix idempotence issue when removing rules #54105

Merged
merged 1 commit into from
Apr 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/pamd-make-idempotence-fix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- pamd - fix idempotence issue when removing rules
2 changes: 1 addition & 1 deletion lib/ansible/modules/system/pamd.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ def remove(self, rule_type, rule_control, rule_path):
else:
self._head = current_line.next
current_line.next.prev = None
changed += 1
changed += 1

current_line = current_line.next
return changed
Expand Down
2 changes: 2 additions & 0 deletions test/units/modules/system/test_pamd.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,5 +349,7 @@ def test_add_module_arguments_where_some_existed(self):

def test_remove_rule(self):
self.assertTrue(self.pamd.remove('account', 'required', 'pam_unix.so'))
# Second run should not change anything
self.assertFalse(self.pamd.remove('account', 'required', 'pam_unix.so'))
test_rule = PamdRule('account', 'required', 'pam_unix.so')
self.assertNotIn(str(test_rule), str(self.pamd))