From 96d27202a3caa4741708028b7ea441f5baa9a198 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20=C4=8Cern=C3=BD?= Date: Wed, 8 Jan 2025 11:08:42 +0100 Subject: [PATCH] Use nss-altfiles in file_groupowner_etc_chrony_keys The bootable containers and Image Mode Operating systems use `/usr/lib/group` provided by the `nss-altfiles` RPM package as an alternative place to define user groups in the system. The rule `file_groupowner_etc_chrony_keys` didn't read the `/usr/lib/group`. As a result the rule failed in the after-deployment scan with the ANSSI BP28 High profile. This commit extends the check to read `/usr/lib/group`, which makes the rule pass in Image Mode. This change has been inspired by the code in rule `file_permissions_ungroupowned` which already has been modified for Image Mode. The code that is same in OVALs in both rules has been extracted to a Jinja 2 macro to prevent code duplication and enable further reuse in future. --- .../oval/shared.xml | 72 +++++++++++++++++++ .../oval/shared.xml | 17 +---- shared/macros/10-oval.jinja | 22 ++++++ 3 files changed, 95 insertions(+), 16 deletions(-) create mode 100644 linux_os/guide/services/ntp/file_groupowner_etc_chrony_keys/oval/shared.xml diff --git a/linux_os/guide/services/ntp/file_groupowner_etc_chrony_keys/oval/shared.xml b/linux_os/guide/services/ntp/file_groupowner_etc_chrony_keys/oval/shared.xml new file mode 100644 index 00000000000..e6ce282c9de --- /dev/null +++ b/linux_os/guide/services/ntp/file_groupowner_etc_chrony_keys/oval/shared.xml @@ -0,0 +1,72 @@ + + + + {{{ oval_metadata("All files should be owned by a group") }}} + + + + + + + + + + + + +{{{ oval_test_nsswitch_uses_altfiles() }}} + + + + + + /etc/chrony.keys + state_file_groupowner_etc_chrony_keys_uid_chrony + state_file_groupowner_etc_chrony_keys_gid_chrony + + + /etc/group + ^chrony:\w+:(\w+):.* + 1 + + + + + + symbolic link + + + + + + + + + + /etc/chrony.keys + state_file_groupowner_etc_chrony_keys_uid_chrony + state_file_groupowner_etc_chrony_keys_gid_chrony_with_usrlib + + + + object_file_groupowner_etc_chrony_keys_etc_group + object_file_groupowner_etc_chrony_keys_usr_lib_group + + + + /usr/lib/group + ^chrony:\w+:(\w+):.* + 1 + + + + + + + + + diff --git a/linux_os/guide/system/permissions/files/file_permissions_ungroupowned/oval/shared.xml b/linux_os/guide/system/permissions/files/file_permissions_ungroupowned/oval/shared.xml index 2abf8f046d9..9c7e307c69a 100644 --- a/linux_os/guide/system/permissions/files/file_permissions_ungroupowned/oval/shared.xml +++ b/linux_os/guide/system/permissions/files/file_permissions_ungroupowned/oval/shared.xml @@ -92,22 +92,7 @@ state_file_permissions_ungroupowned_sysroot - - - - - - - /etc/nsswitch.conf - ^\s*group:\s+(.*)$ - 1 - - - - altfiles - +{{{ oval_test_nsswitch_uses_altfiles() }}} + + + + + /etc/nsswitch.conf + ^\s*group:\s+(.*)$ + 1 + + + altfiles + +{{%- endmacro -%}}