1 /* Replacement <selinux/label.h> for platforms that lack it.
2 Copyright 2020-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 /* Written by Paul Eggert. */
18
19 #ifndef SELINUX_LABEL_H
20 #define SELINUX_LABEL_H
21
22 /* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE,
23 _GL_ATTRIBUTE_MAYBE_UNUSED. */
24 #if !_GL_CONFIG_H_INCLUDED
25 #error "Please include config.h first."
26 #endif
27
28 #include <selinux/selinux.h>
29 #include <errno.h>
30
31 _GL_INLINE_HEADER_BEGIN
32 #ifndef SE_LABEL_INLINE
33 # define SE_LABEL_INLINE _GL_INLINE
34 #endif
35
36 /* _GL_ATTRIBUTE_MAYBE_UNUSED declares that it is not a programming mistake if
37 the entity is not used. The compiler should not warn if the entity is not
38 used. */
39 #ifndef _GL_ATTRIBUTE_MAYBE_UNUSED
40 # if 0 /* no GCC or clang version supports this yet */
41 # define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]]
42 # elif defined __GNUC__ || defined __clang__
43 # define _GL_ATTRIBUTE_MAYBE_UNUSED __attribute__ ((__unused__))
44 # else
45 # define _GL_ATTRIBUTE_MAYBE_UNUSED
46 # endif
47 #endif
48
49 #define SELABEL_CTX_FILE 0
50
51 struct selabel_handle;
52
53 SE_LABEL_INLINE int
54 selabel_lookup (_GL_ATTRIBUTE_MAYBE_UNUSED struct selabel_handle *hnd,
55 _GL_ATTRIBUTE_MAYBE_UNUSED char **context,
56 _GL_ATTRIBUTE_MAYBE_UNUSED char const *key,
57 _GL_ATTRIBUTE_MAYBE_UNUSED int type)
58 { errno = ENOTSUP; return -1; }
59
60 SE_LABEL_INLINE struct selabel_handle *
61 selabel_open (_GL_ATTRIBUTE_MAYBE_UNUSED int backend,
62 _GL_ATTRIBUTE_MAYBE_UNUSED struct selinux_opt *options,
63 _GL_ATTRIBUTE_MAYBE_UNUSED unsigned nopt)
64 { errno = ENOTSUP; return 0; }
65
66 SE_LABEL_INLINE void
67 selabel_close (_GL_ATTRIBUTE_MAYBE_UNUSED struct selabel_handle *hnd)
68 { errno = ENOTSUP; }
69
70 _GL_INLINE_HEADER_END
71
72 #endif