Skip to content

Update enable_authselect remediation on bootable containers#13131

Merged
jan-cerny merged 1 commit into
ComplianceAsCode:masterfrom
matusmarhefka:rhel9_authselect_bootc
Mar 3, 2025
Merged

Update enable_authselect remediation on bootable containers#13131
jan-cerny merged 1 commit into
ComplianceAsCode:masterfrom
matusmarhefka:rhel9_authselect_bootc

Conversation

@matusmarhefka
Copy link
Copy Markdown
Member

The authselect has been added into RHEL 9 bootable containers in https://issues.redhat.com/browse/RHEL-76811 but there is no default authselect profile selected and that is causing the remediation of the rule enable_authselect to fail:

[root]# authselect current
No existing configuration detected.

[root]# authselect select sssd
No existing configuration detected.
[error] File [/etc/pam.d/system-auth] exists but it needs to be overwritten!
[error] File [/etc/pam.d/password-auth] exists but it needs to be overwritten!
[error] File [/etc/pam.d/fingerprint-auth] exists but it needs to be overwritten!
[error] File [/etc/pam.d/smartcard-auth] exists but it needs to be overwritten!
[error] File [/etc/pam.d/postlogin] exists but it needs to be overwritten!
[error] File [/etc/nsswitch.conf] exists but it needs to be overwritten!
[error] File that needs to be overwritten was found
[error] Refusing to activate profile unless this file is removed or overwrite is requested.

Some unexpected changes to the configuration were detected.
Use --force parameter if you want to overwrite these changes.
authselect is not used but files from the 'pam' package have been altered, so the authselect configuration won't be forced.

Therefore, we update the remediation to run authselect select command with the --force parameter when running on a bootable container which resolves this issue.

The `authselect` has been added into RHEL 9 bootable containers in
https://issues.redhat.com/browse/RHEL-76811 but there is no default
authselect profile selected and that is causing the remediation of
the rule `enable_authselect` to fail:

```
[root]# authselect current
No existing configuration detected.

[root]# authselect select sssd
No existing configuration detected.
[error] File [/etc/pam.d/system-auth] exists but it needs to be overwritten!
[error] File [/etc/pam.d/password-auth] exists but it needs to be overwritten!
[error] File [/etc/pam.d/fingerprint-auth] exists but it needs to be overwritten!
[error] File [/etc/pam.d/smartcard-auth] exists but it needs to be overwritten!
[error] File [/etc/pam.d/postlogin] exists but it needs to be overwritten!
[error] File [/etc/nsswitch.conf] exists but it needs to be overwritten!
[error] File that needs to be overwritten was found
[error] Refusing to activate profile unless this file is removed or overwrite is requested.

Some unexpected changes to the configuration were detected.
Use --force parameter if you want to overwrite these changes.
authselect is not used but files from the 'pam' package have been altered, so the authselect configuration won't be forced.
```

Therefore, we update the remediation to run `authselect select` command
with the `--force` parameter when running on a bootable container which
resolves this issue.
@matusmarhefka matusmarhefka added the Image Mode Bootable containers and Image Mode RHEL label Mar 3, 2025
@matusmarhefka matusmarhefka added this to the 0.1.77 milestone Mar 3, 2025
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 3, 2025

This datastream diff is auto generated by the check Compare DS/Generate Diff

Click here to see the full diff
bash remediation for rule 'xccdf_org.ssgproject.content_rule_enable_authselect' differs.
--- xccdf_org.ssgproject.content_rule_enable_authselect
+++ xccdf_org.ssgproject.content_rule_enable_authselect
@@ -5,7 +5,11 @@
 authselect current
 
 if test "$?" -ne 0; then
-    authselect select "$var_authselect_profile"
+    if { rpm --quiet -q kernel rpm-ostree bootc && ! rpm --quiet -q openshift-kubelet && { [ -f "/run/.containerenv" ] || [ -f "/.containerenv" ]; }; }; then
+        authselect select --force "$var_authselect_profile"
+    else
+        authselect select "$var_authselect_profile"
+    fi
 
     if test "$?" -ne 0; then
         if rpm --quiet --verify pam; then

@qlty-cloud-legacy
Copy link
Copy Markdown

Code Climate has analyzed commit 8ec4bca and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (50% is the threshold).

This pull request will bring the total coverage in the repository to 62.1% (0.0% change).

View more on Code Climate.

@jan-cerny jan-cerny self-assigned this Mar 3, 2025
Copy link
Copy Markdown
Collaborator

@jan-cerny jan-cerny left a comment

Choose a reason for hiding this comment

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

I have built a RHEL 9 bootable container image hardened with the STIG profile using content built from this PR branch. I have deployed a VM from the built bootable container image using podman-bootc and I run a verification oscap scan. The rules that previously failed are passed in the report.

@jan-cerny jan-cerny added the Bash Bash remediation update. label Mar 3, 2025
@jan-cerny jan-cerny merged commit cd0bce1 into ComplianceAsCode:master Mar 3, 2025
@matusmarhefka matusmarhefka deleted the rhel9_authselect_bootc branch March 3, 2025 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bash Bash remediation update. Image Mode Bootable containers and Image Mode RHEL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants