Skip to content

Commit 9105286

Browse files
committed
replace echo config writing with macro
1 parent 5d1911d commit 9105286

22 files changed

Lines changed: 41 additions & 87 deletions
Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,19 @@
1+
#!/bin/bash
2+
# packages = sssd
3+
14
# 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
5+
SSSD_CONF="/etc/sssd/sssd.conf"
6+
SSSD_CONF_DIR="/etc/sssd/conf.d"
7+
{{{ bash_sssd_ensure_default_config("$SSSD_CONF", "$SSSD_CONF_DIR") }}}
88

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
9+
{{%- if ('rhel' in product or 'ol' in families) and product not in ['ol7', 'ol8', 'ol9', 'rhel8', 'rhel9']%}}
10+
{{{ bash_ensure_ini_config("$SSSD_CONF $SSSD_CONF_DIR/*.conf", "pam", "pam_cert_auth", "True") }}}
1811
{{%- endif %}}
1912

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
13+
{{%- if product in ["fedora"] or (('rhel' in product or 'ol' in families) and product not in ['ol7', 'ol8', 'ol9', 'rhel8', 'rhel9']) %}}
14+
{{{ bash_package_install("sssd-proxy") }}}
15+
authselect select sssd with-smartcard
16+
chmod 0640 $SSSD_CONF
17+
{{%- else %}}
18+
chmod 0600 $SSSD_CONF
2719
{{%- 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
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#!/bin/bash
22
# packages = sssd-common
33

4-
mkdir -p /etc/sssd/conf.d
5-
touch /etc/sssd/sssd.conf
6-
echo -e "[sssd]\ncertificate_verification = ocsp_dgst=sha1" >> /etc/sssd/sssd.conf
4+
{{{ bash_ensure_ini_config("/etc/sssd/sssd.conf", "sssd", "certificate_verification", "ocsp_dgst=sha1") }}}
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#!/bin/bash
22
# packages = sssd-common
33

4-
mkdir -p /etc/sssd/conf.d
5-
touch /etc/sssd/sssd.conf
6-
echo -e "[sssd]\ncertificate_verification = ocsp_dgst=sha256" >> /etc/sssd/sssd.conf
4+
{{{ bash_ensure_ini_config("/etc/sssd/sssd.conf", "sssd", "certificate_verification", "ocsp_dgst=sha256") }}}

linux_os/guide/services/sssd/sssd_certificate_verification/tests/wrong_value_not_default.fail.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,5 @@
22
# packages = sssd-common
33
# variables = var_sssd_certificate_verification_digest_function=sha512
44

5-
mkdir -p /etc/sssd/conf.d
6-
touch /etc/sssd/sssd.conf
7-
echo -e "[sssd]\ncertificate_verification = ocsp_dgst=sha256" >> /etc/sssd/sssd.conf
5+
{{{ bash_ensure_ini_config("/etc/sssd/sssd.conf", "sssd", "certificate_verification", "ocsp_dgst=sha256") }}}
86

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
# remediation = none
55

66
SSSD_FILE="/etc/sssd/sssd.conf"
7-
echo "[pam]" > $SSSD_FILE
8-
echo "pam_cert_auth = True" >> $SSSD_FILE
7+
{{{ bash_ensure_ini_config("$SSSD_FILE", "pam", "pam_cert_auth", "True") }}}
98

109
authselect select sssd --force
1110

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
# platform = multi_platform_fedora,Oracle Linux 8,Oracle Linux 9,multi_platform_rhel
44

55
SSSD_FILE="/etc/sssd/sssd.conf"
6-
echo "[pam]" > $SSSD_FILE
7-
echo "pam_cert_auth = True" >> $SSSD_FILE
6+
{{{ bash_ensure_ini_config("$SSSD_FILE", "pam", "pam_cert_auth", "True") }}}
87

98
authselect select sssd --force
109
authselect disable-feature with-smartcard

linux_os/guide/services/sssd/sssd_enable_smartcards/tests/authselect_smartcard_enabled.pass.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
# platform = multi_platform_fedora,Oracle Linux 8,Oracle Linux 9,multi_platform_rhel
44

55
SSSD_FILE="/etc/sssd/sssd.conf"
6-
echo "[pam]" > $SSSD_FILE
7-
echo "pam_cert_auth = True" >> $SSSD_FILE
6+
{{{ bash_ensure_ini_config("$SSSD_FILE", "pam", "pam_cert_auth", "True") }}}
87

98
authselect select sssd --force
109
authselect enable-feature with-smartcard

linux_os/guide/services/sssd/sssd_enable_smartcards/tests/authselect_smartcard_enabled_conf_d.pass.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
# platform = multi_platform_fedora,Oracle Linux 8,Oracle Linux 9,multi_platform_rhel
44

55
SSSD_FILE="/etc/sssd/conf.d/unused.conf"
6-
echo "[pam]" > $SSSD_FILE
7-
echo "pam_cert_auth = True" >> $SSSD_FILE
6+
{{{ bash_ensure_ini_config("$SSSD_FILE", "pam", "pam_cert_auth", "True") }}}
87

98
authselect select sssd --force
109
authselect enable-feature with-smartcard

linux_os/guide/services/sssd/sssd_enable_smartcards/tests/authselect_smartcard_enabled_lower.pass.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
# platform = multi_platform_fedora,Oracle Linux 8,Oracle Linux 9,multi_platform_rhel
44

55
SSSD_FILE="/etc/sssd/sssd.conf"
6-
echo "[pam]" > $SSSD_FILE
7-
echo "pam_cert_auth = true" >> $SSSD_FILE
6+
{{{ bash_ensure_ini_config("$SSSD_FILE", "pam", "pam_cert_auth", "true") }}}
87

98
authselect select sssd --force
109
authselect enable-feature with-smartcard

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
# platform = multi_platform_fedora,Oracle Linux 8,Oracle Linux 9,multi_platform_rhel
44

55
SSSD_FILE="/etc/sssd/sssd.conf"
6-
echo "[pam]" > $SSSD_FILE
7-
echo "pam_cert_auth = False" >> $SSSD_FILE
6+
{{{ bash_ensure_ini_config("$SSSD_FILE", "pam", "pam_cert_auth", "False") }}}
87

98
authselect select sssd --force
109
authselect enable-feature with-smartcard

0 commit comments

Comments
 (0)