Skip to content

Commit 5026b8f

Browse files
authored
Merge pull request #14659 from ggbecker/fix-14600
Fix authselect remediation with multiple features
2 parents b89ff37 + 89044cb commit 5026b8f

6 files changed

Lines changed: 60 additions & 3 deletions

File tree

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
# packages = authselect,pam
3+
# platform = Oracle Linux 8,Oracle Linux 9,multi_platform_rhel,multi_platform_fedora
4+
# remediation = ansible
5+
6+
authselect create-profile test_profile -b sssd
7+
authselect select "custom/test_profile" --force
8+
9+
# Enable multiple features to test the scenario where "authselect current --raw"
10+
# returns a string with spaces (e.g., "custom/test_profile with-faillock with-fingerprint")
11+
authselect enable-feature with-faillock
12+
authselect enable-feature with-fingerprint
13+
14+
authselect apply-changes
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
# packages = authselect,pam
3+
# platform = Oracle Linux 8,Oracle Linux 9,multi_platform_rhel,multi_platform_fedora
4+
5+
authselect create-profile test_profile -b sssd
6+
authselect select "custom/test_profile" --force
7+
8+
# Enable other features but not with-faillock to simulate a system
9+
# that has authselect configured with features, but missing the required faillock
10+
authselect enable-feature with-fingerprint
11+
authselect enable-feature with-silent-lastlog
12+
13+
authselect apply-changes
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
# packages = authselect,pam
3+
# platform = Oracle Linux 8,Oracle Linux 9,multi_platform_rhel,multi_platform_fedora
4+
5+
# Simulate a real RHEL system with sssd profile and multiple features enabled
6+
# This is the scenario reported in issue #14600 where "authselect current --raw"
7+
# returns "sssd with-fingerprint with-silent-lastlog"
8+
authselect select sssd --force
9+
authselect enable-feature with-faillock
10+
authselect enable-feature with-fingerprint
11+
authselect enable-feature with-silent-lastlog
12+
13+
authselect apply-changes
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
# packages = authselect,pam
3+
# platform = Oracle Linux 8,Oracle Linux 9,multi_platform_rhel,multi_platform_fedora
4+
5+
# Test with sssd profile and one feature (not faillock) enabled
6+
# This simulates a system where "authselect current --raw" returns "sssd with-fingerprint"
7+
authselect select sssd --force
8+
authselect enable-feature with-fingerprint
9+
10+
authselect apply-changes

shared/macros/10-ansible.jinja

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -944,9 +944,15 @@ The following macro remediates Audit syscall rule in :code:`/etc/audit/audit.rul
944944

945945
#}}
946946
{{% macro ansible_authselect_force_reselect(rule_title=None) -%}}
947+
- name: '{{{ rule_title }}} - Get current authselect profile'
948+
ansible.builtin.command:
949+
cmd: authselect current --raw
950+
register: authselect_current_profile
951+
changed_when: false
952+
947953
- name: '{{{ rule_title }}} - Force reselect authselect profile'
948-
ansible.builtin.shell:
949-
cmd: authselect select "$(authselect current --raw)" --force
954+
ansible.builtin.command:
955+
cmd: "authselect select {{ authselect_current_profile.stdout }} --force"
950956
{{%- endmacro %}}
951957

952958
{{#

shared/macros/10-bash.jinja

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2484,7 +2484,8 @@ fi
24842484

24852485
#}}
24862486
{{% macro bash_authselect_force_reselect() -%}}
2487-
authselect select "$(authselect current --raw)" --force
2487+
read -ra authselect_args < <(authselect current --raw)
2488+
authselect select "${authselect_args[@]}" --force
24882489
{{%- endmacro %}}
24892490

24902491

0 commit comments

Comments
 (0)