xref: /freebsd/contrib/pam-krb5/tests/module/long-t.c (revision bf6873c5786e333d679a7838d28812febf479a8a)
1 /*
2  * Excessively long password tests for the pam-krb5 module.
3  *
4  * This test case includes all tests for excessively long passwords that can
5  * be done without having Kerberos configured and a username and password
6  * available.
7  *
8  * Copyright 2020 Russ Allbery <eagle@eyrie.org>
9  *
10  * SPDX-License-Identifier: BSD-3-clause or GPL-1+
11  */
12 
13 #include <config.h>
14 #include <portable/system.h>
15 
16 #include <tests/fakepam/script.h>
17 #include <tests/tap/basic.h>
18 
19 
20 int
main(void)21 main(void)
22 {
23     struct script_config config;
24     char *password;
25 
26     plan_lazy();
27 
28     memset(&config, 0, sizeof(config));
29     config.user = "test";
30 
31     /* Test a password that is too long. */
32     password = bcalloc_type(PAM_MAX_RESP_SIZE + 1, char);
33     memset(password, 'a', PAM_MAX_RESP_SIZE);
34     config.password = password;
35     run_script("data/scripts/long/password", &config);
36     run_script("data/scripts/long/password-debug", &config);
37 
38     /* Test a stored authtok that's too long. */
39     config.authtok = password;
40     config.password = "testing";
41     run_script("data/scripts/long/use-first", &config);
42     run_script("data/scripts/long/use-first-debug", &config);
43 
44     free(password);
45     return 0;
46 }
47