/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 | | /* |
20 | | * This is an open source non-commercial project. Dear PVS-Studio, please check it. |
21 | | * PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com |
22 | | */ |
23 | | |
24 | | #include <config.h> |
25 | | |
26 | | #include <stdio.h> |
27 | | #include <stdlib.h> |
28 | | #ifdef HAVE_STDBOOL_H |
29 | | # include <stdbool.h> |
30 | | #else |
31 | | # include "compat/stdbool.h" |
32 | | #endif /* HAVE_STDBOOL_H */ |
33 | | |
34 | | #include "sudo_compat.h" |
35 | | #include "sudo_debug.h" |
36 | | #include "sudo_eventlog.h" |
37 | | #include "sudo_iolog.h" |
38 | | |
39 | | bool |
40 | | iolog_parse_loginfo_json(FILE *fp, const char *iolog_dir, struct eventlog *evlog) |
41 | 2.83k | { |
42 | 2.83k | struct eventlog_json_object *root; |
43 | 2.83k | bool ret = false; |
44 | 2.83k | debug_decl(iolog_parse_loginfo_json, SUDO_DEBUG_UTIL); |
45 | | |
46 | 2.83k | root = eventlog_json_read(fp, iolog_dir); |
47 | 2.83k | if (root != NULL) { |
48 | | /* Parse the JSON into an eventlog. */ |
49 | 1.50k | ret = eventlog_json_parse(root, evlog); |
50 | | |
51 | | /* Cleanup. */ |
52 | 1.50k | eventlog_json_free(root); |
53 | 1.50k | } |
54 | | |
55 | 2.83k | debug_return_bool(ret); |
56 | 2.83k | } |