Debian Codegraph @

libselinux/man/man3/selabel_open.3

raw
1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\"
3 .\" Author: Eamon Walsh ([email protected]) 2007
4 .TH "selabel_open" "3" "18 Jun 2007" "" "SELinux API documentation"
5 .SH "NAME"
6 selabel_open, selabel_close \- userspace SELinux labeling interface
7 .
8 .SH "SYNOPSIS"
9 .B #include <selinux/selinux.h>
10 .br
11 .B #include <selinux/label.h>
12 .sp
13 .BI "struct selabel_handle *selabel_open(int " backend ,
14 .in +\w'struct selabel_handle *selabel_open('u
15 .BI "const struct selinux_opt *" options ,
16 .br
17 .BI "unsigned " nopt ");"
18 .in
19 .sp
20 .BI "void selabel_close(struct selabel_handle *" hnd ");"
21 .
22 .SH "DESCRIPTION"
23 .BR selabel_open ()
24 is used to initialize a labeling handle to be used for lookup operations. The
25 .I backend
26 argument specifies which backend is to be opened; the list of current backends appears in
27 .B BACKENDS
28 below.
29
30 The
31 .I options
32 argument should be NULL or a pointer to an array of
33 .B selinux_opt
34 structures of length
35 .IR nopt :
36
37 .RS
38 .ta 4n 16n 24n
39 .nf
40 struct selinux_opt {
41 int type;
42 const char *value;
43 };
44 .fi
45 .ta
46 .RE
47
48 The available option types are described in
49 .B GLOBAL OPTIONS
50 below as well as in the documentation for each individual backend. The return value on success is a non-NULL value for use in subsequent label operations.
51
52 .BR selabel_close ()
53 terminates use of a handle, freeing any internal resources associated with it. After this call has been made, the handle must not be used again.
54 .
55 .SH "GLOBAL OPTIONS"
56 Global options which may be passed to
57 .BR selabel_open ()
58 include the following:
59 .
60 .TP
61 .B SELABEL_OPT_UNUSED
62 The option with a type code of zero is a no-op. Thus an array of options may be initizalized to zero and any untouched elements will not cause an error.
63 .TP
64 .B SELABEL_OPT_VALIDATE
65 A non-null value for this option enables context validation. By default,
66 .BR security_check_context (3)
67 is used; a custom validation function can be provided via
68 .BR selinux_set_callback (3).
69 Note that an invalid context may not be treated as an error unless it is actually encountered during a lookup operation.
70 .TP
71 .B SELABEL_OPT_DIGEST
72 A non-null value for this option enables the generation of an SHA1 digest of
73 the spec files loaded as described in
74 .BR selabel_digest (3)
75 .
76 .SH "BACKENDS"
77 .TP
78 .B SELABEL_CTX_FILE
79 File contexts backend, described in
80 .BR selabel_file (5).
81 .TP
82 .B SELABEL_CTX_MEDIA
83 Media contexts backend, described in
84 .BR selabel_media (5).
85 .TP
86 .B SELABEL_CTX_X
87 X Windows contexts backend, described in
88 .BR selabel_x (5).
89 .TP
90 .B SELABEL_CTX_DB
91 Database objects contexts backend, described in
92 .BR selabel_db (5).
93 .
94 .SH "RETURN VALUE"
95 A non-NULL handle value is returned on success. On error, NULL is returned and
96 .I errno
97 is set appropriately.
98 .
99 .SH "AUTHOR"
100 Eamon Walsh <[email protected]>
101 .
102 .SH "SEE ALSO"
103 .ad l
104 .nh
105 .BR selabel_lookup (3),
106 .BR selabel_stats (3),
107 .BR selinux_set_callback (3),
108 .BR selinux (8)