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