fix(4.5.2): skip accounts already configured with nologin/false shell#195
Open
Buanderie wants to merge 1 commit intoansible-lockdown:develfrom
Open
fix(4.5.2): skip accounts already configured with nologin/false shell#195Buanderie wants to merge 1 commit intoansible-lockdown:develfrom
Buanderie wants to merge 1 commit intoansible-lockdown:develfrom
Conversation
nologin/false shell
|
Congrats on opening your first pull request and thank you for taking the time to help improve Ansible-Lockdown! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The 4.5.2 task iterates all system accounts (UID < UID_MIN) and
unconditionally calls
ansible.builtin.userto set shell and lock them,even when those accounts are already fully compliant.
This produces false positives: every
system account already set to
/sbin/nologinis reported as "wouldchange", inflating the non-compliance count and making the remediation
appear non-idempotent.
A common trigger is Debian/Ubuntu service accounts whose home is
/nonexistent— they ship with/sbin/nologinalready, yet areconstantly flagged.
Root cause
The CIS 4.5.2 benchmark definition targets only accounts that still
have a valid login shell. The reference audit script (e.g. Tenable
CIS_Debian_Linux_10_v2.0.0 audit id
da60f23f) uses:Accounts already on nologin / false are explicitly out of scope.
Fix
Add item.shell not in ['/sbin/nologin', '/usr/sbin/nologin',
'/bin/false']
to the when guard of both subtasks. This requires switching from
with_items + map(attribute='id') to loop over the full object so
that item.shell is accessible.
Effect
login shell are still remediated).
as drifted.
produces changed=0 on the second run.