Skip to content

Commit 37188e2

Browse files
authored
Merge pull request #14462 from jan-cerny/rhel10_pqc
Check for PQC GPG key only on RHEL 10.1 and newer
2 parents 76f443e + ca678fa commit 37188e2

3 files changed

Lines changed: 48 additions & 9 deletions

File tree

linux_os/guide/system/software/updating/ensure_redhat_gpgkey_installed/ansible/shared.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,27 @@
4040

4141
{{% endif %}}
4242

43-
- name: "{{{ rule_title }}}: Set Fact - Valid fingerprints"
43+
{{% if "rhel" in families and major_version_ordinal >= 10 %}}
44+
- name: "{{{ rule_title }}}: Set Fact - Valid fingerprints (without PQC)"
45+
ansible.builtin.set_fact:
46+
gpg_valid_fingerprints:
47+
- "{{{ release_key_fingerprint }}}"
48+
- "{{{ auxiliary_key_fingerprint }}}"
49+
when: ansible_distribution_version is version('10.1', '<')
50+
51+
- name: "{{{ rule_title }}}: Set Fact - Valid fingerprints (with PQC)"
4452
ansible.builtin.set_fact:
4553
gpg_valid_fingerprints:
4654
- "{{{ release_key_fingerprint }}}"
4755
- "{{{ auxiliary_key_fingerprint }}}"
48-
{{% if "rhel" in families and major_version_ordinal >= 10 %}}
4956
- "{{{ pqc_key_fingerprint }}}"
57+
when: ansible_distribution_version is version('10.1', '>=')
58+
{{% else %}}
59+
- name: "{{{ rule_title }}}: Set Fact - Valid fingerprints"
60+
ansible.builtin.set_fact:
61+
gpg_valid_fingerprints:
62+
- "{{{ release_key_fingerprint }}}"
63+
- "{{{ auxiliary_key_fingerprint }}}"
5064
{{% endif %}}
5165

5266
- name: "{{{ rule_title }}}: Import RedHat GPG key"

linux_os/guide/system/software/updating/ensure_redhat_gpgkey_installed/bash/shared.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,16 @@ then
2525
# No CRC error, safe to proceed
2626
if [ "${GPG_RESULT}" -eq "0" ]
2727
then
28+
# If $REDHAT_RELEASE_KEY file doesn't contain any keys with unknown fingerprint, import it
2829
{{% if "rhel" in families and major_version_ordinal >= 10 %}}
29-
echo "${GPG_OUT[*]}" | grep -vE "${REDHAT_RELEASE_FINGERPRINT}|${REDHAT_AUXILIARY_FINGERPRINT}|${REDHAT_PQC_FINGERPRINT}" || {
30+
if {{{ bash_os_linux_conditional("rhel", expected_ver="10.1", op=">=") | trim }}}
31+
then
32+
echo "${GPG_OUT[*]}" | grep -vE "${REDHAT_RELEASE_FINGERPRINT}|${REDHAT_AUXILIARY_FINGERPRINT}|${REDHAT_PQC_FINGERPRINT}" || rpm --import "${REDHAT_RELEASE_KEY}"
33+
else
34+
echo "${GPG_OUT[*]}" | grep -vE "${REDHAT_RELEASE_FINGERPRINT}|${REDHAT_AUXILIARY_FINGERPRINT}" || rpm --import "${REDHAT_RELEASE_KEY}"
35+
fi
3036
{{% else %}}
31-
echo "${GPG_OUT[*]}" | grep -vE "${REDHAT_RELEASE_FINGERPRINT}|${REDHAT_AUXILIARY_FINGERPRINT}" || {
37+
echo "${GPG_OUT[*]}" | grep -vE "${REDHAT_RELEASE_FINGERPRINT}|${REDHAT_AUXILIARY_FINGERPRINT}" || rpm --import "${REDHAT_RELEASE_KEY}"
3238
{{% endif %}}
33-
# If $REDHAT_RELEASE_KEY file doesn't contain any keys with unknown fingerprint, import it
34-
rpm --import "${REDHAT_RELEASE_KEY}"
35-
}
3639
fi
3740
fi

linux_os/guide/system/software/updating/ensure_redhat_gpgkey_installed/oval/shared.xml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,13 @@
1313
<criterion comment="package gpg-pubkey-{{{ aux_pkg_version }}}-{{{ aux_pkg_release }}} is installed"
1414
test_ref="test_redhat_package_gpgkey-{{{ aux_pkg_version }}}-{{{ aux_pkg_release }}}_installed" />
1515
{{% if "rhel" in families and major_version_ordinal >= 10 %}}
16-
<criterion comment="package gpg-pubkey-{{{ pqc_pkg_version }}}-{{{ pqc_pkg_release }}} is installed"
17-
test_ref="test_redhat_package_gpgkey-{{{ pqc_pkg_version }}}-{{{ pqc_pkg_release }}}_installed" />
16+
<criteria comment="If RHEL is 10.1 or newer then PQC key must be installed" operator="OR">
17+
<criterion comment="RHEL is older than 10.1" test_ref="test_{{{ rule_id }}}_rhel_is_10_1_or_newer" negate="true" />
18+
<criteria comment="RHEL is 10.1 or newer AND PQC is installed" operator="AND">
19+
<criterion comment="RHEL is 10.1 or newer" test_ref="test_{{{ rule_id }}}_rhel_is_10_1_or_newer" />
20+
<criterion comment="package gpg-pubkey-{{{ pqc_pkg_version }}}-{{{ pqc_pkg_release }}} is installed" test_ref="test_redhat_package_gpgkey-{{{ pqc_pkg_version }}}-{{{ pqc_pkg_release }}}_installed" />
21+
</criteria>
22+
</criteria>
1823
{{% endif %}}
1924
</criteria>
2025
{{%- if centos_major_version %}}
@@ -88,5 +93,22 @@
8893
</linux:rpminfo_state>
8994
{{%- endif %}}
9095

96+
{{% if "rhel" in families and major_version_ordinal >= 10 %}}
97+
<ind:textfilecontent54_test check="all" comment="VERSION_ID in os-release is greater than or equal 10.1" id="test_{{{ rule_id }}}_rhel_is_10_1_or_newer" version="1">
98+
<ind:object object_ref="obj_{{{ rule_id }}}_rhel_is_10_1_or_newer" />
99+
<ind:state state_ref="state_{{{ rule_id }}}_rhel_is_10_1_or_newer" />
100+
</ind:textfilecontent54_test>
101+
102+
<ind:textfilecontent54_object id="obj_{{{ rule_id }}}_rhel_is_10_1_or_newer" version="1">
103+
<ind:filepath>/etc/os-release</ind:filepath>
104+
<ind:pattern operation="pattern match">^VERSION_ID=[&quot;&apos;]?([\w.]+)[&quot;&apos;]?$</ind:pattern>
105+
<ind:instance operation="greater than or equal" datatype="int">1</ind:instance>
106+
</ind:textfilecontent54_object>
107+
108+
<ind:textfilecontent54_state id="state_{{{ rule_id }}}_rhel_is_10_1_or_newer" version="1">
109+
<ind:subexpression operation="greater than or equal" datatype="version">10.1</ind:subexpression>
110+
</ind:textfilecontent54_state>
111+
{{% endif %}}
112+
91113
</def-group>
92114
{{% endif %}}

0 commit comments

Comments
 (0)