Hi, I've just added the following new module, from coreutils. The second change set (below) cleans up a little.
I haven't yet listed the new module in MODULES.html.in, mainly because I haven't spotted a good place yet. Suggestions welcome. >From 8a5ff29ccb28ea665463f0ead178d4b0f801c2d1 Mon Sep 17 00:00:00 2001 From: Jim Meyering <[EMAIL PROTECTED]> Date: Tue, 21 Oct 2008 17:06:17 +0200 Subject: [PATCH 1/2] selinux-h: new module (from coreutils/gl/) * modules/selinux-h: New file. * lib/se-context.in.h: New file. * lib/se-selinux.in.h: New file. * m4/selinux-context-h.m4: New file. * m4/selinux-selinux-h.m4: New file. --- lib/se-context.in.h | 31 +++++++++++++++++++++++++ lib/se-selinux.in.h | 57 +++++++++++++++++++++++++++++++++++++++++++++++ m4/selinux-context-h.m4 | 17 ++++++++++++++ m4/selinux-selinux-h.m4 | 17 ++++++++++++++ modules/selinux-h | 46 +++++++++++++++++++++++++++++++++++++ 5 files changed, 168 insertions(+), 0 deletions(-) create mode 100644 lib/se-context.in.h create mode 100644 lib/se-selinux.in.h create mode 100644 m4/selinux-context-h.m4 create mode 100644 m4/selinux-selinux-h.m4 create mode 100644 modules/selinux-h diff --git a/lib/se-context.in.h b/lib/se-context.in.h new file mode 100644 index 0000000..ec88a03 --- /dev/null +++ b/lib/se-context.in.h @@ -0,0 +1,31 @@ +#ifndef SELINUX_CONTEXT_H +# define SELINUX_CONTEXT_H + +# include <errno.h> +/* Some systems don't have ENOTSUP. */ +# ifndef ENOTSUP +# ifdef ENOSYS +# define ENOTSUP ENOSYS +# else +/* Some systems don't have ENOSYS either. */ +# define ENOTSUP EINVAL +# endif +# endif + +typedef int context_t; +static inline context_t context_new (char const *s) + { errno = ENOTSUP; return 0; } +static inline char *context_str (context_t con) + { errno = ENOTSUP; return (void *) 0; } +static inline void context_free (context_t c) {} + +static inline int context_user_set (context_t sc, char const *s) + { errno = ENOTSUP; return -1; } +static inline int context_role_set (context_t sc, char const *s) + { errno = ENOTSUP; return -1; } +static inline int context_range_set (context_t sc, char const *s) + { errno = ENOTSUP; return -1; } +static inline int context_type_set (context_t sc, char const *s) + { errno = ENOTSUP; return -1; } + +#endif diff --git a/lib/se-selinux.in.h b/lib/se-selinux.in.h new file mode 100644 index 0000000..aeaf950 --- /dev/null +++ b/lib/se-selinux.in.h @@ -0,0 +1,57 @@ +#ifndef SELINUX_SELINUX_H +# define SELINUX_SELINUX_H + +# include <sys/types.h> +# include <errno.h> +/* Some systems don't have ENOTSUP. */ +# ifndef ENOTSUP +# ifdef ENOSYS +# define ENOTSUP ENOSYS +# else +/* Some systems don't have ENOSYS either. */ +# define ENOTSUP EINVAL +# endif +# endif + +typedef unsigned short security_class_t; +# define security_context_t char* +# define is_selinux_enabled() 0 + +static inline int getcon (security_context_t *con) + { errno = ENOTSUP; return -1; } +static inline void freecon (security_context_t con) {} + + +static inline int getfscreatecon (security_context_t *con) + { errno = ENOTSUP; return -1; } +static inline int setfscreatecon (security_context_t con) + { errno = ENOTSUP; return -1; } +static inline int matchpathcon (char const *s, mode_t m, + security_context_t *con) + { errno = ENOTSUP; return -1; } +static inline int getfilecon (char const *s, security_context_t *con) + { errno = ENOTSUP; return -1; } +static inline int lgetfilecon (char const *s, security_context_t *con) + { errno = ENOTSUP; return -1; } +static inline int setfilecon (char const *s, security_context_t con) + { errno = ENOTSUP; return -1; } +static inline int lsetfilecon (char const *s, security_context_t con) + { errno = ENOTSUP; return -1; } +static inline int fsetfilecon (int fd, security_context_t con) + { errno = ENOTSUP; return -1; } + +static inline int security_check_context (security_context_t con) + { errno = ENOTSUP; return -1; } +static inline int security_check_context_raw (security_context_t con) + { errno = ENOTSUP; return -1; } +static inline int setexeccon (security_context_t con) + { errno = ENOTSUP; return -1; } +static inline int security_compute_create (security_context_t scon, + security_context_t tcon, + security_class_t tclass, + security_context_t *newcon) + { errno = ENOTSUP; return -1; } +static inline int matchpathcon_init_prefix (char const *path, + char const *prefix) + { errno = ENOTSUP; return -1; } +#endif diff --git a/m4/selinux-context-h.m4 b/m4/selinux-context-h.m4 new file mode 100644 index 0000000..269c152 --- /dev/null +++ b/m4/selinux-context-h.m4 @@ -0,0 +1,17 @@ +# serial 1 -*- Autoconf -*- +# Copyright (C) 2006, 2007 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# From Jim Meyering +# Provide <selinux/context.h>, if necessary. + +AC_DEFUN([gl_HEADERS_SELINUX_CONTEXT_H], +[ + # Check for <selinux/context.h>, + AC_CHECK_HEADERS([selinux/context.h], + [SELINUX_CONTEXT_H=], + [SELINUX_CONTEXT_H=selinux/context.h]) + AC_SUBST([SELINUX_CONTEXT_H]) +]) diff --git a/m4/selinux-selinux-h.m4 b/m4/selinux-selinux-h.m4 new file mode 100644 index 0000000..822ffa2 --- /dev/null +++ b/m4/selinux-selinux-h.m4 @@ -0,0 +1,17 @@ +# serial 1 -*- Autoconf -*- +# Copyright (C) 2006, 2007 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# From Jim Meyering +# Provide <selinux/selinux.h>, if necessary. + +AC_DEFUN([gl_HEADERS_SELINUX_SELINUX_H], +[ + # Check for <selinux/selinux.h>, + AC_CHECK_HEADERS([selinux/selinux.h], + [SELINUX_SELINUX_H=], + [SELINUX_SELINUX_H=selinux/selinux.h]) + AC_SUBST([SELINUX_SELINUX_H]) +]) diff --git a/modules/selinux-h b/modules/selinux-h new file mode 100644 index 0000000..603e057 --- /dev/null +++ b/modules/selinux-h @@ -0,0 +1,46 @@ +Description: +SELinux-related headers for systems that lack them. + +Files: +lib/se-context.in.h +lib/se-selinux.in.h +m4/selinux-context-h.m4 +m4/selinux-selinux-h.m4 + +Depends-on: + +configure.ac: +gl_HEADERS_SELINUX_SELINUX_H +gl_HEADERS_SELINUX_CONTEXT_H + +Makefile.am: +lib_SOURCES += se-context.in.h se-selinux.in.h + +BUILT_SOURCES += $(SELINUX_SELINUX_H) +selinux/selinux.h: se-selinux.in.h + rm -f [EMAIL PROTECTED] $@ + $(MKDIR_P) selinux + cp $(srcdir)/se-selinux.in.h [EMAIL PROTECTED] + chmod a-x [EMAIL PROTECTED] + mv [EMAIL PROTECTED] $@ +MOSTLYCLEANFILES += selinux/selinux.h selinux/selinux.h-t + +BUILT_SOURCES += $(SELINUX_CONTEXT_H) +selinux/context.h: se-context.in.h + rm -f [EMAIL PROTECTED] $@ + $(MKDIR_P) selinux + cp $(srcdir)/se-context.in.h [EMAIL PROTECTED] + chmod a-x [EMAIL PROTECTED] + mv [EMAIL PROTECTED] $@ +MOSTLYCLEANFILES += selinux/context.h selinux/context.h-t +MOSTLYCLEANDIRS += selinux + +Include: +#include <selinux/selinux.h> +#include <selinux/context.h> + +License: +LGPLv2+ + +Maintainer: +Jim Meyering -- 1.6.0.2.588.g3102 >From f279ac41c7bdc3ee7abca7e401cf84fbb3e2e665 Mon Sep 17 00:00:00 2001 From: Jim Meyering <[EMAIL PROTECTED]> Date: Tue, 21 Oct 2008 17:18:53 +0200 Subject: [PATCH 2/2] se-linux-h: remove ENOTSUPP-defining code; instead, use errno * modules/selinux-h (Depends-on): Add errno. (configure.ac): Add AC_REQUIRE([AC_C_INLINE]). * lib/se-context.in.h: Remove code to define ENOTSUPP. * lib/se-selinux.in.h: Likewise. --- lib/se-context.in.h | 9 --------- lib/se-selinux.in.h | 9 --------- modules/selinux-h | 2 ++ 3 files changed, 2 insertions(+), 18 deletions(-) diff --git a/lib/se-context.in.h b/lib/se-context.in.h index ec88a03..f9fe923 100644 --- a/lib/se-context.in.h +++ b/lib/se-context.in.h @@ -2,15 +2,6 @@ # define SELINUX_CONTEXT_H # include <errno.h> -/* Some systems don't have ENOTSUP. */ -# ifndef ENOTSUP -# ifdef ENOSYS -# define ENOTSUP ENOSYS -# else -/* Some systems don't have ENOSYS either. */ -# define ENOTSUP EINVAL -# endif -# endif typedef int context_t; static inline context_t context_new (char const *s) diff --git a/lib/se-selinux.in.h b/lib/se-selinux.in.h index aeaf950..ce64487 100644 --- a/lib/se-selinux.in.h +++ b/lib/se-selinux.in.h @@ -3,15 +3,6 @@ # include <sys/types.h> # include <errno.h> -/* Some systems don't have ENOTSUP. */ -# ifndef ENOTSUP -# ifdef ENOSYS -# define ENOTSUP ENOSYS -# else -/* Some systems don't have ENOSYS either. */ -# define ENOTSUP EINVAL -# endif -# endif typedef unsigned short security_class_t; # define security_context_t char* diff --git a/modules/selinux-h b/modules/selinux-h index 603e057..05cdd71 100644 --- a/modules/selinux-h +++ b/modules/selinux-h @@ -8,10 +8,12 @@ m4/selinux-context-h.m4 m4/selinux-selinux-h.m4 Depends-on: +errno configure.ac: gl_HEADERS_SELINUX_SELINUX_H gl_HEADERS_SELINUX_CONTEXT_H +AC_REQUIRE([AC_C_INLINE]) Makefile.am: lib_SOURCES += se-context.in.h se-selinux.in.h -- 1.6.0.2.588.g3102