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

Fix rule ubtu 20 010066 #12296

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# platform = multi_platform_ubuntu
# reboot = false
# strategy = restrict
# complexity = low
# disruption = low
{{%- set pam_package = "libpam-pkcs11" %}}

- name: "{{{ rule_title }}} - Gather Package Facts"
ansible.builtin.package_facts:

- name: "{{{ rule_title }}} - Check if cert_policy in /etc/pam_pkcs11/pam_pkcs11.conf Is Already Set"
ansible.builtin.lineinfile:
path: /etc/pam_pkcs11/pam_pkcs11.conf
regexp: ^(\s*)cert_policy\s+.*
state: absent
check_mode: true
changed_when: false
register: cert_policy_replace
when: '"{{{ pam_package }}}" in ansible_facts.packages'

- name: "{{{ rule_title }}} - Ensure 'none' Parameter for cert_policy in /etc/pam_pkcs11/pam_pkcs11.conf Is Removed"
ansible.builtin.replace:
path: /etc/pam_pkcs11/pam_pkcs11.conf
regexp: (^\s*cert_policy\s*=\s*)none\s*;(\s*$)
replace: \g<1>ca,signature,ocsp_on,crl_auto;\g<2>
when:
- cert_policy_replace.found > 0
- '"{{{ pam_package }}}" in ansible_facts.packages'

- name: "{{{ rule_title }}} - Add 'crl_auto' Parameter for cert_policy in /etc/pam_pkcs11/pam_pkcs11.conf"
ansible.builtin.replace:
path: /etc/pam_pkcs11/pam_pkcs11.conf
regexp: (^\s*cert_policy\s*=\s*)(?!.*crl_auto)(.*)
replace: \g<1>crl_auto,\g<2>
when:
- cert_policy_replace.found > 0
- '"{{{ pam_package }}}" in ansible_facts.packages'

- name: "{{{ rule_title }}} - Add cert_policy if It Does Not Exist"
ansible.builtin.lineinfile:
path: /etc/pam_pkcs11/pam_pkcs11.conf
line: cert_policy = ca,signature,ocsp_on,crl_auto;
state: present
create: true
when:
- cert_policy_replace.found == 0
- '"{{{ pam_package }}}" in ansible_facts.packages'

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</ind:textfilecontent54_object>

<ind:textfilecontent54_state id="state_pam_pkcs11_cert_policy_crl" version="1">
<ind:subexpression operation="pattern match">(^|,\s*)(crl_auto|crl_offline)(\s*,|$)</ind:subexpression>
<ind:subexpression operation="pattern match">(^|,\s*)(crl_auto|crl_offline)(\s*,|$|;)</ind:subexpression>
</ind:textfilecontent54_state>

</def-group>

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
# platform = multi_platform_ubuntu
# packages = libpam-pkcs11

if [ ! -f /etc/pam_pkcs11/pam_pkcs11.conf ]; then
cp /usr/share/doc/libpam-pkcs11/examples/pam_pkcs11.conf.example /etc/pam_pkcs11/pam_pkcs11.conf
fi
mkdir -p /etc/pam_pkcs11
echo "cert_policy = ca,signature,ocsp_on,crl_auto;" > /etc/pam_pkcs11/pam_pkcs11.conf

if grep -v "^\s*\#+cert_policy" /etc/pam_pkcs11/pam_pkcs11.conf | grep -Eqv "crl_auto|crl_offline" ; then
sed -i "s/\(^[[:blank:]]*\)\(\(\#*[[:blank:]]*cert_policy[[:blank:]]*=[[:blank:]]*.*;\)[^ $]*\)/\1cert_policy = ca,signature,ocsp_on,crl_auto;/" /etc/pam_pkcs11/pam_pkcs11.conf
fi
# if [ ! -f /etc/pam_pkcs11/pam_pkcs11.conf ]; then
# cp /usr/share/doc/libpam-pkcs11/examples/pam_pkcs11.conf.example /etc/pam_pkcs11/pam_pkcs11.conf
# fi
#
# if grep -v "^\s*\#+cert_policy" /etc/pam_pkcs11/pam_pkcs11.conf | grep -Eqv "crl_auto|crl_offline" ; then
# sed -i "s/\(^[[:blank:]]*\)\(\(\#*[[:blank:]]*cert_policy[[:blank:]]*=[[:blank:]]*.*;\)[^ $]*\)/\1cert_policy = ca,signature,ocsp_on,crl_auto;/" /etc/pam_pkcs11/pam_pkcs11.conf
# fi
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
# platform = multi_platform_ubuntu
# packages = libpam-pkcs11

if [ ! -f /etc/pam_pkcs11/pam_pkcs11.conf ]; then
cp /usr/share/doc/libpam-pkcs11/examples/pam_pkcs11.conf.example /etc/pam_pkcs11/pam_pkcs11.conf
fi
mkdir -p /etc/pam_pkcs11
echo "# cert_policy = ca,signature,ocsp_on,crl_auto;" > /etc/pam_pkcs11/pam_pkcs11.conf

sed -i "/^\s*#/! s/cert_policy.*/cert_policy = ca,signature,ocsp_on;/g" /etc/pam_pkcs11/pam_pkcs11.conf
Loading