16cd6a6acSopenharmony_ci/* 26cd6a6acSopenharmony_ci * This file describes the callbacks passed to selinux_init() and available 36cd6a6acSopenharmony_ci * for use from the library code. They all have default implementations. 46cd6a6acSopenharmony_ci */ 56cd6a6acSopenharmony_ci#ifndef _SELINUX_CALLBACKS_H_ 66cd6a6acSopenharmony_ci#define _SELINUX_CALLBACKS_H_ 76cd6a6acSopenharmony_ci 86cd6a6acSopenharmony_ci#include <errno.h> 96cd6a6acSopenharmony_ci#include <stdio.h> 106cd6a6acSopenharmony_ci#include <stdlib.h> 116cd6a6acSopenharmony_ci#include <string.h> 126cd6a6acSopenharmony_ci#include <selinux/selinux.h> 136cd6a6acSopenharmony_ci 146cd6a6acSopenharmony_ci#include "selinux_internal.h" 156cd6a6acSopenharmony_ci 166cd6a6acSopenharmony_ci/* callback pointers */ 176cd6a6acSopenharmony_ciextern int __attribute__ ((format(printf, 2, 3))) 186cd6a6acSopenharmony_ci(*selinux_log_direct) (int type, const char *, ...) ; 196cd6a6acSopenharmony_ci 206cd6a6acSopenharmony_ciextern int 216cd6a6acSopenharmony_ci(*selinux_audit) (void *, security_class_t, char *, size_t) ; 226cd6a6acSopenharmony_ci 236cd6a6acSopenharmony_ciextern int 246cd6a6acSopenharmony_ci(*selinux_validate)(char **ctx) ; 256cd6a6acSopenharmony_ci 266cd6a6acSopenharmony_ciextern int 276cd6a6acSopenharmony_ci(*selinux_netlink_setenforce) (int enforcing) ; 286cd6a6acSopenharmony_ci 296cd6a6acSopenharmony_ciextern int 306cd6a6acSopenharmony_ci(*selinux_netlink_policyload) (int seqno) ; 316cd6a6acSopenharmony_ci 326cd6a6acSopenharmony_ci/* Thread-safe selinux_log() function */ 336cd6a6acSopenharmony_ciextern pthread_mutex_t log_mutex; 346cd6a6acSopenharmony_ci 356cd6a6acSopenharmony_ci#define selinux_log(type, ...) do { \ 366cd6a6acSopenharmony_ci int saved_errno__ = errno; \ 376cd6a6acSopenharmony_ci __pthread_mutex_lock(&log_mutex); \ 386cd6a6acSopenharmony_ci selinux_log_direct(type, __VA_ARGS__); \ 396cd6a6acSopenharmony_ci __pthread_mutex_unlock(&log_mutex); \ 406cd6a6acSopenharmony_ci errno = saved_errno__; \ 416cd6a6acSopenharmony_ci} while(0) 426cd6a6acSopenharmony_ci 436cd6a6acSopenharmony_ci#endif /* _SELINUX_CALLBACKS_H_ */ 44