# selinux_set_callback

## NAME



           selinux_set_callback - userspace SELinux callback facilities
    


## SYNOPSIS



           **#include <selinux/selinux.h>**
    
           **void selinux_set_callback(int** _type_**, union selinux_callback**
           _callback_**);**
    


## DESCRIPTION



           **selinux_set_callback**() sets the callback indicated by _type_ to the
           value of _callback_ , which should be passed as a function pointer
           cast to type **union selinux_callback**.
    
           All callback functions should return a negative value with _errno_
           set appropriately on error.
    
           The available values for _type_ are:
    
           **SELINUX_CB_LOG**
                  **int (***_func_log_**) (int** _type_**, const char ***_fmt_**, ...);**
    
                  This callback is used for logging and should process the
                  printf(3) style _fmt_ string and arguments as appropriate.
                  The _type_ argument indicates the type of message and will be
                  set to one of the following:
    
                  **SELINUX_ERROR**
    
                  **SELINUX_WARNING**
    
                  **SELINUX_INFO**
    
                  **SELINUX_AVC**
    
                  **SELINUX_POLICYLOAD**
    
                  **SELINUX_SETENFORCE**
    
                  SELINUX_ERROR, SELINUX_WARNING, and SELINUX_INFO indicate
                  standard log severity levels and are not auditable
                  messages.
    
                  The SELINUX_AVC, SELINUX_POLICYLOAD, and SELINUX_SETENFORCE
                  message types can be audited with AUDIT_USER_AVC,
                  AUDIT_USER_MAC_POLICY_LOAD, and AUDIT_USER_MAC_STATUS
                  values from libaudit, respectively.  If they are not
                  audited, SELINUX_AVC should be considered equivalent to
                  SELINUX_ERROR; similarly, SELINUX_POLICYLOAD and
                  SELINUX_SETENFORCE should be considered equivalent to
                  SELINUX_INFO.
    
           **SELINUX_CB_AUDIT**
                  **int (***_func_audit_**) (void ***_auditdata_**, security_class_t** _cls_**,**
                                     **char ***_msgbuf_**, size_t** _msgbufsize_**);**
    
                  This callback is used for supplemental auditing in AVC
                  messages.  The _auditdata_ and _cls_ arguments are the values
                  passed to avc_has_perm(3).  A human-readable interpretation
                  should be printed to _msgbuf_ using no more than _msgbufsize_
                  characters.
    
           **SELINUX_CB_VALIDATE**
                  **int (***_func_validate_**) (char ****_ctx_**);**
    
                  This callback is used for context validation.  The callback
                  may optionally modify the input context by setting the
                  target of the _ctx_ pointer to a new context.  In this case,
                  the old value should be freed with freecon(3).  The value
                  of _errno_ should be set to **EINVAL** to indicate an invalid
                  context.
    
           **SELINUX_CB_SETENFORCE**
                  **int (***_func_setenforce_**) (int** _enforcing_**);**
    
                  This callback is invoked when the system enforcing state
                  changes.  The _enforcing_ argument indicates the new value
                  and is set to _1_ for enforcing mode, and _0_ for permissive
                  mode.
    
           **SELINUX_CB_POLICYLOAD**
                  **int (***_func_policyload_**) (int** _seqno_**);**
    
                  This callback is invoked when the system security policy is
                  reloaded.  The _seqno_ argument is the current sequential
                  number of the policy generation in the system.
    


## RETURN VALUE



           None.
    


## ERRORS



           None.
    


* * *