Skip to content

Commit 18ee96b

Browse files
authored
Merge pull request #14726 from Arden97/sssd_fails
Add default domain to SSSD related remediations and fix Fedora test failures
2 parents 273cad0 + 20f13fe commit 18ee96b

22 files changed

Lines changed: 270 additions & 168 deletions

File tree

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,16 @@
11
# sssd.service needs /etc/sssd/sssd.conf to start
2-
if [ ! -f /etc/sssd/sssd.conf ]; then
3-
cat << EOF > /etc/sssd/sssd.conf
4-
[sssd]
5-
config_file_version = 2
6-
services = nss, pam
7-
domains = example.com
2+
SSSD_CONF="/etc/sssd/sssd.conf"
3+
SSSD_CONF_DIR="/etc/sssd/conf.d"
4+
{{{ bash_sssd_ensure_default_config("$SSSD_CONF", "$SSSD_CONF_DIR") }}}
85

9-
[domain/example.com]
10-
{{%- if ('rhel' in product or 'ol' in families) and product not in ['ol8', 'ol9', 'rhel8', 'rhel9']%}}
11-
id_provider = proxy
12-
proxy_lib_name = files
13-
local_auth_policy = only
14-
{{%- else %}}
15-
id_provider = files
16-
access_provider = simple
17-
simple_allow_users = user1, user2
6+
{{%- if ('rhel' in product or 'ol' in families) and product not in ['ol7', 'ol8', 'ol9', 'rhel8', 'rhel9']%}}
7+
{{{ bash_ensure_ini_config("$SSSD_CONF $SSSD_CONF_DIR/*.conf", "pam", "pam_cert_auth", "True") }}}
188
{{%- endif %}}
199

20-
[nss]
21-
filter_groups = root
22-
filter_users = root
23-
24-
[pam]
25-
{{%- if ('rhel' in product or 'ol' in families) and product not in ['ol8', 'ol9', 'rhel8', 'rhel9']%}}
26-
pam_cert_auth = True
10+
{{%- if product in ["fedora"] or (('rhel' in product or 'ol' in families) and product not in ['ol7', 'ol8', 'ol9', 'rhel8', 'rhel9']) %}}
11+
{{{ bash_package_install("sssd-proxy") }}}
12+
authselect select sssd with-smartcard
13+
chmod 0640 $SSSD_CONF
14+
{{%- else %}}
15+
chmod 0600 $SSSD_CONF
2716
{{%- endif %}}
28-
EOF
29-
{{%- if ('rhel' in product or 'ol' in families) and product not in ['ol8', 'ol9', 'rhel8', 'rhel9']%}}
30-
dnf install sssd-proxy -y
31-
authselect select sssd with-smartcard
32-
chmod 0640 /etc/sssd/sssd.conf
33-
{{%- else %}}
34-
chmod 0600 /etc/sssd/sssd.conf
35-
{{%- endif %}}
36-
fi

linux_os/guide/services/sssd/sssd_certificate_verification/ansible/shared.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,31 @@
55
# disruption = medium
66
{{{ ansible_instantiate_variables("var_sssd_certificate_verification_digest_function") }}}
77

8-
- name: Ensure that "certificate_verification" is not set in /etc/sssd/sssd.conf
8+
{{% set sssd_conf = "/etc/sssd/sssd.conf" -%}}
9+
{{% set sssd_conf_dir = "/etc/sssd/conf.d" -%}}
10+
{{{ ansible_sssd_ensure_default_config(sssd_conf, sssd_conf_dir, rule_title) }}}
11+
12+
{{{ ansible_install_sssd_proxy(rule_title) }}}
13+
14+
- name: Ensure that "certificate_verification" is not set in {{{ sssd_conf }}}
915
community.general.ini_file:
10-
path: /etc/sssd/sssd.conf
16+
path: {{{ sssd_conf }}}
1117
section: sssd
1218
option: certificate_verification
1319
state: absent
1420
mode: 0600
1521

16-
- name: 'Ensure that "certificate_verification" is not set in /etc/sssd/conf.d/*.conf'
22+
- name: 'Ensure that "certificate_verification" is not set in {{{ sssd_conf_dir }}}/*.conf'
1723
community.general.ini_file:
18-
path: /etc/sssd/conf.d/*.conf
24+
path: {{{ sssd_conf_dir }}}/*.conf
1925
section: sssd
2026
option: certificate_verification
2127
state: absent
2228
mode: 0600
2329

2430
- name: Ensure that "certificate_verification" is set
2531
community.general.ini_file:
26-
path: /etc/sssd/conf.d/certificate_verification.conf
32+
path: {{{ sssd_conf_dir }}}/certificate_verification.conf
2733
section: sssd
2834
option: certificate_verification
2935
value: "ocsp_dgst={{ var_sssd_certificate_verification_digest_function }}"

linux_os/guide/services/sssd/sssd_certificate_verification/bash/shared.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,13 @@
1111
OLD_UMASK=$(umask)
1212
umask u=rw,go=
1313

14-
MAIN_CONF="/etc/sssd/conf.d/certificate_verification.conf"
14+
SSSD_CONF="/etc/sssd/sssd.conf"
15+
SSSD_CONF_DIR="/etc/sssd/conf.d"
16+
{{{ bash_sssd_ensure_default_config("$SSSD_CONF", "$SSSD_CONF_DIR") }}}
17+
{{{ bash_install_sssd_proxy() }}}
1518

16-
{{{ bash_ensure_ini_config("$MAIN_CONF /etc/sssd/sssd.conf /etc/sssd/conf.d/*.conf", "sssd", "certificate_verification", "ocsp_dgst=$var_sssd_certificate_verification_digest_function") }}}
19+
MAIN_CONF="$SSSD_CONF_DIR/certificate_verification.conf"
20+
21+
{{{ bash_ensure_ini_config("$MAIN_CONF $SSSD_CONF $SSSD_CONF_DIR/*.conf", "sssd", "certificate_verification", "ocsp_dgst=$var_sssd_certificate_verification_digest_function") }}}
1722

1823
umask $OLD_UMASK

linux_os/guide/services/sssd/sssd_enable_pam_services/ansible/shared.yml

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,20 @@
44
# complexity = low
55
# disruption = medium
66

7-
- name: {{{ rule_title }}} - Find all the conf files inside the /etc/sssd/conf.d/ directory
7+
{{% set sssd_conf = "/etc/sssd/sssd.conf" -%}}
8+
{{% set sssd_conf_dir = "/etc/sssd/conf.d" -%}}
9+
{{{ ansible_sssd_ensure_default_config(sssd_conf, sssd_conf_dir, rule_title) }}}
10+
11+
{{{ ansible_install_sssd_proxy(rule_title) }}}
12+
13+
- name: {{{ rule_title }}} - Find all the conf files inside the {{{ sssd_conf_dir }}} directory
814
ansible.builtin.find:
915
paths:
10-
- "/etc/sssd/conf.d/"
16+
- "{{{ sssd_conf_dir }}}"
1117
patterns: "*.conf"
1218
register: sssd_conf_d_files
1319

14-
- name: {{{ rule_title }}} - Modify lines in files in the /etc/sssd/conf.d/ directory
20+
- name: {{{ rule_title }}} - Modify lines in files in the {{{ sssd_conf_dir }}} directory
1521
ansible.builtin.replace:
1622
path: "{{ item }}"
1723
regexp: '^(\s*\[sssd\].*(?:\n\s*[^[\s].*)*\n\s*services\s*=(?!.*\bpam\b).*)$'
@@ -20,32 +26,32 @@
2026
register: modify_lines_sssd_conf_d_files
2127
when: sssd_conf_d_files.matched is defined and sssd_conf_d_files.matched >= 1
2228

23-
- name: {{{ rule_title }}} - Find /etc/sssd/sssd.conf
29+
- name: {{{ rule_title }}} - Find {{{ sssd_conf }}}
2430
ansible.builtin.stat:
25-
path: /etc/sssd/sssd.conf
31+
path: {{{ sssd_conf }}}
2632
register: sssd_conf_file
2733

28-
- name: {{{ rule_title }}} - Modify lines in /etc/sssd/sssd.conf
34+
- name: {{{ rule_title }}} - Modify lines in {{{ sssd_conf }}}
2935
ansible.builtin.replace:
30-
path: "/etc/sssd/sssd.conf"
36+
path: "{{{ sssd_conf }}}"
3137
regexp: '^(\s*\[sssd\].*(?:\n\s*[^[\s].*)*\n\s*services\s*=(?!.*\bpam\b).*)$'
3238
replace: '\1,pam'
3339
register: modify_lines_sssd_conf_file
3440
when: sssd_conf_file.stat.exists
3541

36-
- name: {{{ rule_title }}} - Find services key in /etc/sssd/sssd.conf
42+
- name: {{{ rule_title }}} - Find services key in {{{ sssd_conf }}}
3743
ansible.builtin.replace:
38-
path: "/etc/sssd/sssd.conf"
44+
path: "{{{ sssd_conf }}}"
3945
regexp: '^\s*\[sssd\][^\[\]]*?(?:\n(?!\[)[^\n]*?services\s*=)+'
4046
replace: ''
4147
changed_when: false
4248
check_mode: true
4349
register: sssd_conf_file_services
4450
when: sssd_conf_file.stat.exists
4551

46-
- name: {{{ rule_title }}} - Insert entry to /etc/sssd/sssd.conf
52+
- name: {{{ rule_title }}} - Insert entry to {{{ sssd_conf }}}
4753
community.general.ini_file:
48-
path: /etc/sssd/sssd.conf
54+
path: {{{ sssd_conf }}}
4955
section: sssd
5056
option: services
5157
value: pam
Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
11
# platform = Red Hat Virtualization 4,multi_platform_rhel,multi_platform_ol,multi_platform_almalinux,multi_platform_ubuntu
22

33

4-
54
# sssd configuration files must be created with 600 permissions if they don't exist
65
# otherwise the sssd module fails to start
76
OLD_UMASK=$(umask)
87
umask u=rw,go=
98

109
SSSD_CONF="/etc/sssd/sssd.conf"
11-
SSSD_CONF_DIR="/etc/sssd/conf.d/*.conf"
12-
13-
if [ ! -f "$SSSD_CONF" ] && [ ! -f "$SSSD_CONF_DIR" ]; then
14-
mkdir -p /etc/sssd
15-
touch "$SSSD_CONF"
16-
fi
10+
SSSD_CONF_DIR="/etc/sssd/conf.d"
11+
{{{ bash_sssd_ensure_default_config("$SSSD_CONF", "$SSSD_CONF_DIR") }}}
12+
{{{ bash_install_sssd_proxy() }}}
1713

1814
# Flag to check if there is already services with pam
1915
service_already_exist=false
20-
for f in $SSSD_CONF $SSSD_CONF_DIR; do
16+
for f in $SSSD_CONF $SSSD_CONF_DIR/*.conf; do
2117
if [ ! -e "$f" ]; then
2218
continue
2319
fi
@@ -39,13 +35,7 @@ done
3935

4036
# If there was no service in [sssd], add it to first config
4137
if [ "$service_already_exist" = false ]; then
42-
for f in $SSSD_CONF $SSSD_CONF_DIR; do
43-
cat << EOF >> "$f"
44-
[sssd]
45-
services = pam
46-
EOF
47-
break
48-
done
38+
{{{ bash_ensure_ini_config("$SSSD_CONF $SSSD_CONF_DIR/*.conf", "sssd", "services", "pam") }}}
4939
fi
5040

5141
umask $OLD_UMASK

linux_os/guide/services/sssd/sssd_enable_smartcards/ansible/shared.yml

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,28 @@
33
# strategy = configure
44
# complexity = low
55
# disruption = medium
6-
- name: "Test for domain group"
7-
ansible.builtin.command: grep '^\s*\[domain\/[^]]*]' /etc/sssd/sssd.conf
8-
register: test_grep_domain
9-
failed_when: false
10-
changed_when: False
11-
check_mode: no
6+
{{% set sssd_conf = "/etc/sssd/sssd.conf" -%}}
7+
{{% set sssd_conf_dir = "/etc/sssd/conf.d" -%}}
8+
{{{ ansible_sssd_ensure_default_config(sssd_conf, sssd_conf_dir, rule_title) }}}
129

13-
- name: "Add default domain group (if no domain there)"
14-
community.general.ini_file:
15-
path: /etc/sssd/sssd.conf
16-
section: "{{ item.section }}"
17-
option: "{{ item.option }}"
18-
value: "{{ item.value }}"
19-
create: yes
20-
mode: 0600
21-
with_items:
22-
- { section: sssd, option: domains, value: default}
23-
- { section: domain/default, option: id_provider, value: files }
24-
when:
25-
- test_grep_domain.stdout is defined
26-
- test_grep_domain.stdout | length < 1
10+
{{{ ansible_install_sssd_proxy(rule_title) }}}
2711

2812
- name: "Enable Smartcards in SSSD"
2913
community.general.ini_file:
30-
dest: /etc/sssd/sssd.conf
14+
path: {{{ sssd_conf }}}
3115
section: pam
3216
option: pam_cert_auth
3317
value: 'True'
3418
create: yes
3519
mode: 0600
3620

37-
- name: Find all the conf files inside /etc/sssd/conf.d/
21+
- name: Find all the conf files inside {{{ sssd_conf_dir }}}
3822
ansible.builtin.find:
39-
paths: "/etc/sssd/conf.d/"
23+
paths: "{{{ sssd_conf_dir }}}"
4024
patterns: "*.conf"
4125
register: sssd_conf_d_files
4226

43-
- name: Fix pam_cert_auth configuration in /etc/sssd/conf.d/
27+
- name: Fix pam_cert_auth configuration in {{{ sssd_conf_dir }}}
4428
ansible.builtin.replace:
4529
path: "{{ item.path }}"
4630
regexp: '[^#]*pam_cert_auth.*'

linux_os/guide/services/sssd/sssd_enable_smartcards/bash/shared.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@
99
OLD_UMASK=$(umask)
1010
umask u=rw,go=
1111

12-
{{{ bash_ensure_ini_config("/etc/sssd/sssd.conf /etc/sssd/conf.d/*.conf", "pam", "pam_cert_auth", "True") }}}
12+
SSSD_CONF="/etc/sssd/sssd.conf"
13+
SSSD_CONF_DIR="/etc/sssd/conf.d"
14+
{{{ bash_sssd_ensure_default_config("$SSSD_CONF", "$SSSD_CONF_DIR") }}}
15+
{{{ bash_install_sssd_proxy() }}}
16+
17+
{{{ bash_ensure_ini_config("$SSSD_CONF $SSSD_CONF_DIR/*.conf", "pam", "pam_cert_auth", "True") }}}
1318

1419
umask $OLD_UMASK
1520

linux_os/guide/services/sssd/sssd_enable_smartcards/tests/sssd_parameter_false.fail.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
# packages = sssd
33
# platform = multi_platform_fedora,Oracle Linux 7,Red Hat Virtualization 4,multi_platform_ubuntu
44

5-
SSSD_FILE="/etc/sssd/sssd.conf"
6-
echo "[pam]" > $SSSD_FILE
7-
echo "pam_cert_auth = False" >> $SSSD_FILE
5+
{{% if product in ["fedora", "ol8", "ol9"] or 'rhel' in product %}}
6+
authselect select sssd --force
7+
{{% endif %}}
8+
9+
SSSD_CONF="/etc/sssd/sssd.conf"
10+
SSSD_CONF_DIR="/etc/sssd/conf.d"
11+
{{{ bash_ensure_ini_config("$SSSD_CONF $SSSD_CONF_DIR/*.conf", "pam", "pam_cert_auth", "False") }}}

linux_os/guide/services/sssd/sssd_enable_smartcards/tests/sssd_parameter_missing.fail.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,9 @@
22
# packages = sssd
33
# platform = multi_platform_fedora,Oracle Linux 7,Red Hat Virtualization 4,multi_platform_ubuntu
44

5+
{{% if product in ["fedora", "ol8", "ol9"] or 'rhel' in product %}}
6+
authselect select sssd --force
7+
{{% endif %}}
8+
59
SSSD_FILE="/etc/sssd/sssd.conf"
610
echo "[pam]" > $SSSD_FILE

linux_os/guide/services/sssd/sssd_enable_smartcards/tests/sssd_parameter_missing_file.fail.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,9 @@
22
# packages = sssd
33
# platform = multi_platform_fedora,Oracle Linux 7,Red Hat Virtualization 4,multi_platform_ubuntu
44

5+
{{% if product in ["fedora", "ol8", "ol9"] or 'rhel' in product %}}
6+
authselect select sssd --force
7+
{{% endif %}}
8+
59
SSSD_FILE="/etc/sssd/sssd.conf"
610
rm -f $SSSD_FILE

0 commit comments

Comments
 (0)