diff --git a/linux_os/guide/system/accounts/accounts-physical/require_singleuser_auth/ansible/shared.yml b/linux_os/guide/system/accounts/accounts-physical/require_singleuser_auth/ansible/shared.yml index 94e34a0f82d1..e8b284ada0e5 100644 --- a/linux_os/guide/system/accounts/accounts-physical/require_singleuser_auth/ansible/shared.yml +++ b/linux_os/guide/system/accounts/accounts-physical/require_singleuser_auth/ansible/shared.yml @@ -4,13 +4,22 @@ # complexity = low # disruption = low +{{% if 'rhel' not in product %}} - name: Require single user mode password lineinfile: create: yes dest: /usr/lib/systemd/system/rescue.service regexp: "^#?ExecStart=" - {{% if product in ["fedora", "ol8", "ol9", "rhel8", "rhel9", "sle12", "sle15"] -%}} + {{% if product in ["fedora", "ol8", "ol9", "sle12", "sle15"] -%}} line: "ExecStart=-/usr/lib/systemd/systemd-sulogin-shell rescue" {{%- else -%}} line: 'ExecStart=-/bin/sh -c "/sbin/sulogin; /usr/bin/systemctl --fail --no-block default"' {{%- endif %}} +{{% else %}} +- name: "{{{ rule_title }}} - Require single user mode password" + community.general.ini_file: + path: "/etc/systemd/system/rescue.service.d/10-oscap.conf" + section: "Service" + option: "ExecStart" + value: "-/usr/lib/systemd/systemd-sulogin-shell rescue" +{{% endif %}} diff --git a/linux_os/guide/system/accounts/accounts-physical/require_singleuser_auth/bash/shared.sh b/linux_os/guide/system/accounts/accounts-physical/require_singleuser_auth/bash/shared.sh index 1d43e2d51dc9..499c22ee7089 100644 --- a/linux_os/guide/system/accounts/accounts-physical/require_singleuser_auth/bash/shared.sh +++ b/linux_os/guide/system/accounts/accounts-physical/require_singleuser_auth/bash/shared.sh @@ -1,15 +1,9 @@ # platform = multi_platform_all -service_file="/usr/lib/systemd/system/rescue.service" - {{% if product in ["fedora", "ol8", "ol9", "sle12", "sle15",] or 'rhel' in product -%}} -sulogin="/usr/lib/systemd/systemd-sulogin-shell rescue" +{{% set sulogin="/usr/lib/systemd/systemd-sulogin-shell rescue" %}} {{%- else -%}} -sulogin='/bin/sh -c "/sbin/sulogin; /usr/bin/systemctl --fail --no-block default"' +{{% set sulogin='/bin/sh -c "/sbin/sulogin; /usr/bin/systemctl --fail --no-block default"' %}} {{%- endif %}} -if grep "^ExecStart=.*" "$service_file" ; then - sed -i "s%^ExecStart=.*%ExecStart=-$sulogin%" "$service_file" -else - echo "ExecStart=-$sulogin" >> "$service_file" -fi +{{{ bash_ensure_ini_config("/etc/systemd/system/rescue.service.d/10-oscap.conf", "Service", "ExecStart", sulogin) }}} diff --git a/linux_os/guide/system/accounts/accounts-physical/require_singleuser_auth/oval/shared.xml b/linux_os/guide/system/accounts/accounts-physical/require_singleuser_auth/oval/shared.xml index 62fd1a76a257..28e4a260df26 100644 --- a/linux_os/guide/system/accounts/accounts-physical/require_singleuser_auth/oval/shared.xml +++ b/linux_os/guide/system/accounts/accounts-physical/require_singleuser_auth/oval/shared.xml @@ -5,16 +5,16 @@ - {{%- if product not in ["ol8", "rhel8"] -%}} + {{%- if product not in ["ol8"] and 'rhel' not in product -%}} - + {{%- endif -%}} + {{%- if 'rhel' in product -%}} + /etc/systemd/system/rescue.service.d + ^.*\.conf$ + {{%- else -%}} /usr/lib/systemd/system/rescue.service - {{%- if product in ["fedora", "ol8", "ol9", "rhel8", "rhel9", "rhcos4", "sle12", "sle15"] -%}} + {{%- endif -%}} + {{%- if product in ["fedora", "ol8", "ol9", "rhcos4", "sle12", "sle15"] or 'rhel' in product -%}} ^ExecStart=\-.*/usr/lib/systemd/systemd-sulogin-shell[ ]+rescue {{%- else -%}} ^ExecStart=\-/bin/sh[\s]+-c[\s]+\"(/usr)?/sbin/sulogin;[\s]+/usr/bin/systemctl[\s]+--fail[\s]+--no-block[\s]+default\" @@ -34,7 +39,7 @@ 1 - {{%- if product not in ["ol8", "rhel8"] -%}} + {{%- if product not in ["ol8"] and 'rhel' not in product -%}} diff --git a/linux_os/guide/system/accounts/accounts-physical/require_singleuser_auth/tests/correct_value.pass.sh b/linux_os/guide/system/accounts/accounts-physical/require_singleuser_auth/tests/correct_value.pass.sh index fd13fbd1c80e..c786daca324a 100644 --- a/linux_os/guide/system/accounts/accounts-physical/require_singleuser_auth/tests/correct_value.pass.sh +++ b/linux_os/guide/system/accounts/accounts-physical/require_singleuser_auth/tests/correct_value.pass.sh @@ -1,5 +1,5 @@ #!/bin/bash -# platform = Oracle Linux 8,Oracle Linux 9,Red Hat Enterprise Linux 8,Red Hat Enterprise Linux 9,multi_platform_fedora +# platform = Oracle Linux 8,Oracle Linux 9,multi_platform_fedora,multi_platform_rhel service_file="/usr/lib/systemd/system/rescue.service" sulogin="/usr/lib/systemd/systemd-sulogin-shell"