Skip to content

Commit

Permalink
libpamtest: Test failed login & pam_faillock
Browse files Browse the repository at this point in the history
  • Loading branch information
pyllyukko committed Jan 14, 2025
1 parent 867c1ea commit 07a1806
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/pam.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ jobs:
# Anyone can use su
echo '[*] Test 11'
tests/test -t 7 -r 0
echo '[*] Test 12'
# Wrong password
tests/test -t 8 -r 2
- name: Harden PAM
run: |
ansible-playbook harden.yml --tags pam --skip-tags slackware
Expand All @@ -97,6 +100,10 @@ jobs:
sudo tests/test -t 6 -r 2
# Use of su should be denied
tests/test -t 7 -r 2
# Test failed login & pam_faillock
sudo tests/test -t 8 -r 2
ls -l /var/run/faillock/nobody
sudo faillock --user nobody
- name: chmod /var/log/auth.log
run: sudo chmod -c 644 /var/log/auth.log
- name: Archive auth.log
Expand Down
23 changes: 23 additions & 0 deletions tests/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,26 @@ static void test_pam_authenticate(void **state)
perr = run_pamtest("login", "root", &conv_data, tests, NULL);
assert_int_equal(perr, testcase);
}
static void test_pam_authenticate_wrong_password(void **state)
{
enum pamtest_err perr;
struct pamtest_conv_data conv_data;
const char *trinity_authtoks[] = {
"wrong_password",
NULL,
};
struct pam_testcase tests[] = {
pam_test(PAMTEST_AUTHENTICATE, PAM_AUTH_ERR),
};

(void) state; /* unused */

ZERO_STRUCT(conv_data);
conv_data.in_echo_off = trinity_authtoks;

perr = run_pamtest("login", "nobody", &conv_data, tests, NULL);
assert_int_equal(perr, testcase);
}
static void test_pam_authenticate_nobody(void **state)
{
enum pamtest_err perr;
Expand Down Expand Up @@ -200,6 +220,9 @@ int main(int argc, char *argv[]) {
case 7:
ptr = test_pam_authenticate_nobody_su;
break;
case 8:
ptr = test_pam_authenticate_wrong_password;
break;
default:
printf("invalid test case\n");
exit (1);
Expand Down

0 comments on commit 07a1806

Please sign in to comment.