File: selinux_set_callback.3

package info (click to toggle)
libselinux 3.8.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 2,380 kB
  • sloc: ansic: 17,619; makefile: 416; sh: 48; python: 21
file content (132 lines) | stat: -rw-r--r-- 3,221 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
.\" Hey Emacs! This file is -*- nroff -*- source.
.\"
.\" Author: Eamon Walsh (ewalsh@tycho.nsa.gov) 2007
.TH "selinux_set_callback" "3" "20 Jun 2007" "" "SELinux API documentation"
.SH "NAME"
selinux_set_callback \- userspace SELinux callback facilities
.
.SH "SYNOPSIS"
.B #include <selinux/selinux.h>
.sp
.BI "void selinux_set_callback(int " type ", union selinux_callback " callback ");"
.
.SH "DESCRIPTION"
.BR selinux_set_callback ()
sets the callback indicated by
.I type
to the value of
.IR callback ,
which should be passed as a function pointer cast to type
.B union
.BR selinux_callback .

All callback functions should return a negative value with
.I errno
set appropriately on error.

The available values for 
.I type
are:
.TP
.B SELINUX_CB_LOG
.BI "int (*" func_log ") (int " type ", const char *" fmt ", ...);"

This callback is used for logging and should process the 
.BR printf (3)
style 
.I fmt
string and arguments as appropriate.  The
.I type
argument indicates the type of message and will be set to one of the following:

.B SELINUX_ERROR

.B SELINUX_WARNING

.B SELINUX_INFO

.B SELINUX_AVC

.B SELINUX_POLICYLOAD

.B 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.

.
.TP
.B SELINUX_CB_AUDIT
.BI "int (*" func_audit ") (void *" auditdata ", security_class_t " cls ,
.in +\w'int (*func_audit) ('u
.BI "char *" msgbuf ", size_t " msgbufsize ");"
.in

This callback is used for supplemental auditing in AVC messages.  The
.I auditdata
and
.I cls
arguments are the values passed to
.BR avc_has_perm (3).
A human-readable interpretation should be printed to
.I msgbuf
using no more than
.I msgbufsize
characters.
.
.TP
.B SELINUX_CB_VALIDATE
.BI "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 
.I ctx
pointer to a new context.  In this case, the old value should be freed with
.BR freecon (3).
The value of
.I errno
should be set to
.B EINVAL
to indicate an invalid context.
.
.TP
.B SELINUX_CB_SETENFORCE
.BI "int (*" func_setenforce ") (int " enforcing ");"

This callback is invoked when the system enforcing state changes.
The
.I enforcing
argument indicates the new value and is set to
.I 1
for enforcing mode, and
.I 0
for permissive mode.
.
.TP
.B SELINUX_CB_POLICYLOAD
.BI "int (*" func_policyload ") (int " seqno ");"

This callback is invoked when the system security policy is reloaded.
The
.I seqno
argument is the current sequential number of the policy generation in the system.
.
.SH "RETURN VALUE"
None.
.
.SH "ERRORS"
None.
.
.SH "AUTHOR"
Eamon Walsh <ewalsh@tycho.nsa.gov>
.
.SH "SEE ALSO"
.BR selabel_open (3),
.BR avc_init (3),
.BR avc_netlink_open (3),
.BR selinux (8)