Skip to content

Commit dedc5a7

Browse files
Implement bash_pam_pwhistory_enable macro
1 parent ec4dae3 commit dedc5a7

File tree

2 files changed

+18
-20
lines changed
  • linux_os/guide/system/accounts/accounts-pam/locking_out_password_attempts/accounts_password_pam_pwhistory_enabled/bash
  • shared/macros

2 files changed

+18
-20
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,3 @@
11
# platform = multi_platform_ubuntu
22

3-
conf_name=cac_pwhistory
4-
conf_path="/usr/share/pam-configs"
5-
6-
if [ ! -f "$conf_path"/"$conf_name" ]; then
7-
if [ -f "$conf_path"/pwhistory ]; then
8-
cp "$conf_path"/pwhistory "$conf_path"/"$conf_name"
9-
sed -i '/Default: yes/a Priority: 1025\
10-
Conflicts: pwhistory' "$conf_path"/"$conf_name"
11-
else
12-
cat << EOF > "$conf_path"/"$conf_name"
13-
Name: pwhistory password history checking
14-
Default: yes
15-
Priority: 1024
16-
Password-Type: Primary
17-
Password: requisite pam_pwhistory.so remember=24 enforce_for_root try_first_pass use_authtok
18-
EOF
19-
fi
20-
fi
21-
22-
DEBIAN_FRONTEND=noninteractive pam-auth-update
3+
{{{ bash_pam_pwhistory_enable() }}}

shared/macros/10-bash.jinja

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,24 @@ if [ -f /usr/bin/authselect ]; then
982982
{{{ bash_ensure_pam_module_line("$PAM_FILE_PATH", 'password', control, 'pam_pwhistory.so', after_match) | indent(8) }}}
983983
fi
984984
else
985+
{{% if 'ubuntu' in product %}}
986+
conf_name=cac_pwhistory
987+
conf_path="/usr/share/pam-configs"
988+
989+
if [ ! -f "$conf_path"/"$conf_name" ]; then
990+
cat << EOF > "$conf_path"/"$conf_name"
991+
Name: pwhistory password history checking
992+
Default: yes
993+
Priority: 1024
994+
Password-Type: Primary
995+
Password: requisite pam_pwhistory.so remember=24 enforce_for_root try_first_pass use_authtok
996+
EOF
997+
fi
998+
999+
DEBIAN_FRONTEND=noninteractive pam-auth-update
1000+
{{% else %}}
9851001
{{{ bash_ensure_pam_module_line(pam_file, 'password', control, 'pam_pwhistory.so', after_match) | indent(4) }}}
1002+
{{% endif %}}
9861003
fi
9871004
{{%- endmacro -%}}
9881005

0 commit comments

Comments
 (0)