Debian Codegraph @

libselinux/man/man3/selinux_set_mapping.3

raw
1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\"
3 .\" Author: Eamon Walsh ([email protected]) 2008
4 .TH "selinux_set_mapping" "3" "12 Jun 2008" "" "SELinux API documentation"
5 .SH "NAME"
6 selinux_set_mapping \- establish dynamic object class and permission mapping
7 .
8 .SH "SYNOPSIS"
9 .B #include <selinux/selinux.h>
10 .sp
11 .nf
12 struct security_class_mapping {
13 const char *name;
14 const char *perms[];
15 };
16 .fi
17 .sp
18 .BI "int selinux_set_mapping(struct security_class_mapping *" map ");"
19 .
20 .SH "DESCRIPTION"
21 .BR selinux_set_mapping ()
22 establishes a mapping from a user-provided ordering of object classes and permissions to the numbers actually used by the loaded system policy. Use of this function is highly preferred over the generated constants in the libselinux header files, as this method allows the policy's class and permission values to change over time.
23
24 After the mapping is established, all libselinux functions that operate on class and permission values take the user-provided numbers, which are determined as follows:
25
26 The
27 .I map
28 argument consists of an array of
29 .B security_class_mapping
30 structures, which must be terminated by a structure having a NULL name field. Except for this last structure, the
31 .I name
32 field should refer to the string name of an object class, and the corresponding
33 .I perms
34 field should refer to an array of permission bit names terminated by a NULL string.
35
36 The object classes named in the mapping and the bit indexes of each set of permission bits named in the mapping are numbered in order starting from 1. These numbers are the values that should be passed to subsequent libselinux calls.
37 .
38 .SH "RETURN VALUE"
39 Zero is returned on success. On error, \-1 is returned and
40 .I errno
41 is set appropriately.
42 .
43 .SH "ERRORS"
44 .TP
45 .B EINVAL
46 One of the class or permission names requested in the mapping is not present in the loaded policy.
47 .TP
48 .B ENOMEM
49 An attempt to allocate memory failed.
50 .
51 .SH "EXAMPLE"
52 .RS
53 .ta 4n 10n
54 .nf
55 struct security_class_mapping map[] = {
56 { "file", { "create", "unlink", "read", "write", NULL } },
57 { "socket", { "bind", NULL } },
58 { "process", { "signal", NULL } },
59 { NULL }
60 };
61
62 if (selinux_set_mapping(map) < 0)
63 exit(1);
64 .fi
65 .ta
66 .RE
67
68 In this example, after the call has succeeded, classes
69 .BR file ,
70 .BR socket ,
71 and
72 .B process
73 will be identified by 1, 2 and 3, respectively. Permissions
74 .IR create ,
75 .IR unlink ,
76 .IR read ,
77 and
78 .I write
79 (for the
80 .B file
81 class) will be identified by 1, 2, 4, and 8 respectively. Classes and permissions not listed in the mapping cannot be used.
82 .
83 .SH "AUTHOR"
84 Eamon Walsh <[email protected]>
85 .
86 .SH "SEE ALSO"
87 .BR avc_open (8),
88 .BR selinux (8)