summaryrefslogtreecommitdiff
path: root/lib/se-label.in.h
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2020-11-21 12:54:22 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2020-11-21 12:55:10 -0800
commita8269e99d349a8598d4f405af787139285475702 (patch)
treea0277e96a8c8786ced27ad9ea7015bfccb768312 /lib/se-label.in.h
parent63c809ade9daacf4a02f00cf082e73de224861c0 (diff)
downloadgnulib-a8269e99d349a8598d4f405af787139285475702.tar.gz
selinux-h: add stubs for selabel_open etc.
Coreutils with --enable-gcc-warnings does not build on Ubuntu 20.10 because matchpathcon is deprecated in favor of selabel_open etc., so this patch adds stubs for these functions. * lib/se-label.c, lib/se-label.in.h, m4/selinux-label-h.m4: New files. * lib/se-selinux.in.h (struct selinux_opt): Add incomplete decl, as it is needed for selabel_open and selinux/selinux.h declares this type here. * modules/selinux-h (Files): Add the new files. (configure.ac): Add gl_HEADERS_SELINUX_LABEL_H. (lib_SOURCES): Add se-label.in.h, se-label.c. (BUILT_SOURCES): Add $(SELINUX_LABEL_H). (selinux/label.h): New rule, mimicking selinux/context.h. (MOSTLYCLEANFILES): Add selinux/label.h, selinux/label.h-t. (Include): Add selinux/label.h.
Diffstat (limited to 'lib/se-label.in.h')
-rw-r--r--lib/se-label.in.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/lib/se-label.in.h b/lib/se-label.in.h
new file mode 100644
index 0000000000..405e77401c
--- /dev/null
+++ b/lib/se-label.in.h
@@ -0,0 +1,59 @@
+/* Replacement <selinux/label.h> for platforms that lack it.
+ Copyright 2020 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Paul Eggert. */
+
+#ifndef SELINUX_LABEL_H
+
+#define SELINUX_LABEL_H
+
+#include <selinux/selinux.h>
+#include <errno.h>
+
+#ifndef _GL_INLINE_HEADER_BEGIN
+ #error "Please include config.h first."
+#endif
+_GL_INLINE_HEADER_BEGIN
+#ifndef SE_LABEL_INLINE
+# define SE_LABEL_INLINE _GL_INLINE
+#endif
+
+/* The definition of _GL_UNUSED_PARAMETER is copied here. */
+
+#define SELABEL_CTX_FILE 0
+
+struct selabel_handle;
+
+SE_LABEL_INLINE int
+selabel_lookup (struct selabel_handle *hnd _GL_UNUSED_PARAMETER,
+ char **context _GL_UNUSED_PARAMETER,
+ char const *key _GL_UNUSED_PARAMETER,
+ int type _GL_UNUSED_PARAMETER)
+{ errno = ENOTSUP; return -1; }
+
+SE_LABEL_INLINE struct selabel_handle *
+selabel_open (int backend _GL_UNUSED_PARAMETER,
+ struct selinux_opt *options _GL_UNUSED_PARAMETER,
+ unsigned nopt _GL_UNUSED_PARAMETER)
+{ errno = ENOTSUP; return 0; }
+
+SE_LABEL_INLINE void
+selabel_close (struct selabel_handle *hnd _GL_UNUSED_PARAMETER)
+{ errno = ENOTSUP; }
+
+_GL_INLINE_HEADER_END
+
+#endif