-
Notifications
You must be signed in to change notification settings - Fork 78
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
Benchmark fails: 10.5 Lock Inactive User Accounts #118
base: master
Are you sure you want to change the base?
Conversation
@@ -98,22 +98,18 @@ | |||
- section10.4 | |||
|
|||
- name: 10.5.1 Lock Inactive User Accounts (check) (Scored) | |||
command: grep INACTIVE /etc/login.defs | |||
command: bash -c "useradd -D | grep -oP '(?<=^INACTIVE=)-?[0-9]+'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is bash -c
required here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. When I just did useradd -D | grep -oP '(?<=^INACTIVE=)-?[0-9]+'
, for some reason it said that -P
was not a valid option for useradd
. I tried various methods of escaping the pipe and other things, but this is the only thing that worked.
I got the technique from http://stackoverflow.com/a/24685924. Seems like the shell
module could also be a workaround.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. In that case I think using the shell module would be cleaner, since we end up using a shell anyway. @awailly What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the command
module will execute the process, and using the shell
you will wrap the string with bash
as you did. So yes, using the shell
module is better here to keep the code simple.
Thanks for the pull request! The Travis build is failing because, when it does a second playbook run, it finds an incorrect |
The assessment tool is reporting that it is working. Digging in a little deeper, after running the role with the pull request applied, I get the following output when running the following commands as a normal user:
So, running
Looking at the |
I haven't tested, but will the user be locked if he was not created using |
The changes for the 10.5 don't appear to be sticking. The CIS-CAT Benchmark Assessment Tool suggests using the
useradd -D | grep INACTIVE
command to check the default value, which always returns-1
despite the changes written to/etc/login.defs
. The tool also suggests running theuseradd -D -f 35
command to change the setting.I am not 100% psyched about this PR, but it does result in a passing benchmark. Posting the issue to start the discussion.