8000 Update enable_authselect remediation on bootable containers by matusmarhefka · Pull Request #13131 · ComplianceAsCode/content · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Update enable_authselect remediation on bootable containers #13131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

matusmarhefka
Copy link
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
Copy link
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

Copy link
codeclimate bot commented Mar 3, 2025

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.

8000
@jan-cerny jan-cerny self-assigned this Mar 3, 2025
Copy link
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
104 of 111 checks passed
@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 Bo 4938 otable containers and Image Mode RHEL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0