/src/sudo/lib/iolog/iolog_json.c
Line | Count | Source |
1 | | /* |
2 | | * SPDX-License-Identifier: ISC |
3 | | * |
4 | | * Copyright (c) 2020-2023 Todd C. Miller <Todd.Miller@sudo.ws> |
5 | | * |
6 | | * Permission to use, copy, modify, and distribute this software for any |
7 | | * purpose with or without fee is hereby granted, provided that the above |
8 | | * copyright notice and this permission notice appear in all copies. |
9 | | * |
10 | | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
11 | | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
12 | | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
13 | | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
14 | | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
15 | | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
16 | | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
17 | | */ |
18 | | |
19 | | #include <config.h> |
20 | | |
21 | | #include <stdio.h> |
22 | | #include <stdlib.h> |
23 | | #ifdef HAVE_STDBOOL_H |
24 | | # include <stdbool.h> |
25 | | #else |
26 | | # include <compat/stdbool.h> |
27 | | #endif /* HAVE_STDBOOL_H */ |
28 | | |
29 | | #include <sudo_compat.h> |
30 | | #include <sudo_debug.h> |
31 | | #include <sudo_eventlog.h> |
32 | | #include <sudo_iolog.h> |
33 | | |
34 | | bool |
35 | | iolog_parse_loginfo_json(FILE *fp, const char *iolog_dir, struct eventlog *evlog) |
36 | 3.20k | { |
37 | 3.20k | struct eventlog_json_object *root; |
38 | 3.20k | bool ret = false; |
39 | 3.20k | debug_decl(iolog_parse_loginfo_json, SUDO_DEBUG_UTIL); |
40 | | |
41 | 3.20k | root = eventlog_json_read(fp, iolog_dir); |
42 | 3.20k | if (root != NULL) { |
43 | | /* Parse the JSON into an eventlog. */ |
44 | 1.88k | ret = eventlog_json_parse(root, evlog); |
45 | | |
46 | | /* Cleanup. */ |
47 | 1.88k | eventlog_json_free(root); |
48 | 1.88k | } |
49 | | |
50 | | debug_return_bool(ret); |
51 | 3.20k | } |