Skip to content

Ansible/Bash remediations: add explicit file permissions to all file-creating tasks and commands - #14947

Open
macko1 wants to merge 8 commits into
ComplianceAsCode:masterfrom
macko1:RHEL-182657-remediation-explicit-permissions
Open

Ansible/Bash remediations: add explicit file permissions to all file-creating tasks and commands#14947
macko1 wants to merge 8 commits into
ComplianceAsCode:masterfrom
macko1:RHEL-182657-remediation-explicit-permissions

Conversation

@macko1

@macko1 macko1 commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Description

Ansible and bash remediations create files without setting permissions explicitly. The resulting permissions depend on the process
umask. On default RHEL (umask 0022) that produces 0644, but on hardened systems with a stricter umask the result is
unpredictable.

This PR adds explicit permissions to file-creating remediations in:

  • Macros (Ansible and bash)
  • Templates
  • Standalone remediations

Rationale

Remediation output must be deterministic. File permissions must not depend on the runtime umask.

Permissions by file type

The values below match RPM package defaults (checked with rpm -qlv) and any existing OVAL permission checks.

  • /etc/audit/rules.d/*.rules0600 (OVAL enforced)
  • /etc/audit/auditd.conf0640 (RPM default)
  • /etc/ssh/sshd_config, /etc/ssh/sshd_config.d/*.conf0600
  • /etc/ssh/sshd_config.d/ directory → 0700
  • /etc/sssd/0600 files, 0711 directories
  • /etc/sudoers, /etc/sudoers.d/0440
  • /etc/shadow-0000
  • /etc/cron.daily/*0755
  • Directories (general) → 0755
  • /etc/profile.d/*.sh0644 (shell profile scripts, world-readable)
  • /etc/systemd/system/*.service.d/*.conf0644 (systemd drop-ins, world-readable)
  • /etc/security/limits.d/*.conf0644 (PAM limits drop-ins, world-readable)
  • /etc/tmpfiles.d/*.conf0644 (systemd tmpfiles, world-readable)
  • /etc/permissions.local0644 (SUSE permissions config, world-readable)
  • Everything else → 0644

What this PR does not change, and why

  • owner: and group: are not set, because remediations run as root and every created file is
    already owned by root:root. Adding owner: root and group: root explicitly to every task
    inflates the diff without changing the resulting file ownership.

  • /etc/sssd/sssd.conf keeps mode 0600 even though the RPM default is 0640:

    • Every rule using the bash_sssd_ensure_default_config
      macro wraps the fix in umask u=rw,go=
    • The comment there reads: "sssd configuration files must be created with 600 permissions if
      they don't exist otherwise the sssd module fails to start"
    • Changing to 0640 risks breaking SSSD startup on affected systems
  • The ansible.posix.sysctl, ansible.builtin.cron, and ansible.posix.mount Ansible modules
    don't accept a mode: parameter (confirmed from ansible-doc). Nothing to fix here.

  • The ansible.builtin.replace Ansible module never creates files. Fails with "Path does not
    exist" if the target is missing (confirmed from its module source
    ansible/modules/replace.py line 254).

  • The macros ansible_shell_set, ansible_selinux_config_set, and ansible_login_defs call
    the ansible.builtin.lineinfile Ansible module with create: yes and no mode parameter,
    but their target files' permissions already default to 0644 when installed, so the missing
    mode parameter produces the correct result by coincidence.

Changes

  • Macros (shared/macros/10-ansible.jinja, shared/macros/10-bash.jinja): added mode:/chmod
    so every caller inherits explicit permissions automatically.

  • Templates (shared/templates/): added mode:/chmod to file-creating templates so every rule
    using them is covered in one place.

  • Handwritten remediations (linux_os/): rule-specific bash/shared.sh or ansible/shared.yml
    files that don't call a macro or template, added mode: or chmod directly.

  • Bash remediations that create drop-in files via shell redirect (>>, >, cat >) without
    chmod. Affects these rules:

    • require_emergency_target_auth (systemd drop-in
      /etc/systemd/system/emergency.service.d/10-oscap.conf)
    • disable_users_coredumps (PAM limits drop-in /etc/security/limits.d/10-ssg-hardening.conf)
    • sshd_use_directory_configuration (/etc/ssh/sshd_config, corrected from 0644 to 0600)
    • accounts_tmout (/etc/profile.d/tmout.sh)
    • audit_rules_immutable_login_uids (/etc/audit/rules.d/immutable.rules)
  • Ansible remediations using the ansible_lineinfile macro with create: yes but no mode=
    parameter, so the file it creates gets no explicit mode. Affects these rules:

    • accounts_tmout (/etc/profile.d/tmout.sh)
    • rootfiles_configured (/etc/tmpfiles.d/rootfiles.conf)
    • permissions_local_var_log_audit (/etc/permissions.local, 4 ansible_lineinfile calls)
  • Ansible remediations with unquoted octal mode: values, quoted for YAML 1.1 compatibility
    (mode: 0644mode: '0644'). Only these two rules, because they're the only ones where
    this PR itself added a new mode: value that happened to be unquoted:

    • require_emergency_target_auth
    • disable_users_coredumps
    • Quoting the roughly 100 pre-existing unquoted mode: values already in the codebase is a
      separate, larger cleanup.
  • The macros ansible_auditd_set and ansible_sshd_set were missing mode:. The
    ansible_set_config_file macro they call already accepts a mode= parameter, so the fix
    was adding mode="0640" and mode="0600" to these two call sites, not new plumbing:

    • ansible_auditd_set (shared/macros/10-ansible.jinja) is unused by any ComplianceAsCode
      rule today, but is now correct if a future rule calls it
    • ansible_sshd_set writes directly into /etc/ssh/sshd_config in one mode, and to a
      separate drop-in file under /etc/ssh/sshd_config.d/ in another (controlled by
      config_is_distributed). Only the first way was missing mode:; the drop-in way already
      sets it via a separate task. Verified on the ol8 product with the sshd_rekey_limit rule.

How to test

  • Run ./build_product rhel10 and confirm it passes.
  • Run in Contest: the daily test suite, and the per-rule tests covering both ansible and
    oscap (bash).

Assisted by Claude.

@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Used by openshift-ci bot. label Jul 30, 2026
@openshift-ci

openshift-ci Bot commented Jul 30, 2026

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown

This datastream diff is auto generated by the check Compare DS/Generate Diff.
Due to the excessive size of the diff, it has been trimmed to fit the 65535-character limit.

Click here to see the trimmed diff
ansible remediation for rule 'xccdf_org.ssgproject.content_rule_aide_build_database' differs.
--- xccdf_org.ssgproject.content_rule_aide_build_database
+++ xccdf_org.ssgproject.content_rule_aide_build_database
@@ -82,6 +82,7 @@
     dest: /var/lib/aide/aide.db.gz
     backup: true
     remote_src: true
+    mode: 420
   when:
   - '"kernel-core" in ansible_facts.packages'
   - aide_database_init is changed

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_aide_check_audit_tools' differs.
--- xccdf_org.ssgproject.content_rule_aide_check_audit_tools
+++ xccdf_org.ssgproject.content_rule_aide_check_audit_tools
@@ -94,6 +94,7 @@
     regexp: ^{{ item }}\s
     line: '{{ item }} p+i+n+u+g+s+b+acl+xattrs+sha512'
     create: true
+    mode: 420
   with_items: '{{ audit_tools }}'
   when:
   - '"kernel-core" in ansible_facts.packages'
@@ -116,6 +117,7 @@
     path: /etc/aide.conf
     line: '{{ item }} p+i+n+u+g+s+b+acl+xattrs+sha512'
     create: true
+    mode: 420
   with_items: '{{ audit_tools }}'
   when:
   - '"kernel-core" in ansible_facts.packages'

bash remediation for rule 'xccdf_org.ssgproject.content_rule_enable_fips_mode' differs.
--- xccdf_org.ssgproject.content_rule_enable_fips_mode
+++ xccdf_org.ssgproject.content_rule_enable_fips_mode
@@ -5,6 +5,7 @@
 	cat > /usr/lib/bootc/kargs.d/01-fips.toml << EOF
 kargs = ["fips=1"]
 EOF
+ chmod 0644 /usr/lib/bootc/kargs.d/01-fips.toml
 fi
 
 else

bash remediation for rule 'xccdf_org.ssgproject.content_rule_fips_custom_stig_sub_policy' differs.
--- xccdf_org.ssgproject.content_rule_fips_custom_stig_sub_policy
+++ xccdf_org.ssgproject.content_rule_fips_custom_stig_sub_policy
@@ -5,6 +5,7 @@
 cipher@SSH=AES-256-GCM AES-256-CTR AES-128-GCM AES-128-CTR
 mac@SSH=HMAC-SHA2-512 HMAC-SHA2-256
 EOF
+chmod 0644 /etc/crypto-policies/policies/modules/STIG.pmod
 
 sudo update-crypto-policies --set FIPS:STIG
 

bash remediation for rule 'xccdf_org.ssgproject.content_rule_configure_custom_crypto_policy_cis' differs.
--- xccdf_org.ssgproject.content_rule_configure_custom_crypto_policy_cis
+++ xccdf_org.ssgproject.content_rule_configure_custom_crypto_policy_cis
@@ -6,21 +6,25 @@
 cat << 'EOF' > /etc/crypto-policies/policies/modules/NO-SSHCBC.pmod
 cipher@SSH = -*-CBC
 EOF
+chmod 0644 /etc/crypto-policies/policies/modules/NO-SSHCBC.pmod
 
 expected_crypto_policy="${expected_crypto_policy}:NO-SSHWEAKCIPHERS"
 cat << 'EOF' > /etc/crypto-policies/policies/modules/NO-SSHWEAKCIPHERS.pmod
 cipher@SSH = -3DES-CBC -AES-128-CBC -AES-192-CBC -AES-256-CBC -CHACHA20-POLY1305
 EOF
+chmod 0644 /etc/crypto-policies/policies/modules/NO-SSHWEAKCIPHERS.pmod
 
 expected_crypto_policy="${expected_crypto_policy}:NO-SSHWEAKMACS"
 cat << 'EOF' > /etc/crypto-policies/policies/modules/NO-SSHWEAKMACS.pmod
 mac@SSH = -HMAC-MD5* -UMAC-64* -UMAC-128*
 EOF
+chmod 0644 /etc/crypto-policies/policies/modules/NO-SSHWEAKMACS.pmod
 
 expected_crypto_policy="${expected_crypto_policy}:NO-WEAKMAC"
 cat << 'EOF' > /etc/crypto-policies/policies/modules/NO-WEAKMAC.pmod
 mac = -*-128*
 EOF
+chmod 0644 /etc/crypto-policies/policies/modules/NO-WEAKMAC.pmod
 
 
 current_crypto_policy=$(update-crypto-policies --show)

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_configure_gnutls_tls_crypto_policy' differs.
--- xccdf_org.ssgproject.content_rule_configure_gnutls_tls_crypto_policy
+++ xccdf_org.ssgproject.content_rule_configure_gnutls_tls_crypto_policy
@@ -34,6 +34,7 @@
     regexp: '{{ lineinfile_reg }}'
     line: '{{ correct_value }}'
     create: true
+    mode: 420
   when: not gnutls_file.stat.exists or gnutls_file.stat.size <= correct_value|length
   tags:
   - CCE-84254-2

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_configure_libreswan_crypto_policy' differs.
--- xccdf_org.ssgproject.content_rule_configure_libreswan_crypto_policy
+++ xccdf_org.ssgproject.content_rule_configure_libreswan_crypto_policy
@@ -22,6 +22,7 @@
     path: /etc/ipsec.conf
     line: include /etc/crypto-policies/back-ends/libreswan.config
     create: true
+    mode: 420
   when: ( "libreswan" in ansible_facts.packages and "kernel-core" in ansible_facts.packages
     )
   tags:

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_configure_openssl_crypto_policy' differs.
--- xccdf_org.ssgproject.content_rule_configure_openssl_crypto_policy
+++ xccdf_org.ssgproject.content_rule_configure_openssl_crypto_policy
@@ -75,6 +75,7 @@
     insertafter: ^\s*\[\s*crypto_policy\s*]\s*
     line: .include /etc/crypto-policies/back-ends/opensslcnf.config
     path: /etc/pki/tls/openssl.cnf
+    mode: 420
   when:
   - '"openssl" in ansible_facts.packages'
   - test_crypto_policy_group.matched > 0
@@ -104,6 +105,7 @@
       [crypto_policy]
       .include /etc/crypto-policies/back-ends/opensslcnf.config
     path: /etc/pki/tls/openssl.cnf
+    mode: 420
   when:
   - '"openssl" in ansible_facts.packages'
   - test_crypto_policy_group.matched == 0

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_harden_openssl_crypto_policy' differs.
--- xccdf_org.ssgproject.content_rule_harden_openssl_crypto_policy
+++ xccdf_org.ssgproject.content_rule_harden_openssl_crypto_policy
@@ -84,6 +84,7 @@
     exists in /etc/crypto-policies/local.d/opensslcnf-ospp.config
   ansible.builtin.copy:
     dest: /etc/crypto-policies/local.d/opensslcnf-ospp.config
+    mode: 420
     content: |2
 
       Ciphersuites = TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256

bash remediation for rule 'xccdf_org.ssgproject.content_rule_harden_sshd_ciphers_openssh_conf_crypto_policy' differs.
--- xccdf_org.ssgproject.content_rule_harden_sshd_ciphers_openssh_conf_crypto_policy
+++ xccdf_org.ssgproject.content_rule_harden_sshd_ciphers_openssh_conf_crypto_policy
@@ -6,6 +6,7 @@
     LC_ALL=C sed -i "/^.*Ciphers\s\+/d" "/etc/crypto-policies/back-ends/openssh.config"
 else
     touch "/etc/crypto-policies/back-ends/openssh.config"
+    chmod 0644 "/etc/crypto-policies/back-ends/openssh.config"
 fi
 # make sure file has newline at the end
 sed -i -e '$a\' "/etc/crypto-policies/back-ends/openssh.config"

bash remediation for rule 'xccdf_org.ssgproject.content_rule_harden_sshd_ciphers_opensshserver_conf_crypto_policy' differs.
--- xccdf_org.ssgproject.content_rule_harden_sshd_ciphers_opensshserver_conf_crypto_policy
+++ xccdf_org.ssgproject.content_rule_harden_sshd_ciphers_opensshserver_conf_crypto_policy
@@ -27,9 +27,11 @@
         fi
         # Write updated line to LOCAL_CONF_FILE
         echo -e "\n$last_crypto_policy" > "$LOCAL_CONF_FILE"
+        chmod 0644 "$LOCAL_CONF_FILE"
     fi
 else
     echo -e "\nCRYPTO_POLICY='${correct_value}'" > ${LOCAL_CONF_FILE}
+    chmod 0644 "${LOCAL_CONF_FILE}"
 fi
 
 update-crypto-policies --no-reload

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_harden_sshd_ciphers_opensshserver_conf_crypto_policy' differs.
--- xccdf_org.ssgproject.content_rule_harden_sshd_ciphers_opensshserver_conf_crypto_policy
+++ xccdf_org.ssgproject.content_rule_harden_sshd_ciphers_opensshserver_conf_crypto_policy
@@ -156,6 +156,7 @@
   ansible.builtin.file:
     path: '{{ local_path | dirname }}'
     state: directory
+    mode: 493
   when: '"kernel-core" in ansible_facts.packages'
   tags:
   - CCE-85897-7
@@ -176,6 +177,7 @@
       ' ~ updated_crypto_policy }}
     create: true
     insertafter: EOF
+    mode: 420
   register: local_config
   when:
   - '"kernel-core" in ansible_facts.packages'

bash remediation for rule 'xccdf_org.ssgproject.content_rule_harden_sshd_crypto_policy' differs.
--- xccdf_org.ssgproject.content_rule_harden_sshd_crypto_policy
+++ xccdf_org.ssgproject.content_rule_harden_sshd_crypto_policy
@@ -6,6 +6,7 @@
 
 #blank line at the beginning to ease later readability
 echo '' > "$file"
+chmod 0644 "$file"
 echo "$cp" >> "$file"
 update-crypto-policies
 

bash remediation for rule 'xccdf_org.ssgproject.content_rule_harden_sshd_macs_openssh_conf_crypto_policy' differs.
--- xccdf_org.ssgproject.content_rule_harden_sshd_macs_openssh_conf_crypto_policy
+++ xccdf_org.ssgproject.content_rule_harden_sshd_macs_openssh_conf_crypto_policy
@@ -6,6 +6,7 @@
     LC_ALL=C sed -i "/^.*MACs\s\+/d" "/etc/crypto-policies/back-ends/openssh.config"
 else
     touch "/etc/crypto-policies/back-ends/openssh.config"
+    chmod 0644 "/etc/crypto-policies/back-ends/openssh.config"
 fi
 # make sure file has newline at the end
 sed -i -e '$a\' "/etc/crypto-policies/back-ends/openssh.config"

bash remediation for rule 'xccdf_org.ssgproject.content_rule_harden_sshd_macs_opensshserver_conf_crypto_policy' differs.
--- xccdf_org.ssgproject.content_rule_harden_sshd_macs_opensshserver_conf_crypto_policy
+++ xccdf_org.ssgproject.content_rule_harden_sshd_macs_opensshserver_conf_crypto_policy
@@ -27,9 +27,11 @@
         fi
         # Write updated line to LOCAL_CONF_FILE
         echo -e "\n$last_crypto_policy" > "$LOCAL_CONF_FILE"
+        chmod 0644 "$LOCAL_CONF_FILE"
     fi
 else
     echo -e "\nCRYPTO_POLICY='${correct_value}'" > ${LOCAL_CONF_FILE}
+    chmod 0644 "${LOCAL_CONF_FILE}"
 fi
 
 update-crypto-policies --no-reload

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_harden_sshd_macs_opensshserver_conf_crypto_policy' differs.
--- xccdf_org.ssgproject.content_rule_harden_sshd_macs_opensshserver_conf_crypto_policy
+++ xccdf_org.ssgproject.content_rule_harden_sshd_macs_opensshserver_conf_crypto_policy
@@ -156,6 +156,7 @@
   ansible.builtin.file:
     path: '{{ local_path | dirname }}'
     state: directory
+    mode: 493
   when: '"kernel-core" in ansible_facts.packages'
   tags:
   - CCE-85899-3
@@ -176,6 +177,7 @@
       ' ~ updated_crypto_policy }}
     create: true
     insertafter: EOF
+    mode: 420
   register: local_config
   when:
   - '"kernel-core" in ansible_facts.packages'

bash remediation for rule 'xccdf_org.ssgproject.content_rule_openssl_use_strong_entropy' differs.
--- xccdf_org.ssgproject.content_rule_openssl_use_strong_entropy
+++ xccdf_org.ssgproject.content_rule_openssl_use_strong_entropy
@@ -29,3 +29,4 @@
   exec $openssl_bin "$@"
 )
 EOM
+chmod 0644 /etc/profile.d/openssl-rand.sh

bash remediation for rule 'xccdf_org.ssgproject.content_rule_xwayland_disabled' differs.
--- xccdf_org.ssgproject.content_rule_xwayland_disabled
+++ xccdf_org.ssgproject.content_rule_xwayland_disabled
@@ -34,6 +34,7 @@
 if ! $found ; then
     file=$(echo "/etc/gdm/custom.conf" | cut -f1 -d ' ')
     mkdir -p "$(dirname "$file")"
+    chmod 0755 "$(dirname "$file")"
 
     echo -e "[daemon]\nWaylandEnable=false" >> "$file"
 

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_xwayland_disabled' differs.
--- xccdf_org.ssgproject.content_rule_xwayland_disabled
+++ xccdf_org.ssgproject.content_rule_xwayland_disabled
@@ -18,6 +18,7 @@
     value: 'false'
     create: true
     state: present
+    mode: 420
   when: '"gdm" in ansible_facts.packages'
   tags:
   - CCE-86968-5

bash remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_disable_restart_shutdown' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_disable_restart_shutdown
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_disable_restart_shutdown
@@ -10,6 +10,7 @@
 DBDIR="/etc/dconf/db/gdm.d"
 
 mkdir -p "${DBDIR}"
+chmod 0755 "${DBDIR}"
 
 # Comment out the configurations in databases different from the target one
 if [ "${#SETTINGSFILES[@]}" -ne 0 ]
@@ -41,6 +42,7 @@
 LOCKSFOLDER="/etc/dconf/db/gdm.d/locks"
 
 mkdir -p "${LOCKSFOLDER}"
+chmod 0755 "${LOCKSFOLDER}"
 
 # Comment out the configurations in databases different from the target one
 if [[ ! -z "${LOCKFILES}" ]]

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_disable_restart_shutdown' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_disable_restart_shutdown
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_disable_restart_shutdown
@@ -21,6 +21,7 @@
     value: 'true'
     create: true
     no_extra_spaces: true
+    mode: 420
   register: result_ini
   when: '"gdm" in ansible_facts.packages'
   tags:
@@ -42,6 +43,7 @@
     regexp: ^/org/gnome/login-screen/disable-restart-buttons
     line: /org/gnome/login-screen/disable-restart-buttons
     create: true
+    mode: 420
   register: result_lineinfile
   when: '"gdm" in ansible_facts.packages'
   tags:

bash remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_disable_user_list' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_disable_user_list
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_disable_user_list
@@ -10,6 +10,7 @@
 DBDIR="/etc/dconf/db/gdm.d"
 
 mkdir -p "${DBDIR}"
+chmod 0755 "${DBDIR}"
 
 # Comment out the configurations in databases different from the target one
 if [ "${#SETTINGSFILES[@]}" -ne 0 ]
@@ -41,6 +42,7 @@
 LOCKSFOLDER="/etc/dconf/db/gdm.d/locks"
 
 mkdir -p "${LOCKSFOLDER}"
+chmod 0755 "${LOCKSFOLDER}"
 
 # Comment out the configurations in databases different from the target one
 if [[ ! -z "${LOCKFILES}" ]]

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_disable_user_list' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_disable_user_list
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_disable_user_list
@@ -21,6 +21,7 @@
     value: 'true'
     no_extra_spaces: true
     create: true
+    mode: 420
   register: result_ini
   when: '"gdm" in ansible_facts.packages'
   tags:
@@ -41,6 +42,7 @@
     regexp: ^/org/gnome/login-screen/disable-user-list$
     line: /org/gnome/login-screen/disable-user-list
     create: true
+    mode: 420
   register: result_lineinfile
   when: '"gdm" in ansible_facts.packages'
   tags:

bash remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_enable_smartcard_auth' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_enable_smartcard_auth
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_enable_smartcard_auth
@@ -10,6 +10,7 @@
 DBDIR="/etc/dconf/db/gdm.d"
 
 mkdir -p "${DBDIR}"
+chmod 0755 "${DBDIR}"
 
 # Comment out the configurations in databases different from the target one
 if [ "${#SETTINGSFILES[@]}" -ne 0 ]
@@ -41,6 +42,7 @@
 LOCKSFOLDER="/etc/dconf/db/gdm.d/locks"
 
 mkdir -p "${LOCKSFOLDER}"
+chmod 0755 "${LOCKSFOLDER}"
 
 # Comment out the configurations in databases different from the target one
 if [[ ! -z "${LOCKFILES}" ]]

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_enable_smartcard_auth' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_enable_smartcard_auth
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_enable_smartcard_auth
@@ -23,6 +23,7 @@
     value: 'true'
     create: true
     no_extra_spaces: true
+    mode: 420
   register: result_ini
   when: '"gdm" in ansible_facts.packages'
   tags:
@@ -45,6 +46,7 @@
     regexp: ^/org/gnome/login-screen/enable-smartcard-authentication$
     line: /org/gnome/login-screen/enable-smartcard-authentication
     create: true
+    mode: 420
   register: result_lineinfile
   when: '"gdm" in ansible_facts.packages'
   tags:

bash remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_lock_screen_on_smartcard_removal' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_lock_screen_on_smartcard_removal
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_lock_screen_on_smartcard_removal
@@ -10,6 +10,7 @@
 DBDIR="/etc/dconf/db/local.d"
 
 mkdir -p "${DBDIR}"
+chmod 0755 "${DBDIR}"
 
 # Comment out the configurations in databases different from the target one
 if [ "${#SETTINGSFILES[@]}" -ne 0 ]
@@ -41,6 +42,7 @@
 LOCKSFOLDER="/etc/dconf/db/local.d/locks"
 
 mkdir -p "${LOCKSFOLDER}"
+chmod 0755 "${LOCKSFOLDER}"
 
 # Comment out the configurations in databases different from the target one
 if [[ ! -z "${LOCKFILES}" ]]

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_lock_screen_on_smartcard_removal' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_lock_screen_on_smartcard_removal
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_lock_screen_on_smartcard_removal
@@ -34,6 +34,7 @@
     option: removal-action
     value: '''lock-screen'''
     create: true
+    mode: 420
   when:
   - '"gdm" in ansible_facts.packages'
   - dconf_gnome_lock_screen_on_smartcard_removal_config_files is defined and dconf_gnome_lock_screen_on_smartcard_removal_config_files.matched
@@ -56,6 +57,7 @@
     option: removal-action
     value: '''lock-screen'''
     create: true
+    mode: 420
   with_items: '{{ dconf_gnome_lock_screen_on_smartcard_removal_config_files.files
     }}'
   when:
@@ -95,6 +97,7 @@
     regexp: ^/org/gnome/settings-daemon/peripherals/smartcard/removal-action$
     line: /org/gnome/settings-daemon/peripherals/smartcard/removal-action
     create: true
+    mode: 420
   when:
   - '"gdm" in ansible_facts.packages'
   - dconf_gnome_lock_screen_on_smartcard_removal_lock_files is defined and dconf_gnome_lock_screen_on_smartcard_removal_lock_files.matched
@@ -115,6 +118,7 @@
     regexp: ^/org/gnome/settings-daemon/peripherals/smartcard/removal-action$
     line: /org/gnome/settings-daemon/peripherals/smartcard/removal-action
     create: true
+    mode: 420
   with_items: '{{ dconf_gnome_lock_screen_on_smartcard_removal_lock_files.files }}'
   when:
   - '"gdm" in ansible_facts.packages'

bash remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_login_retries' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_login_retries
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_login_retries
@@ -10,6 +10,7 @@
 DBDIR="/etc/dconf/db/gdm.d"
 
 mkdir -p "${DBDIR}"
+chmod 0755 "${DBDIR}"
 
 # Comment out the configurations in databases different from the target one
 if [ "${#SETTINGSFILES[@]}" -ne 0 ]
@@ -41,6 +42,7 @@
 LOCKSFOLDER="/etc/dconf/db/gdm.d/locks"
 
 mkdir -p "${LOCKSFOLDER}"
+chmod 0755 "${LOCKSFOLDER}"
 
 # Comment out the configurations in databases different from the target one
 if [[ ! -z "${LOCKFILES}" ]]

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_login_retries' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_login_retries
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_login_retries
@@ -19,6 +19,7 @@
     value: '3'
     create: true
     no_extra_spaces: true
+    mode: 420
   register: result_ini
   when: '"gdm" in ansible_facts.packages'
   tags:
@@ -37,6 +38,7 @@
     regexp: ^/org/gnome/login-screen/allowed-failures$
     line: /org/gnome/login-screen/allowed-failures
     create: true
+    mode: 420
   register: result_lineinfile
   when: '"gdm" in ansible_facts.packages'
   tags:

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_gnome_gdm_disable_automatic_login' differs.
--- xccdf_org.ssgproject.content_rule_gnome_gdm_disable_automatic_login
+++ xccdf_org.ssgproject.content_rule_gnome_gdm_disable_automatic_login
@@ -25,6 +25,7 @@
     value: 'false'
     no_extra_spaces: true
     create: true
+    mode: 420
   when: '"gdm" in ansible_facts.packages'
   tags:
   - CCE-80823-8

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_gnome_gdm_disable_guest_login' differs.
--- xccdf_org.ssgproject.content_rule_gnome_gdm_disable_guest_login
+++ xccdf_org.ssgproject.content_rule_gnome_gdm_disable_guest_login
@@ -25,6 +25,7 @@
     value: 'false'
     no_extra_spaces: true
     create: true
+    mode: 420
   when: '"gdm" in ansible_facts.packages'
   tags:
   - CCE-80824-6

bash remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_disable_automount' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_disable_automount
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_disable_automount
@@ -12,6 +12,7 @@
 DBDIR="/etc/dconf/db/local.d"
 
 mkdir -p "${DBDIR}"
+chmod 0755 "${DBDIR}"
 
 # Comment out the configurations in databases different from the target one
 if [ "${#SETTINGSFILES[@]}" -ne 0 ]
@@ -43,6 +44,7 @@
 LOCKSFOLDER="/etc/dconf/db/local.d/locks"
 
 mkdir -p "${LOCKSFOLDER}"
+chmod 0755 "${LOCKSFOLDER}"
 
 # Comment out the configurations in databases different from the target one
 if [[ ! -z "${LOCKFILES}" ]]

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_disable_automount' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_disable_automount
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_disable_automount
@@ -18,6 +18,7 @@
 
 - name: Disable GNOME3 Automounting - automount
   community.general.ini_file:
+    mode: 420
     dest: /etc/dconf/db/local.d/00-security-settings
     section: org/gnome/desktop/media-handling
     option: automount
@@ -43,6 +44,7 @@
 
 - name: Prevent user modification of GNOME3 Automounting - automount
   ansible.builtin.lineinfile:
+    mode: 420
     path: /etc/dconf/db/local.d/locks/00-security-settings-lock
     regexp: ^/org/gnome/desktop/media-handling/automount$
     line: /org/gnome/desktop/media-handling/automount

bash remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_disable_automount_open' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_disable_automount_open
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_disable_automount_open
@@ -12,6 +12,7 @@
 DBDIR="/etc/dconf/db/local.d"
 
 mkdir -p "${DBDIR}"
+chmod 0755 "${DBDIR}"
 
 # Comment out the configurations in databases different from the target one
 if [ "${#SETTINGSFILES[@]}" -ne 0 ]
@@ -43,6 +44,7 @@
 LOCKSFOLDER="/etc/dconf/db/local.d/locks"
 
 mkdir -p "${LOCKSFOLDER}"
+chmod 0755 "${LOCKSFOLDER}"
 
 # Comment out the configurations in databases different from the target one
 if [[ ! -z "${LOCKFILES}" ]]

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_disable_automount_open' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_disable_automount_open
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_disable_automount_open
@@ -18,6 +18,7 @@
 
 - name: Disable GNOME3 Automounting - automount-open
   community.general.ini_file:
+    mode: 420
     dest: /etc/dconf/db/local.d/00-security-settings
     section: org/gnome/desktop/media-handling
     option: automount-open
@@ -43,6 +44,7 @@
 
 - name: Prevent user modification of GNOME3 Automounting - automount-open
   ansible.builtin.lineinfile:
+    mode: 420
     path: /etc/dconf/db/local.d/locks/00-security-settings-lock
     regexp: ^/org/gnome/desktop/media-handling/automount-open$
     line: /org/gnome/desktop/media-handling/automount-open

bash remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_disable_autorun' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_disable_autorun
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_disable_autorun
@@ -10,6 +10,7 @@
 DBDIR="/etc/dconf/db/local.d"
 
 mkdir -p "${DBDIR}"
+chmod 0755 "${DBDIR}"
 
 # Comment out the configurations in databases different from the target one
 if [ "${#SETTINGSFILES[@]}" -ne 0 ]
@@ -41,6 +42,7 @@
 LOCKSFOLDER="/etc/dconf/db/local.d/locks"
 
 mkdir -p "${LOCKSFOLDER}"
+chmod 0755 "${LOCKSFOLDER}"
 
 # Comment out the configurations in databases different from the target one
 if [[ ! -z "${LOCKFILES}" ]]

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_disable_autorun' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_disable_autorun
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_disable_autorun
@@ -16,6 +16,7 @@
 
 - name: Disable GNOME3 Automounting - autorun-never
   community.general.ini_file:
+    mode: 420
     dest: /etc/dconf/db/local.d/00-security-settings
     section: org/gnome/desktop/media-handling
     option: autorun-never
@@ -39,6 +40,7 @@
 
 - name: Prevent user modification of GNOME3 Automounting - autorun-never
   ansible.builtin.lineinfile:
+    mode: 420
     path: /etc/dconf/db/local.d/locks/00-security-settings-lock
     regexp: ^/org/gnome/desktop/media-handling/autorun-never$
     line: /org/gnome/desktop/media-handling/autorun-never

bash remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_disable_thumbnailers' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_disable_thumbnailers
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_disable_thumbnailers
@@ -10,6 +10,7 @@
 DBDIR="/etc/dconf/db/local.d"
 
 mkdir -p "${DBDIR}"
+chmod 0755 "${DBDIR}"
 
 # Comment out the configurations in databases different from the target one
 if [ "${#SETTINGSFILES[@]}" -ne 0 ]
@@ -41,6 +42,7 @@
 LOCKSFOLDER="/etc/dconf/db/local.d/locks"
 
 mkdir -p "${LOCKSFOLDER}"
+chmod 0755 "${LOCKSFOLDER}"
 
 # Comment out the configurations in databases different from the target one
 if [[ ! -z "${LOCKFILES}" ]]

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_disable_thumbnailers' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_disable_thumbnailers
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_disable_thumbnailers
@@ -20,6 +20,7 @@
     value: 'true'
     create: true
     no_extra_spaces: true
+    mode: 420
   register: result_ini
   when: '"gdm" in ansible_facts.packages'
   tags:
@@ -39,6 +40,7 @@
     regexp: ^/org/gnome/desktop/thumbnailers/disable-all$
     line: /org/gnome/desktop/thumbnailers/disable-all
     create: true
+    mode: 420
   register: result_lineinfile
   when: '"gdm" in ansible_facts.packages'
   tags:

bash remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_disable_wifi_create' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_disable_wifi_create
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_disable_wifi_create
@@ -10,6 +10,7 @@
 DBDIR="/etc/dconf/db/local.d"
 
 mkdir -p "${DBDIR}"
+chmod 0755 "${DBDIR}"
 
 # Comment out the configurations in databases different from the target one
 if [ "${#SETTINGSFILES[@]}" -ne 0 ]
@@ -41,6 +42,7 @@
 LOCKSFOLDER="/etc/dconf/db/local.d/locks"
 
 mkdir -p "${LOCKSFOLDER}"
+chmod 0755 "${LOCKSFOLDER}"
 
 # Comment out the configurations in databases different from the target one
 if [[ ! -z "${LOCKFILES}" ]]

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_disable_wifi_create' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_disable_wifi_create
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_disable_wifi_create
@@ -18,6 +18,7 @@
     value: 'true'
     create: true
     no_extra_spaces: true
+    mode: 420
   register: result_ini
   when: '"gdm" in ansible_facts.packages'
   tags:
@@ -35,6 +36,7 @@
     regexp: ^/org/gnome/nm-applet/disable-wifi-create$
     line: /org/gnome/nm-applet/disable-wifi-create
     create: true
+    mode: 420
   register: result_lineinfile
   when: '"gdm" in ansible_facts.packages'
   tags:

bash remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_disable_wifi_notification' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_disable_wifi_notification
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_disable_wifi_notification
@@ -10,6 +10,7 @@
 DBDIR="/etc/dconf/db/local.d"
 
 mkdir -p "${DBDIR}"
+chmod 0755 "${DBDIR}"
 
 # Comment out the configurations in databases different from the target one
 if [ "${#SETTINGSFILES[@]}" -ne 0 ]
@@ -41,6 +42,7 @@
 LOCKSFOLDER="/etc/dconf/db/local.d/locks"
 
 mkdir -p "${LOCKSFOLDER}"
+chmod 0755 "${LOCKSFOLDER}"
 
 # Comment out the configurations in databases different from the target one
 if [[ ! -z "${LOCKFILES}" ]]

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_disable_wifi_notification' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_disable_wifi_notification
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_disable_wifi_notification
@@ -18,6 +18,7 @@
     value: 'true'
     create: true
     no_extra_spaces: true
+    mode: 420
   register: result_ini
   when: '"gdm" in ansible_facts.packages'
   tags:
@@ -35,6 +36,7 @@
     regexp: ^/org/gnome/nm-applet/suppress-wireless-networks-available$
     line: /org/gnome/nm-applet/suppress-wireless-networks-available
     create: true
+    mode: 420
   register: result_lineinfile
   when: '"gdm" in ansible_facts.packages'
   tags:

bash remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_remote_access_credential_prompt' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_remote_access_credential_prompt
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_remote_access_credential_prompt
@@ -10,6 +10,7 @@
 DBDIR="/etc/dconf/db/local.d"
 
 mkdir -p "${DBDIR}"
+chmod 0755 "${DBDIR}"
 
 # Comment out the configurations in databases different from the target one
 if [ "${#SETTINGSFILES[@]}" -ne 0 ]
@@ -41,6 +42,7 @@
 LOCKSFOLDER="/etc/dconf/db/local.d/locks"
 
 mkdir -p "${LOCKSFOLDER}"
+chmod 0755 "${LOCKSFOLDER}"
 
 # Comment out the configurations in databases different from the target one
 if [[ ! -z "${LOCKFILES}" ]]

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_remote_access_credential_prompt' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_remote_access_credential_prompt
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_remote_access_credential_prompt
@@ -13,6 +13,7 @@
 
 - name: Require Credential Prompting for Remote Access in GNOME3
   community.general.ini_file:
+    mode: 420
     dest: /etc/dconf/db/local.d/00-security-settings
     section: org/gnome/Vino
     option: authentication-methods
@@ -33,6 +34,7 @@
 
 - name: Prevent user modification of GNOME3 Credential Prompting for Remote Access
   ansible.builtin.lineinfile:
+    mode: 420
     path: /etc/dconf/db/local.d/locks/00-security-settings-lock
     regexp: ^/org/gnome/Vino/authentication-methods$
     line: /org/gnome/Vino/authentication-methods

bash remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_remote_access_encryption' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_remote_access_encryption
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_remote_access_encryption
@@ -10,6 +10,7 @@
 DBDIR="/etc/dconf/db/local.d"
 
 mkdir -p "${DBDIR}"
+chmod 0755 "${DBDIR}"
 
 # Comment out the configurations in databases different from the target one
 if [ "${#SETTINGSFILES[@]}" -ne 0 ]
@@ -41,6 +42,7 @@
 LOCKSFOLDER="/etc/dconf/db/local.d/locks"
 
 mkdir -p "${LOCKSFOLDER}"
+chmod 0755 "${LOCKSFOLDER}"
 
 # Comment out the configurations in databases different from the target one
 if [[ ! -z "${LOCKFILES}" ]]

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_remote_access_encryption' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_remote_access_encryption
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_remote_access_encryption
@@ -16,6 +16,7 @@
 
 - name: Require Encryption for Remote Access in GNOME3
   community.general.ini_file:
+    mode: 420
     dest: /etc/dconf/db/local.d/00-security-settings
     section: org/gnome/Vino
     option: require-encryption
@@ -39,6 +40,7 @@
 
 - name: Prevent user modification of GNOME3 Encryption for Remote Access
   ansible.builtin.lineinfile:
+    mode: 420
     path: /etc/dconf/db/local.d/locks/00-security-settings-lock
     regexp: ^/org/gnome/Vino/require-encryption$
     line: /org/gnome/Vino/require-encryption

bash remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_idle_activation_enabled' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_idle_activation_enabled
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_idle_activation_enabled
@@ -10,6 +10,7 @@
 DBDIR="/etc/dconf/db/local.d"
 
 mkdir -p "${DBDIR}"
+chmod 0755 "${DBDIR}"
 
 # Comment out the configurations in databases different from the target one
 if [ "${#SETTINGSFILES[@]}" -ne 0 ]
@@ -41,6 +42,7 @@
 LOCKSFOLDER="/etc/dconf/db/local.d/locks"
 
 mkdir -p "${LOCKSFOLDER}"
+chmod 0755 "${LOCKSFOLDER}"
 
 # Comment out the configurations in databases different from the target one
 if [[ ! -z "${LOCKFILES}" ]]

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_idle_activation_enabled' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_idle_activation_enabled
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_idle_activation_enabled
@@ -19,6 +19,7 @@
 
 - name: Enable GNOME3 Screensaver Idle Activation
   community.general.ini_file:
+    mode: 420
     dest: /etc/dconf/db/local.d/00-security-settings
     section: org/gnome/desktop/screensaver
     option: idle-activation-enabled
@@ -45,6 +46,7 @@
 
 - name: Prevent user modification of GNOME idle-activation-enabled
   ansible.builtin.lineinfile:
+    mode: 420
     path: /etc/dconf/db/local.d/locks/00-security-settings-lock
     regexp: ^/org/gnome/desktop/screensaver/idle-activation-enabled$
     line: /org/gnome/desktop/screensaver/idle-activation-enabled

bash remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_idle_activation_locked' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_idle_activation_locked
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_idle_activation_locked
@@ -7,6 +7,7 @@
 LOCKSFOLDER="/etc/dconf/db/local.d/locks"
 
 mkdir -p "${LOCKSFOLDER}"
+chmod 0755 "${LOCKSFOLDER}"
 
 # Comment out the configurations in databases different from the target one
 if [[ ! -z "${LOCKFILES}" ]]

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_idle_activation_locked' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_idle_activation_locked
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_idle_activation_locked
@@ -20,6 +20,7 @@
     regexp: ^/org/gnome/desktop/screensaver/idle-activation-enabled$
     line: /org/gnome/desktop/screensaver/idle-activation-enabled
     create: true
+    mode: 420
   register: result_lineinfile
   when: '"gdm" in ansible_facts.packages'
   tags:

bash remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_idle_delay' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_idle_delay
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_idle_delay
@@ -14,6 +14,7 @@
 DBDIR="/etc/dconf/db/local.d"
 
 mkdir -p "${DBDIR}"
+chmod 0755 "${DBDIR}"
 
 # Comment out the configurations in databases different from the target one
 if [ "${#SETTINGSFILES[@]}" -ne 0 ]

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_idle_delay' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_idle_delay
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_idle_delay
@@ -25,6 +25,7 @@
 
 - name: Set GNOME3 Screensaver Inactivity Timeout
   community.general.ini_file:
+    mode: 420
     dest: /etc/dconf/db/local.d/00-security-settings
     section: org/gnome/desktop/session
     option: idle-delay

bash remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_lock_delay' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_lock_delay
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_lock_delay
@@ -14,6 +14,7 @@
 DBDIR="/etc/dconf/db/local.d"
 
 mkdir -p "${DBDIR}"
+chmod 0755 "${DBDIR}"
 
 # Comment out the configurations in databases different from the target one
 if [ "${#SETTINGSFILES[@]}" -ne 0 ]

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_lock_delay' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_lock_delay
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_lock_delay
@@ -24,6 +24,7 @@
 
 - name: Set GNOME3 Screensaver Lock Delay After Activation Period
   community.general.ini_file:
+    mode: 420
     dest: /etc/dconf/db/local.d/00-security-settings
     section: org/gnome/desktop/screensaver
     option: lock-delay

bash remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_lock_enabled' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_lock_enabled
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_lock_enabled
@@ -10,6 +10,7 @@
 DBDIR="/etc/dconf/db/local.d"
 
 mkdir -p "${DBDIR}"
+chmod 0755 "${DBDIR}"
 
 # Comment out the configurations in databases different from the target one
 if [ "${#SETTINGSFILES[@]}" -ne 0 ]
@@ -41,6 +42,7 @@
 LOCKSFOLDER="/etc/dconf/db/local.d/locks"
 
 mkdir -p "${LOCKSFOLDER}"
+chmod 0755 "${LOCKSFOLDER}"
 
 # Comment out the configurations in databases different from the target one
 if [[ ! -z "${LOCKFILES}" ]]

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_lock_enabled' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_lock_enabled
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_lock_enabled
@@ -26,6 +26,7 @@
     value: 'true'
     create: true
     no_extra_spaces: true
+    mode: 420
   when:
   - '"gdm" in ansible_facts.packages'
   - ansible_distribution != 'SLES'
@@ -53,6 +54,7 @@
     regexp: ^/org/gnome/desktop/screensaver/lock-enabled$
     line: /org/gnome/desktop/screensaver/lock-enabled
     create: true
+    mode: 420
   when:
   - '"gdm" in ansible_facts.packages'
   - ansible_distribution != 'SLES'
@@ -82,6 +84,7 @@
     value: 'false'
     create: true
     no_extra_spaces: true
+    mode: 420
   when:
   - '"gdm" in ansible_facts.packages'
   - ansible_distribution == 'SLES'
@@ -109,6 +112,7 @@
     regexp: ^/org/gnome/desktop/lockdown/disable-lock-screen$
     line: /org/gnome/desktop/lockdown/disable-lock-screen
     create: true
+    mode: 420
   when:
   - '"gdm" in ansible_facts.packages'
   - ansible_distribution == 'SLES'

bash remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_lock_locked' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_lock_locked
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_lock_locked
@@ -7,6 +7,7 @@
 LOCKSFOLDER="/etc/dconf/db/local.d/locks"
 
 mkdir -p "${LOCKSFOLDER}"
+chmod 0755 "${LOCKSFOLDER}"
 
 # Comment out the configurations in databases different from the target one
 if [[ ! -z "${LOCKFILES}" ]]

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_lock_locked' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_lock_locked
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_lock_locked
@@ -21,6 +21,7 @@
     regexp: ^/org/gnome/desktop/screensaver/lock-enabled$
     line: /org/gnome/desktop/screensaver/lock-enabled
     create: true
+    mode: 420
   register: result_lineinfile
   when: '"gdm" in ansible_facts.packages'
   tags:

bash remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_mode_blank' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_mode_blank
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_mode_blank
@@ -10,6 +10,7 @@
 DBDIR="/etc/dconf/db/local.d"
 
 mkdir -p "${DBDIR}"
+chmod 0755 "${DBDIR}"
 
 # Comment out the configurations in databases different from the target one
 if [ "${#SETTINGSFILES[@]}" -ne 0 ]
@@ -41,6 +42,7 @@
 LOCKSFOLDER="/etc/dconf/db/local.d/locks"
 
 mkdir -p "${LOCKSFOLDER}"
+chmod 0755 "${LOCKSFOLDER}"
 
 # Comment out the configurations in databases different from the target one
 if [[ ! -z "${LOCKFILES}" ]]

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_mode_blank' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_mode_blank
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_mode_blank
@@ -20,6 +20,7 @@
 
 - name: Implement Blank Screensaver
   community.general.ini_file:
+    mode: 420
     dest: /etc/dconf/db/local.d/00-security-settings
     section: org/gnome/desktop/screensaver
     option: picture-uri
@@ -47,6 +48,7 @@
 
 - name: Prevent user modification of GNOME picture-uri
   ansible.builtin.lineinfile:
+    mode: 420
     path: /etc/dconf/db/local.d/locks/00-security-settings-lock
     regexp: ^/org/gnome/desktop/screensaver/picture-uri$
     line: /org/gnome/desktop/screensaver/picture-uri

bash remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_user_info' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_user_info
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_user_info
@@ -10,6 +10,7 @@
 DBDIR="/etc/dconf/db/local.d"
 
 mkdir -p "${DBDIR}"
+chmod 0755 "${DBDIR}"
 
 # Comment out the configurations in databases different from the target one
 if [ "${#SETTINGSFILES[@]}" -ne 0 ]
@@ -41,6 +42,7 @@
 LOCKSFOLDER="/etc/dconf/db/local.d/locks"
 
 mkdir -p "${LOCKSFOLDER}"
+chmod 0755 "${LOCKSFOLDER}"
 
 # Comment out the configurations in databases different from the target one
 if [[ ! -z "${LOCKFILES}" ]]

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_user_info' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_user_info
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_user_info
@@ -18,6 +18,7 @@
     value: 'false'
     create: true
     no_extra_spaces: true
+    mode: 420
   register: result_ini
   when: '"gdm" in ansible_facts.packages'
   tags:
@@ -35,6 +36,7 @@
     regexp: ^/org/gnome/desktop/screensaver/show-full-name-in-top-bar$
     line: /org/gnome/desktop/screensaver/show-full-name-in-top-bar
     create: true
+    mode: 420
   register: result_lineinfile
   when: '"gdm" in ansible_facts.packages'
   tags:

bash remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_user_locks' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_user_locks
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_user_locks
@@ -7,6 +7,7 @@
 LOCKSFOLDER="/etc/dconf/db/local.d/locks"
 
 mkdir -p "${LOCKSFOLDER}"
+chmod 0755 "${LOCKSFOLDER}"
 
 # Comment out the configurations in databases different from the target one
 if [[ ! -z "${LOCKFILES}" ]]

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_user_locks' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_user_locks
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_screensaver_user_locks
@@ -15,6 +15,7 @@
 
 - name: Prevent user modification of GNOME lock-delay
   ansible.builtin.lineinfile:
+    mode: 420
     path: /etc/dconf/db/local.d/locks/00-security-settings-lock
     regexp: ^/org/gnome/desktop/screensaver/lock-delay$
     line: /org/gnome/desktop/screensaver/lock-delay

bash remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_session_idle_user_locks' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_session_idle_user_locks
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_session_idle_user_locks
@@ -7,6 +7,7 @@
 LOCKSFOLDER="/etc/dconf/db/local.d/locks"
 
 mkdir -p "${LOCKSFOLDER}"
+chmod 0755 "${LOCKSFOLDER}"
 
 # Comment out the configurations in databases different from the target one
 if [[ ! -z "${LOCKFILES}" ]]

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_session_idle_user_locks' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_session_idle_user_locks
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_session_idle_user_locks
@@ -18,6 +18,7 @@
 
 - name: Prevent user modification of GNOME Session idle-delay
   ansible.builtin.lineinfile:
+    mode: 420
     path: /etc/dconf/db/local.d/locks/00-security-settings-lock
     regexp: ^/org/gnome/desktop/session/idle-delay$
     line: /org/gnome/desktop/session/idle-delay

bash remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_disable_ctrlaltdel_reboot' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_disable_ctrlaltdel_reboot
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_disable_ctrlaltdel_reboot
@@ -10,6 +10,7 @@
 DBDIR="/etc/dconf/db/local.d"
 
 mkdir -p "${DBDIR}"
+chmod 0755 "${DBDIR}"
 
 # Comment out the configurations in databases different from the target one
 if [ "${#SETTINGSFILES[@]}" -ne 0 ]
@@ -41,6 +42,7 @@
 LOCKSFOLDER="/etc/dconf/db/local.d/locks"
 
 mkdir -p "${LOCKSFOLDER}"
+chmod 0755 "${LOCKSFOLDER}"
 
 # Comment out the configurations in databases different from the target one
 if [[ ! -z "${LOCKFILES}" ]]

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_disable_ctrlaltdel_reboot' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_disable_ctrlaltdel_reboot
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_disable_ctrlaltdel_reboot
@@ -23,6 +23,7 @@
     value: '['''']'
     create: true
     no_extra_spaces: true
+    mode: 420
   register: result_ini
   when: '"gdm" in ansible_facts.packages'
   tags:
@@ -45,6 +46,7 @@
     regexp: ^/org/gnome/settings-daemon/plugins/media-keys/logout$
     line: /org/gnome/settings-daemon/plugins/media-keys/logout
     create: true
+    mode: 420
   register: result_lineinfile
   when: '"gdm" in ansible_facts.packages'
   tags:

bash remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_disable_geolocation' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_disable_geolocation
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_disable_geolocation
@@ -10,6 +10,7 @@
 DBDIR="/etc/dconf/db/local.d"
 
 mkdir -p "${DBDIR}"
+chmod 0755 "${DBDIR}"
 
 # Comment out the configurations in databases different from the target one
 if [ "${#SETTINGSFILES[@]}" -ne 0 ]
@@ -44,6 +45,7 @@
 DBDIR="/etc/dconf/db/local.d"
 
 mkdir -p "${DBDIR}"
+chmod 0755 "${DBDIR}"
 
 # Comment out the configurations in databases different from the target one
 if [ "${#SETTINGSFILES[@]}" -ne 0 ]
@@ -75,6 +77,7 @@
 LOCKSFOLDER="/etc/dconf/db/local.d/locks"
 
 mkdir -p "${LOCKSFOLDER}"
+chmod 0755 "${LOCKSFOLDER}"
 
 # Comment out the configurations in databases different from the target one
 if [[ ! -z "${LOCKFILES}" ]]
@@ -93,6 +96,7 @@
 LOCKSFOLDER="/etc/dconf/db/local.d/locks"
 
 mkdir -p "${LOCKSFOLDER}"
+chmod 0755 "${LOCKSFOLDER}"
 
 # Comment out the configurations in databases different from the target one
 if [[ ! -z "${LOCKFILES}" ]]

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_disable_geolocation' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_disable_geolocation
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_disable_geolocation
@@ -17,6 +17,7 @@
     value: 'false'
     create: true
     no_extra_spaces: true
+    mode: 420
   register: result_ini1
   when: '"gdm" in ansible_facts.packages'
   tags:
@@ -34,6 +35,7 @@
     option: gelocation
     value: 'false'
     create: true
+    mode: 420
   register: result_ini2
   when: '"gdm" in ansible_facts.packages'
   tags:
@@ -50,6 +52,7 @@
     regexp: ^/org/gnome/system/location/enabled$
     line: /org/gnome/system/location/enabled
     create: true
+    mode: 420
   register: result_lineinfile1
   when: '"gdm" in ansible_facts.packages'
   tags:
@@ -66,6 +69,7 @@
     regexp: ^/org/gnome/clocks/geolocation$
     line: /org/gnome/clocks/geolocation
     create: true
+    mode: 420
   register: result_lineinfile2
   when: '"gdm" in ansible_facts.packages'
   tags:

bash remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_disable_user_admin' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_disable_user_admin
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_disable_user_admin
@@ -10,6 +10,7 @@
 DBDIR="/etc/dconf/db/local.d"
 
 mkdir -p "${DBDIR}"
+chmod 0755 "${DBDIR}"
 
 # Comment out the configurations in databases different from the target one
 if [ "${#SETTINGSFILES[@]}" -ne 0 ]
@@ -41,6 +42,7 @@
 LOCKSFOLDER="/etc/dconf/db/local.d/locks"
 
 mkdir -p "${LOCKSFOLDER}"
+chmod 0755 "${LOCKSFOLDER}"
 
 # Comment out the configurations in databases different from the target one
 if [[ ! -z "${LOCKFILES}" ]]

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_disable_user_admin' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_disable_user_admin
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_disable_user_admin
@@ -34,6 +34,7 @@
     option: user-administration-disabled
     value: 'true'
     create: true
+    mode: 420
   when:
   - '"gdm" in ansible_facts.packages'
   - dconf_gnome_disable_user_admin_config_files is defined and dconf_gnome_disable_user_admin_config_files.matched
@@ -56,6 +57,7 @@
     option: user-administration-disabled
     value: 'true'
     create: true
+    mode: 420
   with_items: '{{ dconf_gnome_disable_user_admin_config_files.files }}'
   when:
   - '"gdm" in ansible_facts.packages'
@@ -94,6 +96,7 @@
     regexp: ^/org/gnome/desktop/lockdown/user-administration-disabled$
     line: /org/gnome/desktop/lockdown/user-administration-disabled
     create: true
+    mode: 420
   when:
   - '"gdm" in ansible_facts.packages'
   - dconf_gnome_disable_user_admin_lock_files is defined and dconf_gnome_disable_user_admin_lock_files.matched
@@ -114,6 +117,7 @@
     regexp: ^/org/gnome/desktop/lockdown/user-administration-disabled$
     line: /org/gnome/desktop/lockdown/user-administration-disabled
     create: true
+    mode: 420
   with_items: '{{ dconf_gnome_disable_user_admin_lock_files.files }}'
   when:
   - '"gdm" in ansible_facts.packages'

bash remediation for rule 'xccdf_org.ssgproject.content_rule_sudo_require_reauthentication' differs.
--- xccdf_org.ssgproject.content_rule_sudo_require_reauthentication
+++ xccdf_org.ssgproject.content_rule_sudo_require_reauthentication
@@ -12,6 +12,7 @@
 
 if /usr/sbin/visudo -qcf /etc/sudoers; then
     cp /etc/sudoers /etc/sudoers.bak
+    chmod 0440 /etc/sudoers.bak
     if ! grep -P '^[\s]*Defaults.*timestamp_timeout[\s]*=[\s]*[-]?\w+.*$' /etc/sudoers; then
         # sudoers file doesn't define Option timestamp_timeout
         echo "Defaults timestamp_timeout=${var_sudo_timestamp_timeout}" >> /etc/sudoers

bash remediation for rule 'xccdf_org.ssgproject.content_rule_sudoers_validate_passwd' differs.
--- xccdf_org.ssgproject.content_rule_sudoers_validate_passwd
+++ xccdf_org.ssgproject.content_rule_sudoers_validate_passwd
@@ -24,6 +24,7 @@
     LC_ALL=C sed -i "/Defaults !targetpw/d" "/etc/sudoers"
 else
     touch "/etc/sudoers"
+    chmod 0644 "/etc/sudoers"
 fi
 # make sure file has newline at the end
 sed -i -e '$a\' "/etc/sudoers"
@@ -37,6 +38,7 @@
     LC_ALL=C sed -i "/Defaults !rootpw/d" "/etc/sudoers"
 else
     touch "/etc/sudoers"
+    chmod 0644 "/etc/sudoers"
 fi
 # make sure file has newline at the end
 sed -i -e '$a\' "/etc/sudoers"
@@ -50,6 +52,7 @@
     LC_ALL=C sed -i "/Defaults !runaspw/d" "/etc/sudoers"
 else
     touch "/etc/sudoers"
+    chmod 0644 "/etc/sudoers"
 fi
 # make sure file has newline at the end
 sed -i -e '$a\' "/etc/sudoers"

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_clean_components_post_updating' differs.
--- xccdf_org.ssgproject.content_rule_clean_components_post_updating
+++ xccdf_org.ssgproject.content_rule_clean_components_post_updating
@@ -24,6 +24,7 @@
     line: clean_requirements_on_remove=1
     insertafter: \[main\]
     create: true
+    mode: 420
   when: ( not ( "kernel-core" in ansible_facts.packages and "rpm-ostree" in ansible_facts.packages
     and "bootc" in ansible_facts.packages and not "openshift-kubelet" in ansible_facts.packages
     and "ostree" in ansible_proc_cmdline ) and "yum" in ansible_facts.packages )

bash remediation for rule 'xccdf_org.ssgproject.content_rule_disable_weak_deps' differs.
--- xccdf_org.ssgproject.content_rule_disable_weak_deps
+++ xccdf_org.ssgproject.content_rule_disable_weak_deps
@@ -34,6 +34,7 @@
 if ! $found ; then
     file=$(echo "/etc/dnf/dnf.conf" | cut -f1 -d ' ')
     mkdir -p "$(dirname "$file")"
+    chmod 0755 "$(dirname "$file")"
 
     echo -e "[main]\ninstall_weak_deps=0" >> "$file"
 

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_disable_weak_deps' differs.
--- xccdf_org.ssgproject.content_rule_disable_weak_deps
+++ xccdf_org.ssgproject.content_rule_disable_weak_deps
@@ -18,6 +18,7 @@
     value: 0
     create: true
     state: present
+    mode: 420
   when: '"dnf" in ansible_facts.packages'
   tags:
   - CCE-88727-3

bash remediation for rule 'xccdf_org.ssgproject.content_rule_dnf-automatic_apply_updates' differs.
--- xccdf_org.ssgproject.content_rule_dnf-automatic_apply_updates
+++ xccdf_org.ssgproject.content_rule_dnf-automatic_apply_updates
@@ -34,6 +34,7 @@
 if ! $found ; then
     file=$(echo "/etc/dnf/automatic.conf" | cut -f1 -d ' ')
     mkdir -p "$(dirname "$file")"
+    chmod 0755 "$(dirname "$file")"
 
     echo -e "[commands]\napply_updates=yes" >> "$file"
 

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_dnf-automatic_apply_updates' differs.
--- xccdf_org.ssgproject.content_rule_dnf-automatic_apply_updates
+++ xccdf_org.ssgproject.content_rule_dnf-automatic_apply_updates
@@ -20,6 +20,7 @@
     option: apply_updates
     value: 'yes'
     create: true
+    mode: 420
   when: ( not ( "kernel-core" in ansible_facts.packages and "rpm-ostree" in ansible_facts.packages
     and "bootc" in ansible_facts.packages and not "openshift-kubelet" in ansible_facts.packages
     and "ostree" in ansible_proc_cmdline ) and not ( ansible_virtualization_type in

bash remediation for rule 'xccdf_org.ssgproject.content_rule_dnf-automatic_security_updates_only' differs.
--- xccdf_org.ssgproject.content_rule_dnf-automatic_security_updates_only
+++ xccdf_org.ssgproject.content_rule_dnf-automatic_security_updates_only
@@ -34,6 +34,7 @@
 if ! $found ; then
     file=$(echo "/etc/dnf/automatic.conf" | cut -f1 -d ' ')
     mkdir -p "$(dirname "$file")"
+    chmod 0755 "$(dirname "$file")"
 
     echo -e "[commands]\nupgrade_type=security" >> "$file"
 

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_dnf-automatic_security_updates_only' differs.
--- xccdf_org.ssgproject.content_rule_dnf-automatic_security_updates_only
+++ xccdf_org.ssgproject.content_rule_dnf-automatic_security_updates_only
@@ -20,6 +20,7 @@
     option: upgrade_type
     value: security
     create: true
+    mode: 420
   when: ( not ( "kernel-core" in ansible_facts.packages and "rpm-ostree" in ansible_facts.packages
     and "bootc" in ansible_facts.packages and not "openshift-kubelet" in ansible_facts.packages
     and "ostree" in ansible_proc_cmdline ) and not ( ansible_virtualization_type in

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_ensure_gpgcheck_local_packages' differs.
--- xccdf_org.ssgproject.content_rule_ensure_gpgcheck_local_packages
+++ xccdf_org.ssgproject.content_rule_ensure_gpgcheck_local_packages
@@ -40,6 +40,7 @@
       value: 1
       no_extra_spaces: true
       create: true
+      mode: 420
   when: '"yum" in ansible_facts.packages'
   tags:
   - CCE-80791-7

bash remediation for rule 'xccdf_org.ssgproject.content_rule_banner_etc_issue' differs.
--- xccdf_org.ssgproject.content_rule_banner_etc_issue
+++ xccdf_org.ssgproject.content_rule_banner_etc_issue
@@ -3,6 +3,7 @@
 
 login_banner_contents=$(echo "" | sed 's/\\n/\n/g')
 echo "$login_banner_contents" > /etc/issue
+chmod 0644 /etc/issue
 
 else
     >&2 echo 'Remediation is not applicable, nothing was done'

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_banner_etc_issue' differs.
--- xccdf_org.ssgproject.content_rule_banner_etc_issue
+++ xccdf_org.ssgproject.content_rule_banner_etc_issue
@@ -22,6 +22,7 @@
 - name: Modify the System Login Banner - Ensure Correct Banner
   ansible.builtin.copy:
     dest: /etc/issue
+    mode: 420
     content: |
       {{ login_banner_contents | replace('\n', '
       ') }}

bash remediation for rule 'xccdf_org.ssgproject.content_rule_banner_etc_issue_cis' differs.
--- xccdf_org.ssgproject.content_rule_banner_etc_issue_cis
+++ xccdf_org.ssgproject.content_rule_banner_etc_issue_cis
@@ -4,6 +4,7 @@
 cis_banner_text=''
 
 echo "$cis_banner_text" > "/etc/issue"
+chmod 0644 "/etc/issue"
 
 else
     >&2 echo 'Remediation is not applicable, nothing was done'

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_banner_etc_issue_cis' differs.
--- xccdf_org.ssgproject.content_rule_banner_etc_issue_cis
+++ xccdf_org.ssgproject.content_rule_banner_etc_issue_cis
@@ -20,6 +20,7 @@
   ansible.builtin.copy:
     content: '{{ cis_banner_text }}'
     dest: /etc/issue
+    mode: 420
   when: '"kernel-core" in ansible_facts.packages'
   tags:
   - CCE-86160-9

bash remediation for rule 'xccdf_org.ssgproject.content_rule_banner_etc_issue_net' differs.
--- xccdf_org.ssgproject.content_rule_banner_etc_issue_net
+++ xccdf_org.ssgproject.content_rule_banner_etc_issue_net
@@ -3,6 +3,7 @@
 
 remote_login_banner_contents=$(echo "" | sed 's/\\n/\n/g')
 echo "$remote_login_banner_contents" > /etc/issue.net
+chmod 0644 /etc/issue.net
 
 else
     >&2 echo 'Remediation is not applicable, nothing was done'

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_banner_etc_issue_net' differs.
--- xccdf_org.ssgproject.content_rule_banner_etc_issue_net
+++ xccdf_org.ssgproject.content_rule_banner_etc_issue_net
@@ -18,6 +18,7 @@
 - name: Modify the System Login Banner for Remote Connections - ensure correct banner
   ansible.builtin.copy:
     dest: /etc/issue.net
+    mode: 420
     content: |
       {{ remote_login_banner_contents | replace('\n', '
       ') }}

bash remediation for rule 'xccdf_org.ssgproject.content_rule_banner_etc_issue_net_cis' differs.
--- xccdf_org.ssgproject.content_rule_banner_etc_issue_net_cis
+++ xccdf_org.ssgproject.content_rule_banner_etc_issue_net_cis
@@ -4,6 +4,7 @@
 cis_banner_text=''
 
 echo "$cis_banner_text" > "/etc/issue.net"
+chmod 0644 "/etc/issue.net"
 
 else
     >&2 echo 'Remediation is not applicable, nothing was done'

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_banner_etc_issue_net_cis' differs.
--- xccdf_org.ssgproject.content_rule_banner_etc_issue_net_cis
+++ xccdf_org.ssgproject.content_rule_banner_etc_issue_net_cis
@@ -20,6 +20,7 @@
   ansible.builtin.copy:
     content: '{{ cis_banner_text }}'
     dest: /etc/issue.net
+    mode: 420
   when: '"kernel-core" in ansible_facts.packages'
   tags:
   - CCE-86167-4

bash remediation for rule 'xccdf_org.ssgproject.content_rule_banner_etc_motd' differs.
--- xccdf_org.ssgproject.content_rule_banner_etc_motd
+++ xccdf_org.ssgproject.content_rule_banner_etc_motd
@@ -3,6 +3,7 @@
 
 motd_banner_contents=$(echo "" | sed 's/\\n/\n/g')
 echo "$motd_banner_contents" > /etc/motd
+chmod 0644 /etc/motd
 
 else
     >&2 echo 'Remediation is not applicable, nothing was done'

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_banner_etc_motd' differs.
--- xccdf_org.ssgproject.content_rule_banner_etc_motd
+++ xccdf_org.ssgproject.content_rule_banner_etc_motd
@@ -18,6 +18,7 @@
 - name: Modify the System Message of the Day Banner - ensure correct banner
   ansible.builtin.copy:
     dest: /etc/motd
+    mode: 420
     content: |
       {{ motd_banner_contents | replace('\n', '
       ') }}

bash remediation for rule 'xccdf_org.ssgproject.content_rule_banner_etc_motd_cis' differs.
--- xccdf_org.ssgproject.content_rule_banner_etc_motd_cis
+++ xccdf_org.ssgproject.content_rule_banner_etc_motd_cis
@@ -4,6 +4,7 @@
 cis_banner_text=''
 
 echo "$cis_banner_text" > "/etc/motd"
+chmod 0644 "/etc/motd"
 
 else
     >&2 echo 'Remediation is not applicable, nothing was done'

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_banner_etc_motd_cis' differs.
--- xccdf_org.ssgproject.content_rule_banner_etc_motd_cis
+++ xccdf_org.ssgproject.content_rule_banner_etc_motd_cis
@@ -19,6 +19,7 @@
   ansible.builtin.copy:
     content: '{{ cis_banner_text }}'
     dest: /etc/motd
+    mode: 420
   when: '"kernel-core" in ansible_facts.packages'
   tags:
   - CCE-86145-0

bash remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_banner_enabled' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_banner_enabled
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_banner_enabled
@@ -10,6 +10,7 @@
 DBDIR="/etc/dconf/db/gdm.d"
 
 mkdir -p "${DBDIR}"
+chmod 0755 "${DBDIR}"
 
 # Comment out the configurations in databases different from the target one
 if [ "${#SETTINGSFILES[@]}" -ne 0 ]
@@ -41,6 +42,7 @@
 LOCKSFOLDER="/etc/dconf/db/gdm.d/locks"
 
 mkdir -p "${LOCKSFOLDER}"
+chmod 0755 "${LOCKSFOLDER}"
 
 # Comment out the configurations in databases different from the target one
 if [[ ! -z "${LOCKFILES}" ]]

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_banner_enabled' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_banner_enabled
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_banner_enabled
@@ -23,6 +23,7 @@
     value: 'true'
     create: true
     no_extra_spaces: true
+    mode: 420
   register: result_ini
   when: '"gdm" in ansible_facts.packages'
   tags:
@@ -45,6 +46,7 @@
     regexp: ^/org/gnome/login-screen/banner-message-enable$
     line: /org/gnome/login-screen/banner-message-enable
     create: true
+    mode: 420
   register: result_lineinfile
   when: '"gdm" in ansible_facts.packages'
   tags:

bash remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_login_banner_text' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_login_banner_text
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_login_banner_text
@@ -11,6 +11,7 @@
 DBDIR="/etc/dconf/db/gdm.d"
 
 mkdir -p "${DBDIR}"
+chmod 0755 "${DBDIR}"
 
 # Comment out the configurations in databases different from the target one
 if [ "${#SETTINGSFILES[@]}" -ne 0 ]
@@ -42,6 +43,7 @@
 LOCKSFOLDER="/etc/dconf/db/gdm.d/locks"
 
 mkdir -p "${LOCKSFOLDER}"
+chmod 0755 "${LOCKSFOLDER}"
 
 # Comment out the configurations in databases different from the target one
 if [[ ! -z "${LOCKFILES}" ]]

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_dconf_gnome_login_banner_text' differs.
--- xccdf_org.ssgproject.content_rule_dconf_gnome_login_banner_text
+++ xccdf_org.ssgproject.content_rule_dconf_gnome_login_banner_text
@@ -75,6 +75,7 @@
     value: '''{{ dconf_login_banner_contents }}'''
     create: true
     no_extra_spaces: true
+    mode: 420
   register: result_ini
   when: '"gdm" in ansible_facts.packages'
   tags:
@@ -97,6 +98,7 @@
     line: /org/gnome/login-screen/banner-message-text
     create: true
     state: present
+    mode: 420
   register: result_lineinfile
   when: '"gdm" in ansible_facts.packages'
   tags:

bash remediation for rule 'xccdf_org.ssgproject.content_rule_account_password_selinux_faillock_dir' differs.
--- xccdf_org.ssgproject.content_rule_account_password_selinux_faillock_dir
+++ xccdf_org.ssgproject.content_rule_account_password_selinux_faillock_dir
@@ -16,6 +16,7 @@
         fi
         if [ ! -e $dir ]; then
             mkdir -p $dir
+            chmod 0755 "$dir"
         fi
         /usr/sbin/restorecon -R -v $dir
     done

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_account_password_selinux_faillock_dir' differs.
--- xccdf_org.ssgproject.content_rule_account_password_selinux_faillock_dir
+++ xccdf_org.ssgproject.content_rule_account_password_selinux_faillock_dir
@@ -60,6 +60,7 @@
   ansible.builtin.file:
     path: '{{ item }}'
     state: directory
+    mode: 493
   with_items: '{{ list_faillock_dir }}'
   when:
   - '"kernel-core" in ansible_facts.packages'

bash remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_password_pam_pwhistory_enforce_for_root' differs.
--- xccdf_org.ssgproject.content_rule_accounts_password_pam_pwhistory_enforce_for_root
+++ xccdf_org.ssgproject.content_rule_accounts_password_pam_pwhistory_enforce_for_root
@@ -5,6 +5,7 @@
     LC_ALL=C sed -i "/^\s*enforce_for_root/Id" "/etc/security/pwhistory.conf"
 else
     touch "/etc/security/pwhistory.conf"
+    chmod 0644 "/etc/security/pwhistory.conf"
 fi
 # make sure file has newline at the end
 sed -i -e '$a\' "/etc/security/pwhistory.conf"

bash remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_dir' differs.
--- xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_dir
+++ xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_dir
@@ -121,6 +121,7 @@
 fi
 
 mkdir -p "$var_accounts_passwords_pam_faillock_dir"
+chmod 0755 "$var_accounts_passwords_pam_faillock_dir"
 # Workaround for https://github.com/OpenSCAP/openscap/issues/2242: Use full
 # path to semanage and restorecon commands to avoid the issue with the command
 # not being found.

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_dir' differs.
--- xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_dir
+++ xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_dir
@@ -747,6 +747,7 @@
     path: '{{ var_accounts_passwords_pam_faillock_dir }}'
     state: directory
     setype: faillog_t
+    mode: 493
   when:
   - '"kernel-core" in ansible_facts.packages'
   - '"pam" in ansible_facts.packages'

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_password_pam_dcredit' differs.
--- xccdf_org.ssgproject.content

... The diff is trimmed here ...

macko1 added a commit to macko1/content that referenced this pull request Jul 31, 2026
Address all findings from the code review:

Critical:
- Remove `mode: 0755` from `dir_system_commands_group_root_owned`
  and `dir_system_commands_root_owned` — these tasks use
  `recurse: yes` over `/usr/bin`, `/usr/sbin`, etc. and adding
  `mode:` would strip setuid bits from `sudo`, `passwd`, `su`

High:
- Parameterize `set_config_file` macro in `10-bash.jinja` to accept
  a `mode` parameter (default `0644`) so callers can override it
- Pass `mode="0640"` from `bash_auditd_config_set` (for
  `/etc/audit/auditd.conf`)
- Pass `mode="0600"` from `bash_sshd_config_set` (for
  `/etc/ssh/sshd_config`)
- Add `chmod 0600` for all four `cp` commands in
  `audit_rules_for_ospp/bash/shared.sh`

Medium:
- Change `/var/tmp` from `chmod 0755` to `chmod 1777` (sticky bit)
- Quote all unquoted shell variables in `chmod` calls
- Fix tab/space indentation in `ensure_logrotate_activated`
- Move `mode: 0644` after `{{% endif %}}` in
  `require_emergency_target_auth` and `require_singleuser_auth`
  so the parameter is unconditional within the task
@macko1

macko1 commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator Author

All findings from review round 1 addressed in 69e5777 and 0993236.

Fixed:

  1. (Critical) Removed mode: 0755 from dir_system_commands_group_root_owned and dir_system_commands_root_owned. These tasks use recurse: yes over /usr/bin, /usr/sbin, /usr/local/bin, /usr/local/sbin to set ownership only. Adding mode: with recursion strips setuid from sudo, passwd, su.

  2. (High) Parameterized the set_config_file macro with mode="0644" default. The bash_auditd_config_set macro passes mode="0640" for /etc/audit/auditd.conf, bash_sshd_config_set passes mode="0600" for /etc/ssh/sshd_config.

  3. (High) Added chmod 0600 for all four files copied into /etc/audit/rules.d/ by audit_rules_for_ospp/bash/shared.sh.

  4. (Medium) Changed /var/tmp from chmod 0755 to chmod 1777 (sticky bit).

  5. (Medium) Quoted all variable references in chmod calls.

  6. (Medium) Fixed tab/space indentation in ensure_logrotate_activated/bash/shared.sh.

  7. (Medium) Moved mode: 0644 after {{% endif %}} in require_emergency_target_auth and require_singleuser_auth so the parameter applies unconditionally.

0993236 reverts the block: re-indentation in tftp_uses_secure_mode_systemd from commit c4fa1e2 — the deeper indentation changed the content: |- scalar, altering the systemd unit file written by the remediation.

Kept as-is (see PR description "Scope decisions"):

  • SSSD 0600/0711 — matches existing repo macros, not RPM defaults. Both work per man 5 sssd.conf.
  • Ansible macro chain — ansible_auditd_set, ansible_sshd_set lack mode: threading. Deferred to follow-up.

@macko1

macko1 commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator Author

CI: All failures are pre-existing or infrastructure issues.

Yaml Lint on Changed yaml files

  • Pre-existing Jinja2 syntax errors in files this PR touches — same errors exist on main

Run Tests (Automatus)

  • Automatus SLE15, Automatus Debian 12, Automatus Debian 13, Automatus Ubuntu 22.04, Automatus UBI8
    — "Couldn't install required packages" (package installation fails in the CI container before tests run)

  • Automatus Fedoratftp_uses_secure_mode_systemd test setup scripts fail

    • tftp-server not available in CI container
    • No test files modified by this PR
  • Automatus CS9tftpd_uses_secure_mode test setup scripts fail

    • /etc/xinetd.d/tftp: No such file or directory
    • xinetd is obsolete on CentOS Stream 9

Red Hat Konflux

  • Pre-existing compliance-operator-dev-enterprise-contract failure — also fails on merged #14950 and #14948

grub2_nousb_argument rule

  • Pre-existing bug in the ansible_grub2_bootloader_argument macro — this PR does not touch that rule, its template, or any macro it uses
  • wrong_value_entries.fail fails on per-rule ansible tests
  • The macro matches nousb= as containing nousb and skips remediation

Datastream diff

  • Rendered playbooks show mode: 420 instead of mode: 0644 — YAML 1.1 parses unquoted 0644 as octal, serializes as decimal 420
  • Ansible sets correct permissions with both representations
  • ansible-lint flags this as risky-octal — follow-up task created to quote all octal mode values repo-wide

@macko1
macko1 marked this pull request as ready for review August 4, 2026 12:36
@openshift-ci openshift-ci Bot removed the do-not-merge/work-in-progress Used by openshift-ci bot. label Aug 4, 2026
@macko1 macko1 changed the title DRAFT: Ansible/Bash remediations: add explicit file permissions to all file-creating tasks and commands Ansible/Bash remediations: add explicit file permissions to all file-creating tasks and commands Aug 4, 2026
@Mab879 Mab879 self-assigned this Aug 4, 2026
@macko1
macko1 requested a review from Mab879 August 4, 2026 12:55

@Mab879 Mab879 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For all new modes should we just quote them now in Ansible?

Please see my other comments below.

else
echo "ExecStart=-$sulogin" >> "$service_file"
fi
{{% endif %}}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You need to chmod the drop-in file.

else
mkdir -p "$DROPIN_DIR"
chmod 0755 "$DROPIN_DIR"
echo "* hard core 0" >> $DROPIN_FILE

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You should chmod the drop-in file as well.


{{{ include_directive }}}
EOF
chmod 0644 {{{ base_config }}}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
chmod 0644 {{{ base_config }}}
chmod 0600 {{{ base_config }}}

Based on my quick test on a default RHEL 10 box.

macko1 added 7 commits August 5, 2026 12:25
Add `mode:` to Ansible macros and `chmod` to bash macros in
`shared/macros/` that create files without explicit permissions.

`owner:` and `group:` are not added — remediations run as `root`,
so every created file is owned by `root:root` by default. Adding
explicit ownership to every task inflates the diff without changing
runtime behavior.

Ansible macros fixed in `shared/macros/10-ansible.jinja`:

- `ansible_file_contents` macro
  - `ansible.builtin.copy` task without `mode:`

- `ansible_pam_faillock_enable` macro
  - `ansible.builtin.copy` tasks for `cac_faillock` and
    `cac_faillock_notify` without `mode:`

- `ansible_pam_pwquality_enable` macro
  - `ansible.builtin.copy` task without `mode:`

- `ansible_setup_rsyslog_common` macro
  - `ansible.builtin.file` with `state: touch` for
    `/etc/rsyslog.conf` without `mode:`
  - `ansible.builtin.file` with `state: directory` for
    `/etc/rsyslog.d` without `mode:`

- `ansible_enable_dconf_user_profile` macro
  - `ansible.builtin.lineinfile` with `create: yes` without `mode:`

Bash macros fixed in `shared/macros/10-bash.jinja`:

- `bash_sshd_remediation` — `mkdir` without `chmod`
  (`0700` for `/etc/ssh/sshd_config.d/`)
- `bash_create_audit_remediation_unsuccessful_file_modification_detailed`
  — `mkdir` and `cat` heredoc without `chmod`
  (`0750`/`0600` for `/etc/audit/rules.d/`)
- `bash_dconf_settings` and `bash_dconf_lock`
  — `mkdir` without `chmod` for `/etc/dconf/db/`
- `bash_enable_pam_faillock_directly_in_pam_files`
  — `cat` heredoc without `chmod`
- `bash_pam_pwquality_enable` — `cat` heredoc without `chmod`
- `bash_pam_unix_enable` — `cp` without `chmod`
- `bash_pam_pwhistory_enable` — `cat` heredoc without `chmod`
- `set_config_file` — `touch` without `chmod`
- `bash_file_contents` — `cat` heredoc without `chmod`
- `bash_sssd_ensure_default_config`
  — `mkdir` (`0711` for `/etc/sssd/`) and `touch` (`0600`) without `chmod`
- `bash_ensure_ini_config` — `mkdir` without `chmod`
- `bash_enable_dconf_user_profile`
  — `mkdir` and `echo` without `chmod` for `/etc/dconf/`

None of the fixed macros accept a `mode` parameter, so all values
are hardcoded. Mode values match RPM package defaults and OVAL
permission checks.
Add `mode:` to Ansible template tasks and `chmod` to bash templates
in `shared/templates/` that create files without explicit permissions.

Ansible templates fixed:

- `accounts_password/ansible.template`
  - `ansible.builtin.lineinfile`, `mode: 0644` for
    `/etc/security/pwquality.conf`

- `audit_rules_syscall_events/ansible.template`
  - all four `ansible.builtin.lineinfile` tasks, `mode: 0600`
    for `/etc/audit/rules.d/` files

- `cis_banner/ansible.template`
  - `ansible.builtin.copy`, `mode: 0644` for `/etc/issue`,
    `/etc/issue.net`, `/etc/motd`

- `dconf_ini_file/ansible.template`
  - `community.general.ini_file` and `ansible.builtin.lineinfile`
    tasks, `mode: 0644` for `/etc/dconf/db/` files

- `kernel_module_disabled/ansible.template`
  - `ansible.builtin.lineinfile` tasks, `mode: 0644` for
    `/etc/modprobe.d/*.conf`

- `systemd_dropin_configuration/ansible.template`
  - `community.general.ini_file`, `mode: 0644` for
    `complianceascode_hardening.conf`

- `zipl_bls_entries_option/ansible.template`
  - `ansible.builtin.lineinfile`, `mode: 0644` for
    `/etc/kernel/cmdline`

Bash templates fixed:

- `cis_banner/bash.template`
  - `chmod 0644` after `echo` redirect

- `zipl_bls_entries_option/bash.template`
  - `chmod 0644` after `echo` redirect to `/etc/kernel/cmdline`

- `pam_account_password_faillock/bash.template`
  - `chmod 0644` after `cp` to `/etc/security/faillock.conf`
Add `mode:` to Ansible tasks and `chmod` to bash commands across
standalone remediation files in `linux_os/` that create files
without explicit permissions.

Ansible modules fixed:

- `ansible.builtin.lineinfile` with `create: yes`
  - `auditd` retention rules for `/etc/audit/auditd.conf` (`0640`)
  - NTP config for `chrony`, `ntpd`, `timesyncd` (`0644`)
  - SSH client config in `/etc/profile.d/` (`0644`)
  - `/etc/login.defs` (`0644`)
  - `dconf` settings and locks in `/etc/dconf/db/` (`0644`)
  - `rsyslog` config (`0644`)
  - `systemd` drop-in files (`0644`)
  - kernel module config in `/etc/modprobe.d/` (`0644`)
  - network config for `nmcli` and `nftables` (`0644`)
  - SELinux config (`0644`)

- `community.general.ini_file`
  - `dconf`/GNOME settings (`0644`)
  - SSSD config in `/etc/sssd/` (`0600`)
  - `dnf`/`yum` config (`0644`)
  - `systemd` drop-in files (`0644`)

- `ansible.builtin.copy`
  - banner files `/etc/issue`, `/etc/issue.net`, `/etc/motd` (`0644`)
  - `chrony-wait.service` (`0644`)
  - TFTP drop-in (`0644`)
  - coredump limits drop-in (`0644`)
  - shadow backup `/etc/shadow-` (`0000`)

- `ansible.builtin.blockinfile` with `create: yes`
  - audit file modification rules in `/etc/audit/rules.d/` (`0600`)
  - `systemd` service overrides (`0644`)
  - `tmux` profile in `/etc/profile.d/` (`0644`)
  - `modprobe` wireless config (`0644`)

- `ansible.builtin.file` with `state: touch` or `state: directory`
  - `faillock` directories (`0755`)
  - `rsyslog` touch (`0644`) and directory (`0755`)
  - crypto policy directories (`0755`)

Bash commands fixed:

- `mkdir`
  - `systemd`, `journal`, SSSD, `logind`, `rsyslog`, `faillock` dirs

- `echo`/`printf` redirect
  - banners, SSH client, crypto policy, `modprobe`, `nftables`, `polkit`

- `cat` heredoc
  - `chrony-wait`, TFTP drop-in, `systemd` mount, AIDE, `openssl`,
    FIPS, PAM, SSH confirm

- `touch`
  - `rsyslog`, `journal-upload`, `nftables`

- `cp`
  - `/etc/shadow-`, `/etc/group-`, `/etc/passwd-` backups,
    `/etc/sudoers.bak`, PAM `pkcs11` config

- `nft` redirect
  - `nftables` filter rules

Manual corrections after the automated script:

- `ensure_logrotate_activated`: `chmod 0755` (not `0644`) because
  `/etc/cron.daily/logrotate` is an executable script

- `sshd_use_directory_configuration`: `chmod 0700` (not `0755`)
  because the `openssh-server` RPM sets `/etc/ssh/sshd_config.d/`
  to `drwx------`

- `no_legacy_plus_entries_etc_shadow`: `mode: 0000` (not `0644`)
  because `/etc/shadow-` matches `/etc/shadow` permissions
Fix indentation and trailing whitespace errors in remediation
files where the `mode:` insertion script used incorrect indentation
or left trailing spaces.

Indentation fixes:
- `tftp_uses_secure_mode_systemd/ansible/shared.yml`
- `accounts_umask_etc_csh_cshrc/ansible/shared.yml`
- `accounts_umask_etc_login_defs/ansible/shared.yml`
- `rsyslog_remote_access_monitoring/ansible/ubuntu.yml`
- `aide_check_audit_tools/ansible/shared.yml`

Trailing whitespace removed:
- `chronyd_configure_pool_and_server/ansible/shared.yml`
- `dir_system_commands_group_root_owned/ansible/shared.yml`
- `dir_system_commands_root_owned/ansible/shared.yml`
- `harden_openssl_crypto_policy/ansible/shared.yml`
Address all findings from the code review:

Critical:
- Remove `mode: 0755` from `dir_system_commands_group_root_owned`
  and `dir_system_commands_root_owned` — these tasks use
  `recurse: yes` over `/usr/bin`, `/usr/sbin`, etc. and adding
  `mode:` would strip setuid bits from `sudo`, `passwd`, `su`

High:
- Parameterize `set_config_file` macro in `10-bash.jinja` to accept
  a `mode` parameter (default `0644`) so callers can override it
- Pass `mode="0640"` from `bash_auditd_config_set` (for
  `/etc/audit/auditd.conf`)
- Pass `mode="0600"` from `bash_sshd_config_set` (for
  `/etc/ssh/sshd_config`)
- Add `chmod 0600` for all four `cp` commands in
  `audit_rules_for_ospp/bash/shared.sh`

Medium:
- Change `/var/tmp` from `chmod 0755` to `chmod 1777` (sticky bit)
- Quote all unquoted shell variables in `chmod` calls
- Fix tab/space indentation in `ensure_logrotate_activated`
- Move `mode: 0644` after `{{% endif %}}` in
  `require_emergency_target_auth` and `require_singleuser_auth`
  so the parameter is unconditional within the task
The yamllint fix commit re-indented tasks inside a block: section
from 4 spaces to 8 spaces. This changed the content: |- scalar
indentation, altering the systemd unit file content written by the
remediation. Reverted to the original 4-space indent (pre-existing
yamllint style issue) and kept only the mode: additions.
Bash remediations creating drop-in files via shell redirects and
ansible remediations using ansible_lineinfile with create=yes were
missing explicit chmod/mode. Files inherit umask-based permissions
instead of explicit values, making remediation output non-deterministic.

Changes:

- Add chmod to bash remediations using shell redirects (>>, >, cat >)
- Add mode= parameter to ansible_lineinfile macro calls where missing
- Quote mode values in direct ansible tasks (mode: 0644 → mode: '0644')
@macko1
macko1 force-pushed the RHEL-182657-remediation-explicit-permissions branch from 0993236 to f4bc93f Compare August 5, 2026 13:31
@macko1

macko1 commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator Author

@Mab879 Good catch. Remediations for drop-in files/folders should be fixed in f4bc93f.

@openshift-ci

openshift-ci Bot commented Aug 5, 2026

Copy link
Copy Markdown

@macko1: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-aws-openshift-node-compliance f4bc93f link false /test e2e-aws-openshift-node-compliance

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Both macros call ansible_set_config_file, which already accepts a
mode= parameter and threads it through ansible_only_lineinfile down
to ansible.builtin.lineinfile. Neither caller passed it, so files
created by ansible.builtin.lineinfile with create: yes fell back to
umask-derived permissions.

ansible_auditd_set now passes mode="0640" for /etc/audit/auditd.conf.
ansible_sshd_set now passes mode="0600" for /etc/ssh/sshd_config, but
only in the non-distributed branch; the distributed branch already
sets mode via a separate follow-up task.

ansible_auditd_set is not called by any rule today. ansible_sshd_set
is used by every rule with config_is_distributed=false. Verified on
ol8 with sshd_rekey_limit, which renders mode: '0600' on the
/etc/ssh/sshd_config task.
@macko1

macko1 commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator Author

PR desc updated, PTAL again, @Mab879

@macko1
macko1 requested a review from Mab879 August 5, 2026 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants