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

Ubuntu2004 stig profile v1r9 update #10738

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
3158229
fix naming for UBTU-20-010430
dexterle Jun 20, 2023
2ef1fed
Add UBTU-20-010181 for generating audit record for unsuccessful attem…
dexterle Jun 20, 2023
234f8bf
Fix UBTU-20-10450 STIG
dexterle Jun 20, 2023
725185d
add aide_disable_silentreports rule for UBTU-20-010451 and UBTU-20-01…
dexterle Jun 20, 2023
aeaad7a
Add Ubuntu2004 manual v1r8 disa STIG
dexterle Jun 20, 2023
a6c8736
Add aide_disable_silentreports OVAL and remediations
dexterle Jun 23, 2023
94747d3
Add UBTU-20-010462 to lock accounts without passwords
dexterle Jun 26, 2023
30eecd3
Add UBTU-20-010463 to ensure system does not allow accounts configure…
dexterle Jun 27, 2023
910b8b9
Add UBTU-20-010461 to ensure kernel module usb-storage is blacklisted…
dexterle Jun 28, 2023
74f46d9
Add UBTU-20-010401 to restrict kernel message buffer
dexterle Jun 28, 2023
e7d99c0
Add multi_platform_ubuntu to ansible remediations
dexterle Jun 30, 2023
e10688c
Modify adie db exist path for UBTU-20-010450
dexterle Jul 3, 2023
6ebd682
Fix package facts for pkcs11 UBTU-20-010033
dexterle Jul 3, 2023
bd20a4d
Fix path for aide to /etc/aide/aide.conf for UBTU-20-010205
dexterle Jul 3, 2023
2559ba5
Fix pam path for common-password for UBTU-20-010070
dexterle Jul 3, 2023
6d336c6
Fix UBTU-20-010449 ansible remediation to proper path and substitution
dexterle Jul 5, 2023
e7e88dc
Add ansible remediation for UBTU-20-010075
dexterle Jul 5, 2023
c3ca6fd
Add proper ansible remediation conditional check for UBTU-20-010060
dexterle Jul 5, 2023
72e8f38
Add pam package conditional for UBTU-20-010065
dexterle Jul 5, 2023
42d3227
Add UBTU-20-010045 for enforcing proper kex exchange algorithms
dexterle Jul 6, 2023
42ef19e
Add UBTU-20-010044 to existing ansible remediation
dexterle Jul 6, 2023
af5bbd3
Fix UBTU-20-010072 to properly set PAM config for pam_faillock
dexterle Jul 10, 2023
b9d81a1
Fix UBTU-20-010072 oval checks for accounts-pam
dexterle Jul 11, 2023
86b7764
Move regex into smaller checks and restrict ubuntu2004 tests
dexterle Jul 14, 2023
6a79941
Fix modular patterns in single test
dexterle Jul 17, 2023
e043e4d
Fix UBTU-20-010033 OVAL and Ansible
dexterle Jul 19, 2023
85eb22b
Fix UBTU-20-010066 Regex and include libpam-pkcs11 package
dexterle Jul 19, 2023
ef5e085
Fix UBTU-20-010013 OVAL and simplify ansible remediation
dexterle Jul 31, 2023
9bbf7f2
Deprecate UBTU-20-010180
dexterle Aug 2, 2023
e04cff6
Fix UBTU-20-010179 to use proper parameters and key
dexterle Aug 2, 2023
6cbcf9a
fix delete_module for UBTU-20-010181
dexterle Aug 2, 2023
dc3b56d
fix su path for UBTU-20-010136
dexterle Aug 2, 2023
56ab476
fix ssh-keysign path for UBTU-20-010141
dexterle Aug 2, 2023
69659ce
fix unix_update path for UBTU-20-010173
dexterle Aug 2, 2023
e7814a4
Fix UBTU-20-010267 and deprecate STIGs
dexterle Aug 3, 2023
d0090a5
Refactor pam conditional UBTU-20-010060
dexterle Aug 4, 2023
cb60109
Refactor pam conditional UBTU-20-010065
dexterle Aug 4, 2023
e808a31
Refactor logic and fix ocil for UBTU-20-010033
dexterle Aug 4, 2023
5e499fa
Fix excluded_files and recursive for UBTU-20-010416
dexterle Aug 7, 2023
f678cca
Fix path and add ansible remediation UBTU-20-010298
dexterle Aug 7, 2023
ee952de
Add remediation and OVAL for UBTU-20-010297
dexterle Aug 7, 2023
ee58feb
Refactor ansible remediation for UBTU-20-010072
dexterle Aug 14, 2023
b728606
Enable ansible remediation for MACs SSH UBTU-20-010043
dexterle Aug 11, 2023
f536340
Add ansible remediation for smartcard UBTU-20-010066
dexterle Aug 11, 2023
2060bc6
Fix gui banner path for UBTU-20-010002 and simplify
dexterle Aug 9, 2023
3e936dc
Add ansible for gnome messsage banner UBTU-20-010003
dexterle Aug 9, 2023
9276622
Fix ansible remediation for UBTU-20-010070
dexterle Aug 10, 2023
164dc76
Fix OVAL legacy for different regex check UBTU-20-010070
dexterle Aug 11, 2023
114455d
Add ansible remediation for log perm for UBTU-20-010122
dexterle Aug 10, 2023
f654425
Add ansible remediation for root group owner of audit for UBTU-20-010124
dexterle Aug 10, 2023
9322cab
Add ansible remediation for audispd plugin UBTU-20-010216
dexterle Aug 15, 2023
460935a
Remove remediation and OVAL for silent reports UBTU-20-010437
dexterle Aug 15, 2023
4de2afc
Remove oval package set for UBTU-20-010063
dexterle Aug 15, 2023
c77d64e
Add rsyslog ansible remediation for UBTU-20-010403
dexterle Aug 16, 2023
91182c3
Replace shell command with find for chrony.conf files on UBTU-20-010435
dexterle Aug 16, 2023
e8f79b1
Enable ansible and bash remediation for sssd for UBTU-20-010441
dexterle Aug 17, 2023
fffa887
Update Ubuntu 20.04 DISA Manual STIG to v1r9
dexterle Aug 22, 2023
98aed89
Fix ansible jinja format and use FQCN
dexterle Sep 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions components/aide.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ packages:
rules:
- aide_build_database
- aide_check_audit_tools
- aide_disable_silentreports
- aide_periodic_cron_checking
- aide_periodic_checking_systemd_timer
- aide_scan_notification
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@

{{{ ansible_instantiate_variables('var_time_service_set_maxpoll') }}}

- name: Check that /etc/ntp.conf exist
stat:
- name: "{{{ rule_title }}} - Check That /etc/ntp.conf Exist"
ansible.builtin.stat:
path: /etc/ntp.conf
register: ntp_conf_exist_result

- name: Update the maxpoll values in /etc/ntp.conf
replace:
- name: "{{{ rule_title }}} - Update the Maxpoll Values in /etc/ntp.conf"
ansible.builtin.replace:
path: /etc/ntp.conf
regexp: '^(server.*maxpoll)[ ]+[0-9]+(.*)$'
replace: '\1 {{ var_time_service_set_maxpoll }}\2'
when: ntp_conf_exist_result.stat.exists

- name: Set the maxpoll values in /etc/ntp.conf
replace:
- name: "{{{ rule_title }}} - Set the Maxpoll Values in /etc/ntp.conf"
ansible.builtin.replace:
path: /etc/ntp.conf
regexp: '(^server\s+((?!maxpoll).)*)$'
replace: '\1 maxpoll {{ var_time_service_set_maxpoll }}\n'
Expand All @@ -29,33 +29,34 @@
# since chrony_conf_path is the full path to chrony.conf
# and includes chrony.conf, that must be handled as well

- name: Check that {{{ chrony_conf_path }}} exist
stat:
- name: "{{{ rule_title }}} - Check That {{{ chrony_conf_path }}} Exist"
ansible.builtin.stat:
path: {{{ chrony_conf_path }}}
register: chrony_conf_exist_result

- name: Get get conf files from {{{ chrony_conf_path }}}
shell: |
set -o pipefail
CHRONY_NAME={{{ chrony_conf_path }}}
CHRONY_PATH=${CHRONY_NAME%%.*}
find ${CHRONY_PATH}.* -type f -name '*.conf'
register: update_chrony_files
when: chrony_conf_exist_result.stat.exists
changed_when: False

- name: Update the maxpoll values in {{{ chrony_conf_path }}}
replace:
path: "{{ item }}"
- name: "{{{ rule_title }}} - Set Chrony Path Facts"
ansible.builtin.set_fact:
chrony_path: {{{ chrony_conf_path }}}

- name: "{{{ rule_title }}} - Get Conf Files from {{ chrony_path | dirname }}"
ansible.builtin.find:
path: "{{ chrony_path | dirname }}"
patterns: '*.conf'
file_type: file
register: chrony_conf_files

- name: "{{{ rule_title }}} - Update the Maxpoll Values in {{{ chrony_conf_path }}}"
ansible.builtin.replace:
path: "{{ item.path }}"
regexp: '^((?:server|pool|peer).*maxpoll)[ ]+[0-9]+(.*)$'
replace: '\1 {{ var_time_service_set_maxpoll }}\2'
loop: "{{ update_chrony_files.stdout_lines|list|flatten|unique }}"
when: chrony_conf_exist_result.stat.exists
loop: '{{ chrony_conf_files.files }}'
when: chrony_conf_files.matched

- name: Set the maxpoll values in {{{ chrony_conf_path }}}
replace:
path: "{{ item }}"
- name: "{{{ rule_title }}} - Set the Maxpoll Values in {{{ chrony_conf_path }}}"
ansible.builtin.replace:
path: "{{ item.path }}"
regexp: '(^(?:server|pool|peer)\s+((?!maxpoll).)*)$'
replace: '\1 maxpoll {{ var_time_service_set_maxpoll }}\n'
loop: "{{ update_chrony_files.stdout_lines|list|flatten|unique }}"
when: chrony_conf_exist_result.stat.exists
loop: '{{ chrony_conf_files.files }}'
when: chrony_conf_files.matched
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# platform = multi_platform_rhel,multi_platform_fedora,multi_platform_ol,multi_platform_rhv,multi_platform_sle
# platform = multi_platform_rhel,multi_platform_fedora,multi_platform_ol,multi_platform_rhv,multi_platform_sle,multi_platform_ubuntu
# reboot = false
# strategy = restrict
# complexity = low
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# platform = Red Hat Enterprise Linux 7,Oracle Linux 7,multi_platform_sle
# platform = Red Hat Enterprise Linux 7,Oracle Linux 7,multi_platform_sle,multi_platform_ubuntu
# reboot = false
# strategy = restrict
# complexity = low
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# platform = multi_platform_ol,multi_platform_rhel,multi_platform_sle
# platform = multi_platform_ol,multi_platform_rhel,multi_platform_sle,multi_platform_ubuntu

source common.sh

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CONF_PREFIX="CRYPTO_POLICY='-oKexAlgorithms="
KEX_ALGOS="ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512"
CONF_SUFIX="'"
CONF_PREFIX_REGEX="^\s*CRYPTO_POLICY"
{{% elif product in ['ol7','rhel7','sle12','sle15'] %}}
{{% elif product in ['ol7','rhel7','sle12','sle15','ubuntu2004'] %}}
FILE_PATH='/etc/ssh/sshd_config'
CONF_PREFIX="KexAlgorithms "
KEX_ALGOS="ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# platform = multi_platform_ol,multi_platform_rhel,multi_platform_sle
# platform = multi_platform_ol,multi_platform_rhel,multi_platform_sle,multi_platform_ubuntu

source common.sh

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# platform = multi_platform_ol,multi_platform_rhel,multi_platform_sle
# platform = multi_platform_ol,multi_platform_rhel,multi_platform_sle,multi_platform_ubuntu

source common.sh

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# platform = multi_platform_ol,multi_platform_rhel,multi_platform_sle
# platform = multi_platform_ol,multi_platform_rhel,multi_platform_sle,multi_platform_ubuntu

source common.sh

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
# platform = multi_platform_ol,multi_platform_rhel,multi_platform_sle
# platform = multi_platform_ol,multi_platform_rhel,multi_platform_sle,multi_platform_ubuntu

source common.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# platform = multi_platform_ol,multi_platform_rhel,multi_platform_sle
# platform = multi_platform_ol,multi_platform_rhel,multi_platform_sle,multi_platform_ubuntu

source common.sh

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# platform = multi_platform_ol,multi_platform_rhel,multi_platform_sle
# platform = multi_platform_ol,multi_platform_rhel,multi_platform_sle,multi_platform_ubuntu

source common.sh

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# platform = Red Hat Enterprise Linux 7,Oracle Linux 7,multi_platform_sle
# platform = Red Hat Enterprise Linux 7,Oracle Linux 7,multi_platform_sle,Ubuntu 20.04
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

multi_platform_ubuntu

# reboot = false
# strategy = restrict
# complexity = low
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# platform = Red Hat Virtualization 4,multi_platform_fedora,multi_platform_ol,multi_platform_rhel,multi_platform_sle
# platform = Red Hat Virtualization 4,multi_platform_fedora,multi_platform_ol,multi_platform_rhel,multi_platform_sle,multi_platform_ubuntu
# reboot = false
# strategy = configure
# complexity = low
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# platform = Red Hat Virtualization 4,multi_platform_fedora,multi_platform_ol,multi_platform_rhel,multi_platform_sle
# platform = Red Hat Virtualization 4,multi_platform_fedora,multi_platform_ol,multi_platform_rhel,multi_platform_sle,multi_platform_ubuntu
# reboot = false
# strategy = configure
# complexity = low
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# platform = multi_platform_ubuntu
# reboot = false
# strategy = unknown
# complexity = low
# disruption = medium

- name: "{{{ rule_title }}} - Uncomment banner-message-enable for Login Warning Banner"
ansible.builtin.lineinfile:
path: /etc/gdm3/greeter.dconf-defaults
regexp: ^(#.*)(banner-message-enable=)
line: \2
backrefs: true

- name: "{{{ rule_title }}} - Set banner-message-enable to True for Login Warning Banner"
ansible.builtin.ini_file:
dest: /etc/gdm3/greeter.dconf-defaults
section: "org/gnome/login-screen"
option: banner-message-enable
value: "true"
create: yes
no_extra_spaces: yes

- name: "{{{ rule_title }}} - Dconf Update"
ansible.builtin.command: dconf update

- name: "{{{ rule_title }}} - Restart gdm3.service"
ansible.builtin.systemd:
name: gdm3
enabled: true
state: restarted
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
<def-group>
{{% if product not in ['ubuntu2004'] %}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please revert the changes to this file. we will need an specific ubuntu to handle both cis and stig.
I already have this OVAL ready to push if you want

{{%- set gui_banner_path = "/etc/dconf/db/{{{ dconf_gdm_dir }}}" %}}
{{%- else %}}
{{%- set gui_banner_path = "/etc/gdm3/greeter.dconf-defaults" %}}
{{% endif %}}

<definition class="compliance" id="dconf_gnome_banner_enabled" version="1">
{{{ oval_metadata("Enable the GNOME3 Login warning banner.") }}}
<criteria operator="OR">
<extend_definition comment="dconf installed" definition_ref="package_dconf_installed" negate="true" />
<criteria comment="Enable GUI banner and prevent user from changing it" operator="AND">
<extend_definition comment="dconf user profile exists" definition_ref="enable_dconf_user_profile" />
<criterion comment="Enable GUI banner" test_ref="test_banner_gui_enabled" />
{{% if product not in ['ubuntu2004'] %}}
<criterion comment="Prevent user from disabling banner" test_ref="test_prevent_user_banner_gui_enabled_change" />
{{% endif %}}
</criteria>
</criteria>
</definition>
Expand All @@ -18,7 +26,7 @@
</ind:textfilecontent54_test>
<ind:textfilecontent54_object id="obj_banner_gui_enabled"
version="1">
<ind:path>/etc/dconf/db/{{{ dconf_gdm_dir }}}/</ind:path>
<ind:path>{{{ gui_banner_path }}}</ind:path>
<ind:filename operation="pattern match">^.*$</ind:filename>
<ind:pattern operation="pattern match">^\[org/gnome/login-screen\]([^\n]*\n+)+?banner-message-enable=true$</ind:pattern>
<ind:instance datatype="int">1</ind:instance>
Expand All @@ -31,7 +39,7 @@
</ind:textfilecontent54_test>
<ind:textfilecontent54_object id="obj_prevent_user_banner_gui_enabled_change"
version="1">
<ind:path>/etc/dconf/db/{{{ dconf_gdm_dir }}}/locks/</ind:path>
<ind:path>{{{ gui_banner_path }}}/locks/</ind:path>
<ind:filename operation="pattern match">^.*$</ind:filename>
<ind:pattern operation="pattern match">^/org/gnome/login-screen/banner-message-enable$</ind:pattern>
<ind:instance datatype="int">1</ind:instance>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,19 @@ description: |-
screen by setting <tt>banner-message-enable</tt> to <tt>true</tt>.
<br /><br />
To enable, add or edit <tt>banner-message-enable</tt> to
{{% if product not in ['ubuntu2004'] %}}
<tt>/etc/dconf/db/{{{ dconf_gdm_dir }}}/00-security-settings</tt>. For example:
<pre>[org/gnome/login-screen]
banner-message-enable=true</pre>
Once the setting has been added, add a lock to
<tt>/etc/dconf/db/{{{ dconf_gdm_dir }}}/locks/00-security-settings-lock</tt> to prevent user modification.
For example:
<pre>/org/gnome/login-screen/banner-message-enable</pre>
{{% else %}}
<tt>/etc/gdm3/greeter.dconf-defaults</tt>. For example:
<pre>[org/gnome/login-screen]
banner-message-enable=true</pre>
{{% endif %}}
After the settings have been set, run <tt>dconf update</tt>.
The banner text must also be set.

Expand Down Expand Up @@ -70,11 +76,16 @@ ocil_clause: 'it is not'

ocil: |-
To ensure a login warning banner is enabled, run the following:
{{% if product not in ['ubuntu2004'] %}}
<pre>$ grep banner-message-enable /etc/dconf/db/{{{ dconf_gdm_dir }}}/*</pre>
If properly configured, the output should be <tt>true</tt>.
To ensure a login warning banner is locked and cannot be changed by a user, run the following:
<pre>$ grep banner-message-enable /etc/dconf/db/{{{ dconf_gdm_dir }}}/locks/*</pre>
If properly configured, the output should be <tt>/org/gnome/login-screen/banner-message-enable</tt>.
{{% else %}}
<pre>$ grep banner-message-enable /etc/dconf/db/{{{ dconf_gdm_dir }}}/*</pre>
If properly configured, the output should be <tt>true</tt>.
{{% endif %}}

fixtext: |-
Configure {{{ full_name }}} to display the Standard Mandatory DoD Notice and Consent Banner before granting access to the system.
Expand All @@ -83,9 +94,13 @@ fixtext: |-

Create a database to contain the system-wide graphical user logon settings (if it does not already exist) with the following command:

{{% if product not in ['ubuntu2004'] %}}
$ sudo touch /etc/dconf/db/local.d/01-banner-message

Add the following lines to the [org/gnome/login-screen] section of the "/etc/dconf/db/local.d/01-banner-message":
{{% else %}}
Add the following lines to the [org/gnome/login-screen] section of the "/etc/gdm3/greeter.dconf-defaults":
{{% endif %}}

[org/gnome/login-screen]

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# platform = multi_platform_ubuntu
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix format to style guide

# reboot = false
# strategy = unknown
# complexity = low
# disruption = medium
{{{ ansible_instantiate_variables("login_banner_text") }}}

- name: "{{{ rule_title }}}"
lineinfile:
path: /etc/gdm3/greeter.dconf-defaults
regexp: ^(#.*)(banner-message-text=)
line: \2
backrefs: true

- name: "{{{ rule_title }}}"
ini_file:
dest: /etc/gdm3/greeter.dconf-defaults
section: org/gnome/login-screen
option: banner-message-text
value: '{{{ ansible_deregexify_banner_dconf_gnome("login_banner_text") }}}'
create: yes
no_extra_spaces: yes

- name: Dconf Update
command: dconf update
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# platform = multi_platform_fedora,multi_platform_ol,multi_platform_rhel,multi_platform_sle,Red Hat Virtualization 4
# platform = multi_platform_fedora,multi_platform_ol,multi_platform_rhel,multi_platform_sle,Red Hat Virtualization 4,multi_platform_ubuntu
# reboot = false
# strategy = configure
# complexity = low
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
# platform = multi_platform_rhel,multi_platform_fedora,multi_platform_ol,multi_platform_rhv,multi_platform_sle
# platform = multi_platform_rhel,multi_platform_fedora,multi_platform_ol,multi_platform_rhv,multi_platform_sle,multi_platform_ubuntu
# reboot = false
# strategy = configure
# complexity = low
# disruption = medium

{{% if product in [ "sle12", "sle15" ] %}}
{{% if product in [ "sle12", "sle15" ] or product in [ "ubuntu1804", "ubuntu2004" ] %}}
{{%- set accounts_password_pam_unix_remember_file = '/etc/pam.d/common-password' -%}}
{{% else %}}
{{%- set accounts_password_pam_unix_remember_file = '/etc/pam.d/system-auth' -%}}
{{% endif %}}

{{{ ansible_instantiate_variables("var_password_pam_unix_remember") }}}

{{% if product not in ['ubuntu2004'] %}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we prefer to have checks like, if "product in", makes it easier to check, so coul you invert the if else please?


{{{ ansible_pam_pwhistory_enable(accounts_password_pam_unix_remember_file,
'requisite',
'^password.*requisite.*pam_pwquality\.so') }}}

{{{ ansible_pam_pwhistory_parameter_value(accounts_password_pam_unix_remember_file,
'remember',
'{{ var_password_pam_unix_remember }}') }}}

{{% else %}}
{{{ ansible_ensure_pam_module_line(accounts_password_pam_unix_remember_file,
"password",
"[success=1 default=ignore]",
"pam_unix.so obscure sha512 shadow remember=5 rounds=5000")}}}

{{% endif %}}
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
{{% if product in [ "sle12", "sle15" ] %}}
{{% if product in [ "sle12", "sle15" ] or product in [ "ubuntu1804", "ubuntu2004"] %}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason to drop the specific oval?

{{%- set accounts_password_pam_unix_remember_file = '/etc/pam.d/common-password' -%}}
{{% else %}}
{{%- set accounts_password_pam_unix_remember_file = '/etc/pam.d/system-auth' -%}}
{{% endif %}}
{{% if product in ["ubuntu2004"] %}}
{{%- set pam_unix_legacy_regex = '^\s*password\s+\[success=1 default=ignore\]\s+pam_unix\.so.*remember=([0-9]*).*$' %}}
{{% else %}}
{{%- set pam_unix_legacy_regex = '^\s*password\s+(?:(?:sufficient)|(?:required))\s+pam_unix\.so.*remember=([0-9]*).*$' %}}
{{% endif %}}


<def-group>
<definition class="compliance" id="{{{ rule_id }}}" version="2">
Expand Down Expand Up @@ -145,14 +151,14 @@
<!-- Check the pam_unix.so remember case -->
<ind:textfilecontent54_test id="test_accounts_password_pam_unix_remember_legacy" version="1"
check="all" check_existence="all_exist"
comment="Test if remember attribute of pam_unix.so is set correctly in /etc/pam.d/system-auth">
comment="Test if remember attribute of pam_unix.so is set correctly in {{{ accounts_password_pam_unix_remember_file }}}">
<ind:object object_ref="object_accounts_password_pam_unix_remember_legacy" />
<ind:state state_ref="state_accounts_password_pam_unix_remember" />
</ind:textfilecontent54_test>

<ind:textfilecontent54_object id="object_accounts_password_pam_unix_remember_legacy" version="1">
<ind:filepath>/etc/pam.d/system-auth</ind:filepath>
<ind:pattern operation="pattern match">^\s*password\s+(?:(?:sufficient)|(?:required))\s+pam_unix\.so.*remember=([0-9]*).*$</ind:pattern>
<ind:filepath>{{{ accounts_password_pam_unix_remember_file }}}</ind:filepath>
<ind:pattern operation="pattern match">{{{ pam_unix_legacy_regex }}}</ind:pattern>
<ind:instance datatype="int">1</ind:instance>
</ind:textfilecontent54_object>
</def-group>
Loading