2018-04-09 21:45:47 +03:00
/*
common routines for audit logging
Copyright ( C ) Andrew Bartlett < abartlet @ samba . org > 2018
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation ; either version 3 of the License , or
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program . If not , see < http : //www.gnu.org/licenses/>.
*/
2018-07-13 00:14:09 +03:00
# ifndef _AUDIT_LOGGING_H_
# define _AUDIT_LOGGING_H_
2018-04-09 21:45:47 +03:00
# include <talloc.h>
# include "lib/messaging/irpc.h"
# include "lib/tsocket/tsocket.h"
2018-07-24 06:20:21 +03:00
# include "lib/util/attr.h"
2018-04-09 21:45:47 +03:00
2018-07-24 06:20:21 +03:00
_WARN_UNUSED_RESULT_ char * audit_get_timestamp ( TALLOC_CTX * frame ) ;
2018-05-16 23:03:00 +03:00
void audit_log_human_text ( const char * prefix ,
const char * message ,
int debug_class ,
int debug_level ) ;
2018-04-09 21:45:47 +03:00
# ifdef HAVE_JANSSON
# include <jansson.h>
/*
* Wrapper for jannson JSON object
*
*/
struct json_object {
json_t * root ;
2018-07-13 00:14:09 +03:00
bool valid ;
2018-04-09 21:45:47 +03:00
} ;
2018-07-13 00:14:09 +03:00
extern const struct json_object json_empty_object ;
# define JSON_ERROR -1
2018-04-09 21:45:47 +03:00
2018-12-13 03:53:08 +03:00
void audit_log_json ( struct json_object * message ,
2018-05-16 23:03:00 +03:00
int debug_class ,
int debug_level ) ;
void audit_message_send ( struct imessaging_context * msg_ctx ,
const char * server_name ,
uint32_t message_type ,
struct json_object * message ) ;
2018-07-24 06:20:21 +03:00
_WARN_UNUSED_RESULT_ struct json_object json_new_object ( void ) ;
_WARN_UNUSED_RESULT_ struct json_object json_new_array ( void ) ;
2018-04-09 21:45:47 +03:00
void json_free ( struct json_object * object ) ;
void json_assert_is_array ( struct json_object * array ) ;
2018-07-09 10:41:37 +03:00
_WARN_UNUSED_RESULT_ bool json_is_invalid ( const struct json_object * object ) ;
2018-04-09 21:45:47 +03:00
2018-07-24 06:20:21 +03:00
_WARN_UNUSED_RESULT_ int json_add_int ( struct json_object * object ,
const char * name ,
2023-03-09 06:11:28 +03:00
const json_int_t value ) ;
2018-07-24 06:20:21 +03:00
_WARN_UNUSED_RESULT_ int json_add_bool ( struct json_object * object ,
const char * name ,
const bool value ) ;
2023-05-16 00:55:52 +03:00
_WARN_UNUSED_RESULT_ int json_add_optional_bool ( struct json_object * object ,
const char * name ,
const bool * value ) ;
2018-07-24 06:20:21 +03:00
_WARN_UNUSED_RESULT_ int json_add_string ( struct json_object * object ,
const char * name ,
const char * value ) ;
_WARN_UNUSED_RESULT_ int json_add_object ( struct json_object * object ,
const char * name ,
struct json_object * value ) ;
_WARN_UNUSED_RESULT_ int json_add_stringn ( struct json_object * object ,
const char * name ,
const char * value ,
const size_t len ) ;
_WARN_UNUSED_RESULT_ int json_add_version ( struct json_object * object ,
int major ,
int minor ) ;
2023-05-16 00:57:12 +03:00
_WARN_UNUSED_RESULT_ int json_add_time ( struct json_object * object , const char * name , struct timeval tv ) ;
2018-07-24 06:20:21 +03:00
_WARN_UNUSED_RESULT_ int json_add_timestamp ( struct json_object * object ) ;
_WARN_UNUSED_RESULT_ int json_add_address (
struct json_object * object ,
const char * name ,
const struct tsocket_address * address ) ;
_WARN_UNUSED_RESULT_ int json_add_sid ( struct json_object * object ,
const char * name ,
const struct dom_sid * sid ) ;
_WARN_UNUSED_RESULT_ int json_add_guid ( struct json_object * object ,
const char * name ,
const struct GUID * guid ) ;
2018-04-09 21:45:47 +03:00
2023-05-16 00:53:02 +03:00
_WARN_UNUSED_RESULT_ int json_add_flags32 ( struct json_object * object ,
const char * name ,
uint32_t flags ) ;
2022-03-22 18:06:37 +03:00
_WARN_UNUSED_RESULT_ int json_update_object ( struct json_object * object ,
const char * key ,
struct json_object * new_obj ) ;
2018-07-24 06:20:21 +03:00
_WARN_UNUSED_RESULT_ struct json_object json_get_array (
struct json_object * object , const char * name ) ;
_WARN_UNUSED_RESULT_ struct json_object json_get_object (
struct json_object * object , const char * name ) ;
_WARN_UNUSED_RESULT_ char * json_to_string ( TALLOC_CTX * mem_ctx ,
2018-07-09 10:41:37 +03:00
const struct json_object * object ) ;
2023-06-15 04:30:45 +03:00
_WARN_UNUSED_RESULT_ struct json_object json_null_object ( void ) ;
2023-06-15 02:12:22 +03:00
struct authn_audit_info ;
_WARN_UNUSED_RESULT_ struct json_object json_from_audit_info (
const struct authn_audit_info * audit_info ) ;
2018-04-09 21:45:47 +03:00
# endif
2018-07-13 00:14:09 +03:00
# endif