1 /*
2 * Tests for trace logging in the pam-krb5 module.
3 *
4 * Checks that trace logging is handled properly. This is currently very
5 * simple and just checks that the file is created.
6 *
7 * Written by Russ Allbery <eagle@eyrie.org>
8 * Copyright 2020 Russ Allbery <eagle@eyrie.org>
9 * Copyright 2012
10 * The Board of Trustees of the Leland Stanford Junior University
11 *
12 * SPDX-License-Identifier: BSD-3-clause or GPL-1+
13 */
14
15 #include <config.h>
16 #include <portable/system.h>
17
18 #include <tests/fakepam/script.h>
19 #include <tests/tap/basic.h>
20 #include <tests/tap/string.h>
21
22
23 int
main(void)24 main(void)
25 {
26 struct script_config config;
27 char *tmpdir, *trace;
28
29 plan_lazy();
30
31 memset(&config, 0, sizeof(config));
32 config.user = "testuser";
33 tmpdir = test_tmpdir();
34 basprintf(&trace, "%s/trace", tmpdir);
35 config.extra[0] = trace;
36 #ifdef HAVE_KRB5_SET_TRACE_FILENAME
37 run_script("data/scripts/trace/supported", &config);
38 is_int(0, access(trace, F_OK), "Trace file was created");
39 unlink(trace);
40 #else
41 run_script("data/scripts/trace/unsupported", &config);
42 is_int(-1, access(trace, F_OK), "Trace file does not exist");
43 #endif
44
45 free(trace);
46 test_tmpdir_free(tmpdir);
47 return 0;
48 }
49