1/*
2 * This file describes the callbacks passed to selinux_init() and available
3 * for use from the library code.  They all have default implementations.
4 */
5#ifndef _SELINUX_CALLBACKS_H_
6#define _SELINUX_CALLBACKS_H_
7
8#include <errno.h>
9#include <stdio.h>
10#include <stdlib.h>
11#include <string.h>
12#include <selinux/selinux.h>
13
14#include "selinux_internal.h"
15
16/* callback pointers */
17extern int __attribute__ ((format(printf, 2, 3)))
18(*selinux_log_direct) (int type, const char *, ...) ;
19
20extern int
21(*selinux_audit) (void *, security_class_t, char *, size_t) ;
22
23extern int
24(*selinux_validate)(char **ctx) ;
25
26extern int
27(*selinux_netlink_setenforce) (int enforcing) ;
28
29extern int
30(*selinux_netlink_policyload) (int seqno) ;
31
32/* Thread-safe selinux_log() function */
33extern pthread_mutex_t log_mutex;
34
35#define selinux_log(type, ...) do { \
36	int saved_errno__ = errno; \
37	__pthread_mutex_lock(&log_mutex); \
38	selinux_log_direct(type, __VA_ARGS__); \
39	__pthread_mutex_unlock(&log_mutex); \
40	errno = saved_errno__; \
41} while(0)
42
43#endif				/* _SELINUX_CALLBACKS_H_ */
44