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

Issue with Task 4.4.3.4.1 Ensure pam_unix does not include nullok #375

Open
msachikanta opened this issue May 15, 2024 · 1 comment
Open
Assignees
Labels
bug Something isn't working

Comments

@msachikanta
Copy link

msachikanta commented May 15, 2024

Describe the Issue
Noticed regex is not updating the values properly in /etc/pam.d/password-auth and /etc/pam.d/system-auth.

ansible.builtin.replace section of the Task 4.4.3.4.1 seems not to be working as expected.

- name: "4.4.3.4.1 | PATCH | Ensure pam_unix does not include nullok | pam_files"
  when:
      - discovered_pam_nullok.stdout | length > 0
      - not rhel8cis_allow_authselect_updates
  ansible.builtin.replace:
      path: "/etc/pam.d/{{ item }}-auth"
      regexp: ^(\s*password\s+(requisite|required|sufficient)\s+pam_unix\.so)(.*)nullok(.*$)
      replace: \1\2\3
  loop:
      - password
      - system

I could see its updating the pam files as below:

password    sufficient                                   pam_unix.sosufficient sha512 shadow

word sufficient is getting replaced with nullok, which should not be happening.

Expected Behavior
After updating the pam files, they should have following line:

password    sufficient                                   pam_unix.so sha512 shadow

Actual Behavior
After updating the pam files, the line is appearing as below:

password    sufficient                                   pam_unix.sosufficient sha512 shadow

Environment (please complete the following information):

  • branch being used: [e.g. devel]

Additional Notes
Updating the regex can fix the issue.

Possible Solution
Here is my proposed solution. I have tested the fix, and it is working fine for me.

 ansible.builtin.replace:
      path: "/etc/pam.d/{{ item }}-auth"
      regexp: (^\s*password\s+(requisite|required|sufficient)\s+pam_unix\.so\s+.*)(nullok)(\s*.*)$
      replace: \1\4
@msachikanta msachikanta added the bug Something isn't working label May 15, 2024
@msachikanta msachikanta changed the title Issue with Task 4.4.3.4.1 | PATCH | Ensure pam_unix does not include nullok Issue with Task 4.4.3.4.1 Ensure pam_unix does not include nullok May 15, 2024
@uk-bolly uk-bolly self-assigned this May 17, 2024
@uk-bolly
Copy link
Member

hi @msachikanta

Thank you for raising this issue, i'm looking and putting a few fixes together and submitting the PR shortly.

Many thanks

uk-bolly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants