1 /* Replacement <selinux/selinux.h> for platforms that lack it.
2 Copyright (C) 2008-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17 #if __GNUC__ >= 3
18 @PRAGMA_SYSTEM_HEADER@
19 #endif
20 @PRAGMA_COLUMNS@
21
22 #if @HAVE_SELINUX_SELINUX_H@
23
24 #@INCLUDE_NEXT@ @NEXT_SELINUX_SELINUX_H@
25
26 #else
27 # if !defined _@GUARD_PREFIX@_SELINUX_SELINUX_H
28 # define _@GUARD_PREFIX@_SELINUX_SELINUX_H
29
30 /* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE,
31 _GL_ATTRIBUTE_MAYBE_UNUSED. */
32 # if !_GL_CONFIG_H_INCLUDED
33 # error "Please include config.h first."
34 # endif
35
36 # include <sys/types.h>
37 # include <errno.h>
38
39 _GL_INLINE_HEADER_BEGIN
40 # ifndef SE_SELINUX_INLINE
41 # define SE_SELINUX_INLINE _GL_INLINE
42 # endif
43
44 /* _GL_ATTRIBUTE_MAYBE_UNUSED declares that it is not a programming mistake if
45 the entity is not used. The compiler should not warn if the entity is not
46 used. */
47 # ifndef _GL_ATTRIBUTE_MAYBE_UNUSED
48 # if 0 /* no GCC or clang version supports this yet */
49 # define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]]
50 # elif defined __GNUC__ || defined __clang__
51 # define _GL_ATTRIBUTE_MAYBE_UNUSED __attribute__ ((__unused__))
52 # else
53 # define _GL_ATTRIBUTE_MAYBE_UNUSED
54 # endif
55 # endif
56
57 # if !GNULIB_defined_security_types
58
59 typedef unsigned short security_class_t;
60 struct selinux_opt;
61 # define is_selinux_enabled() 0
62
63 SE_SELINUX_INLINE int
64 getcon (_GL_ATTRIBUTE_MAYBE_UNUSED char **con)
65 { errno = ENOTSUP; return -1; }
66 SE_SELINUX_INLINE void
67 freecon (_GL_ATTRIBUTE_MAYBE_UNUSED char *con) {}
68
69 SE_SELINUX_INLINE int
70 getfscreatecon (_GL_ATTRIBUTE_MAYBE_UNUSED char **con)
71 { errno = ENOTSUP; return -1; }
72 SE_SELINUX_INLINE int
73 setfscreatecon (_GL_ATTRIBUTE_MAYBE_UNUSED char const *con)
74 { errno = ENOTSUP; return -1; }
75 SE_SELINUX_INLINE int
76 matchpathcon (_GL_ATTRIBUTE_MAYBE_UNUSED char const *file,
77 _GL_ATTRIBUTE_MAYBE_UNUSED mode_t m,
78 _GL_ATTRIBUTE_MAYBE_UNUSED char **con)
79 { errno = ENOTSUP; return -1; }
80 SE_SELINUX_INLINE int
81 getfilecon (_GL_ATTRIBUTE_MAYBE_UNUSED char const *file,
82 _GL_ATTRIBUTE_MAYBE_UNUSED char **con)
83 { errno = ENOTSUP; return -1; }
84 SE_SELINUX_INLINE int
85 lgetfilecon (_GL_ATTRIBUTE_MAYBE_UNUSED char const *file,
86 _GL_ATTRIBUTE_MAYBE_UNUSED char **con)
87 { errno = ENOTSUP; return -1; }
88 SE_SELINUX_INLINE int
89 fgetfilecon (int fd,_GL_ATTRIBUTE_MAYBE_UNUSED char **con)
90 { errno = ENOTSUP; return -1; }
91 SE_SELINUX_INLINE int
92 setfilecon (_GL_ATTRIBUTE_MAYBE_UNUSED char const *file,
93 _GL_ATTRIBUTE_MAYBE_UNUSED char const *con)
94 { errno = ENOTSUP; return -1; }
95 SE_SELINUX_INLINE int
96 lsetfilecon (_GL_ATTRIBUTE_MAYBE_UNUSED char const *file,
97 _GL_ATTRIBUTE_MAYBE_UNUSED char const *con)
98 { errno = ENOTSUP; return -1; }
99 SE_SELINUX_INLINE int
100 fsetfilecon (_GL_ATTRIBUTE_MAYBE_UNUSED int fd,
101 _GL_ATTRIBUTE_MAYBE_UNUSED char const *con)
102 { errno = ENOTSUP; return -1; }
103
104 SE_SELINUX_INLINE int
105 security_check_context (_GL_ATTRIBUTE_MAYBE_UNUSED char const *con)
106 { errno = ENOTSUP; return -1; }
107 SE_SELINUX_INLINE int
108 security_check_context_raw (_GL_ATTRIBUTE_MAYBE_UNUSED char const *con)
109 { errno = ENOTSUP; return -1; }
110 SE_SELINUX_INLINE int
111 setexeccon (_GL_ATTRIBUTE_MAYBE_UNUSED char const *con)
112 { errno = ENOTSUP; return -1; }
113 SE_SELINUX_INLINE int
114 security_compute_create (_GL_ATTRIBUTE_MAYBE_UNUSED char const *scon,
115 _GL_ATTRIBUTE_MAYBE_UNUSED char const *tcon,
116 _GL_ATTRIBUTE_MAYBE_UNUSED security_class_t tclass,
117 _GL_ATTRIBUTE_MAYBE_UNUSED char **newcon)
118 { errno = ENOTSUP; return -1; }
119 SE_SELINUX_INLINE security_class_t
120 string_to_security_class (char const *name)
121 { errno = ENOTSUP; return 0; }
122 SE_SELINUX_INLINE int
123 matchpathcon_init_prefix (_GL_ATTRIBUTE_MAYBE_UNUSED char const *path,
124 _GL_ATTRIBUTE_MAYBE_UNUSED char const *prefix)
125 { errno = ENOTSUP; return -1; }
126
127 # define GNULIB_defined_security_types 1
128 # endif
129
130 _GL_INLINE_HEADER_END
131
132 # endif
133 #endif