Skip to content

Commit

Permalink
Align the pam_account_password_faillock template tests with oval chec…
Browse files Browse the repository at this point in the history
…k logic
  • Loading branch information
alanmcanonical committed Dec 2, 2024
1 parent a1003e9 commit 83e684f
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,17 @@ rm -f /usr/share/pam-configs/cac_faillock*

DEBIAN_FRONTEND=noninteractive pam-auth-update

echo "#{{{ PRM_NAME }}}={{{ VARIABLE_LOWER_BOUND }}}" > /etc/security/faillock.conf
SIGN='='
{{% if EXT_VARIABLE %}}
VALUE=1
{{% else %}}
if [[ {{{ VARIABLE_UPPER_BOUND }}} =~ ^[0-9]+$ ]]; then
VALUE=$(( {{{ VARIABLE_UPPER_BOUND }}} - 1 ))
elif [[ {{{ VARIABLE_LOWER_BOUND }}} =~ ^[0-9]+$ ]]; then
VALUE=$(( {{{ VARIABLE_LOWER_BOUND }}} + 1 ))
else
SIGN=""
fi
{{% endif %}}

echo "#{{{ PRM_NAME }}}$SIGN$VALUE" > /etc/security/faillock.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
#!/bin/bash
# platform = multi_platform_ubuntu

SIGN='='
{{% if EXT_VARIABLE %}}
VALUE=1
{{% else %}}
if [[ {{{ VARIABLE_UPPER_BOUND }}} =~ ^[0-9]+$ ]]; then
VALUE=$(( {{{ VARIABLE_UPPER_BOUND }}} - 1 ))
elif [[ {{{ VARIABLE_LOWER_BOUND }}} =~ ^[0-9]+$ ]]; then
VALUE=$(( {{{ VARIABLE_LOWER_BOUND }}} + 1 ))
else
SIGN=""
fi
{{% endif %}}

{{{ bash_enable_pam_faillock_directly_in_pam_files() }}}
echo "{{{ PRM_NAME }}}={{{ VARIABLE_LOWER_BOUND }}}" > /etc/security/faillock.conf
echo "{{{ PRM_NAME }}}$SIGN$VALUE" > /etc/security/faillock.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,27 @@
rm -f /usr/share/pam-configs/cac_faillock*
DEBIAN_FRONTEND=noninteractive pam-auth-update

SIGN='='
{{% if EXT_VARIABLE %}}
VALUE=1
{{% else %}}
if [[ {{{ VARIABLE_UPPER_BOUND }}} =~ ^[0-9]+$ ]]; then
VALUE=$(( {{{ VARIABLE_UPPER_BOUND }}} - 1 ))
elif [[ {{{ VARIABLE_LOWER_BOUND }}} =~ ^[0-9]+$ ]]; then
VALUE=$(( {{{ VARIABLE_LOWER_BOUND }}} + 1 ))
else
SIGN=""
fi
{{% endif %}}

cat << EOF > /usr/share/pam-configs/cac_faillock
Name: Enable pam_faillock to deny access
Default: yes
Conflicts: faillock
Priority: 0
Auth-Type: Primary
Auth:
[default=die] pam_faillock.so authfail {{{ PRM_NAME }}}={{{ VARIABLE_LOWER_BOUND }}}
[default=die] pam_faillock.so authfail {{{ PRM_NAME }}}$SIGN$VALUE
EOF

cat << EOF > /usr/share/pam-configs/cac_faillock_notify
Expand All @@ -21,7 +34,7 @@ Conflicts: faillock_notify
Priority: 1025
Auth-Type: Primary
Auth:
requisite pam_faillock.so preauth {{{ PRM_NAME }}}={{{ VARIABLE_LOWER_BOUND }}}
requisite pam_faillock.so preauth {{{ PRM_NAME }}}$SIGN$VALUE
Account-Type: Primary
Account:
required pam_faillock.so
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,17 @@ rm -f /usr/share/pam-configs/cac_faillock*

DEBIAN_FRONTEND=noninteractive pam-auth-update

echo "{{{ PRM_NAME }}}={{{ VARIABLE_LOWER_BOUND }}}" > /etc/security/faillock.conf
SIGN='='
{{% if EXT_VARIABLE %}}
VALUE=1
{{% else %}}
if [[ {{{ VARIABLE_UPPER_BOUND }}} =~ ^[0-9]+$ ]]; then
VALUE=$(( {{{ VARIABLE_UPPER_BOUND }}} - 1 ))
elif [[ {{{ VARIABLE_LOWER_BOUND }}} =~ ^[0-9]+$ ]]; then
VALUE=$(( {{{ VARIABLE_LOWER_BOUND }}} + 1 ))
else
SIGN=""
fi
{{% endif %}}

echo "{{{ PRM_NAME }}}$SIGN$VALUE" > /etc/security/faillock.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
#!/bin/bash
# platform = multi_platform_ubuntu

SIGN='='
{{% if EXT_VARIABLE %}}
VALUE=1
if [[ {{{ VARIABLE_UPPER_BOUND }}} == "use_ext_variable" ]]; then
VALUE=$(( $VALUE + 1 ))
elif [[ {{{ VARIABLE_LOWER_BOUND }}} == "use_ext_variable" ]]; then
VALUE=$(( $VALUE - 1 ))
fi
{{% else %}}
if [[ {{{ VARIABLE_UPPER_BOUND }}} =~ ^[0-9]+$ ]]; then
VALUE=$(( {{{ VARIABLE_UPPER_BOUND }}} + 1 ))
elif [[ {{{ VARIABLE_LOWER_BOUND }}} =~ ^[0-9]+$ ]]; then
VALUE=$(( {{{ VARIABLE_LOWER_BOUND }}} - 1 ))
else
SIGN=""
fi
{{% endif %}}

{{{ bash_enable_pam_faillock_directly_in_pam_files() }}}
echo "{{{ PRM_NAME }}}={{{ VARIABLE_UPPER_BOUND }}}" > /etc/security/faillock.conf

0 comments on commit 83e684f

Please sign in to comment.