Backport/2.7/54105 pamd: fix idempotence issue when removing rules (#54105)

This commit is contained in:
Łukasz Szczęsny 2019-04-01 16:18:33 +02:00 committed by Toshio Kuratomi
parent 384781d0ea
commit 110b60fdb8
3 changed files with 5 additions and 1 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- Backport of https://github.com/ansible/ansible/pull/54105, pamd - fix idempotence issue when removing rules

View file

@ -480,7 +480,7 @@ class PamdService(object):
else:
self._head = current_line.next
current_line.next.prev = None
changed += 1
changed += 1
current_line = current_line.next
return changed

View file

@ -349,5 +349,7 @@ session required pam_unix.so"""
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))