s4/selftest: enable samba.tests.dcerpc.raw_protocol for py3
[samba.git] / lib / audit_logging / audit_logging.h
1 /*
2    common routines for audit logging
3
4    Copyright (C) Andrew Bartlett <abartlet@samba.org> 2018
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 3 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 */
19 #ifndef _AUDIT_LOGGING_H_
20 #define _AUDIT_LOGGING_H_
21 #include <talloc.h>
22 #include "lib/messaging/irpc.h"
23 #include "lib/tsocket/tsocket.h"
24 #include "lib/util/attr.h"
25
26 _WARN_UNUSED_RESULT_ char *audit_get_timestamp(TALLOC_CTX *frame);
27 void audit_log_human_text(const char *prefix,
28                           const char *message,
29                           int debug_class,
30                           int debug_level);
31
32 #ifdef HAVE_JANSSON
33 #include <jansson.h>
34 /*
35  * Wrapper for jannson JSON object
36  *
37  */
38 struct json_object {
39         json_t *root;
40         bool valid;
41 };
42 extern const struct json_object json_empty_object;
43
44 #define JSON_ERROR -1
45
46 void audit_log_json(const char *prefix,
47                     struct json_object *message,
48                     int debug_class,
49                     int debug_level);
50 void audit_message_send(struct imessaging_context *msg_ctx,
51                         const char *server_name,
52                         uint32_t message_type,
53                         struct json_object *message);
54 _WARN_UNUSED_RESULT_ struct json_object json_new_object(void);
55 _WARN_UNUSED_RESULT_ struct json_object json_new_array(void);
56 void json_free(struct json_object *object);
57 void json_assert_is_array(struct json_object *array);
58 _WARN_UNUSED_RESULT_ bool json_is_invalid(struct json_object *object);
59
60 _WARN_UNUSED_RESULT_ int json_add_int(struct json_object *object,
61                                       const char *name,
62                                       const int value);
63 _WARN_UNUSED_RESULT_ int json_add_bool(struct json_object *object,
64                                        const char *name,
65                                        const bool value);
66 _WARN_UNUSED_RESULT_ int json_add_string(struct json_object *object,
67                                          const char *name,
68                                          const char *value);
69 _WARN_UNUSED_RESULT_ int json_add_object(struct json_object *object,
70                                          const char *name,
71                                          struct json_object *value);
72 _WARN_UNUSED_RESULT_ int json_add_stringn(struct json_object *object,
73                                           const char *name,
74                                           const char *value,
75                                           const size_t len);
76 _WARN_UNUSED_RESULT_ int json_add_version(struct json_object *object,
77                                           int major,
78                                           int minor);
79 _WARN_UNUSED_RESULT_ int json_add_timestamp(struct json_object *object);
80 _WARN_UNUSED_RESULT_ int json_add_address(
81     struct json_object *object,
82     const char *name,
83     const struct tsocket_address *address);
84 _WARN_UNUSED_RESULT_ int json_add_sid(struct json_object *object,
85                                       const char *name,
86                                       const struct dom_sid *sid);
87 _WARN_UNUSED_RESULT_ int json_add_guid(struct json_object *object,
88                                        const char *name,
89                                        const struct GUID *guid);
90
91 _WARN_UNUSED_RESULT_ struct json_object json_get_array(
92     struct json_object *object, const char *name);
93 _WARN_UNUSED_RESULT_ struct json_object json_get_object(
94     struct json_object *object, const char *name);
95 _WARN_UNUSED_RESULT_ char *json_to_string(TALLOC_CTX *mem_ctx,
96                                           struct json_object *object);
97 #endif
98 #endif