# used by shred
AC_CHECK_FUNCS_ONCE([directio])
- # Used by install.c.
coreutils_saved_libs=$LIBS
LIBS="$LIBS $LIB_SELINUX"
+ # Used by selinux.c.
+ AC_CHECK_FUNCS([mode_to_security_class], [], [])
+ # Used by install.c.
AC_CHECK_FUNCS([matchpathcon_init_prefix], [],
[
case "$ac_cv_search_setfilecon:$ac_cv_header_selinux_selinux_h" in
#include "quote.h"
#include "selinux.h"
+#if HAVE_SELINUX_SELINUX_H
+
+# if ! HAVE_MODE_TO_SECURITY_CLASS
/*
- This function has being added to libselinux-2.1.12-5, but is here
+ This function has been added to libselinux-2.1.12-5, but is here
for support with older versions of SELinux
Translates a mode into an Internal SELinux security_class definition.
errno = EINVAL;
return 0;
}
+# endif
/*
This function takes a PATH and a MODE and then asks SELinux what the label
{
int rc = -1;
security_context_t scon = NULL, tcon = NULL;
- context_t scontext = NULL, tcontext = NULL;
+ context_t scontext = 0, tcontext = 0;
const char *contype;
char *constr;
char *newpath = NULL;
int rc = -1;
struct stat sb;
security_context_t scon = NULL, tcon = NULL;
- context_t scontext = NULL, tcontext = NULL;
+ context_t scontext = 0, tcontext = 0;
const char *contype;
char *constr;
int fd;
free (newpath);
return ok;
}
+#endif
#ifndef COREUTILS_SELINUX_H
# define COREUTILS_SELINUX_H
+# if HAVE_SELINUX_SELINUX_H
+
extern bool restorecon (char const *path, bool recurse, bool preserve);
extern int defaultcon (char const *path, mode_t mode);
+# else
+
+static inline bool
+restorecon (char const *path, bool recurse, bool preserve)
+{ errno = ENOTSUP; return false; }
+
+static inline int
+defaultcon (char const *path, mode_t mode)
+{ errno = ENOTSUP; return -1; }
+
+# endif
+
#endif