Skip to content

Commit d4e0641

Browse files
committed
Fix ubuntu remediation and add tests for no_empty_passwords
Original remediation removed the `nullok` keyword and everything after it.
1 parent c6a7007 commit d4e0641

3 files changed

Lines changed: 15 additions & 3 deletions

File tree

linux_os/guide/system/accounts/accounts-restrictions/password_storage/no_empty_passwords/bash/shared.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ for FILE in ${NULLOK_FILES}; do
1212
done
1313
{{% elif 'ubuntu' in product %}}
1414
COMMON_PASSWORD_PATH="/etc/pam.d/common-password"
15-
if grep -l "nullok.*" ${COMMON_PASSWORD_PATH}; then
16-
sed -i 's/nullok.*//g' ${COMMON_PASSWORD_PATH}
15+
if grep -q "nullok" ${COMMON_PASSWORD_PATH}; then
16+
sed -i 's/\s*nullok//g' ${COMMON_PASSWORD_PATH}
1717
fi
1818
{{% else %}}
1919
if [ -f /usr/bin/authselect ]; then
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/bin/bash
2-
# platform = Oracle Linux 7,Red Hat Enterprise Linux 7,Red Hat Virtualization 4,multi_platform_fedora
2+
# platform = Oracle Linux 7,Red Hat Enterprise Linux 7,Red Hat Virtualization 4,multi_platform_fedora,multi_platform_ubuntu
33

4+
{{% if 'ubuntu' in product %}}
5+
sed -i --follow-symlinks '/nullok/d' /etc/pam.d/common-password
6+
{{% else %}}
47
sed -i --follow-symlinks '/nullok/d' /etc/pam.d/system-auth
58
sed -i --follow-symlinks '/nullok/d' /etc/pam.d/password-auth
9+
{{% endif %}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
# platform = multi_platform_ubuntu
3+
4+
COMMON_PASSWORD_FILE="/etc/pam.d/common-password"
5+
6+
if ! $(grep -q "^[^#].*pam_unix\.so.*nullok" $COMMON_PASSWORD_FILE); then
7+
sed -i --follow-symlinks 's/\([\s].*pam_unix\.so.*\)\s\(sha512.*\)/\1nullok \2/' $COMMON_PASSWORD_FILE
8+
fi

0 commit comments

Comments
 (0)