AC_ARG_ENABLE(
[selinux],
- [AS_HELP_STRING([--disable-selinux], [disable SELinux support])],
+ [AS_HELP_STRING([--enable-selinux], [enable SELinux support])],
,
[enable_selinux="no"]
)
)
AC_SUBST([SOCKETS_LIBS])
+AC_CHECK_LIB(
+ [selinux],
+ [setcon],
+ [SELINUX_LIBS="-lselinux"]
+)
+AC_SUBST([SELINUX_LIBS])
+
case "${with_mem_check}" in
valgrind)
AC_CHECK_HEADER(
fi
fi
-dnl
-dnl check for SELinux library and headers
-dnl
-if test "${enable_selinux}" = "yes"; then
- AC_CHECK_HEADER(
- [selinux/selinux.h],
- [AC_CHECK_LIB(
- [selinux],
- [setcon],
- [
- LIBS="${LIBS} -lselinux"
- AC_DEFINE(HAVE_SETCON, 1, [SELinux support])
- ],
- [AC_MSG_RESULT([SELinux library not found.])]
- )],
- [AC_MSG_ERROR([SELinux headers not found.])]
- )
-fi
-
if test -n "${SP_PLATFORM_WINDOWS}"; then
AC_DEFINE_UNQUOTED([PATH_SEPARATOR], ['\\\\'], [Path separator]) #"
AC_DEFINE_UNQUOTED([PATH_SEPARATOR_STR], ["\\\\"], [Path separator]) #"
fi
fi
+if test "${enable_selinux}" = "yes"; then
+ test -z "${SELINUX_LIBS}" && AC_MSG_ERROR([libselinux required but missing])
+ OPTIONAL_SELINUX_LIBS="${SELINUX_LIBS}"
+ AC_DEFINE([ENABLE_SELINUX], [1], [SELinux support])
+fi
+
if test "${enable_pedantic}" = "yes"; then
enable_strict="yes"
CFLAGS="${CFLAGS} -ansi -pedantic"
AC_SUBST([TAP_WIN_MIN_MINOR])
AC_SUBST([OPTIONAL_DL_LIBS])
+AC_SUBST([OPTIONAL_SELINUX_LIBS])
AM_CONDITIONAL([WIN32], [test "${WIN32}" = "yes"])
mstats_open(c->options.memstats_fn);
#endif
-#ifdef HAVE_SETCON
+#ifdef ENABLE_SELINUX
/* Apply a SELinux context in order to restrict what OpenVPN can do
* to _only_ what it is supposed to do after initialization is complete
* (basically just network I/O operations). Doing it after chroot
msg (M_WARN, "WARNING: --ping should normally be used with --ping-restart or --ping-exit");
if (o->username || o->groupname || o->chroot_dir
-#ifdef HAVE_SETCON
+#ifdef ENABLE_SELINUX
|| o->selinux_context
#endif
)
"--user user : Set UID to user after initialization.\n"
"--group group : Set GID to group after initialization.\n"
"--chroot dir : Chroot to this directory after initialization.\n"
-#ifdef HAVE_SETCON
+#ifdef ENABLE_SELINUX
"--setcon context: Apply this SELinux context after initialization.\n"
#endif
"--cd dir : Change to this directory before initialization.\n"
SHOW_STR (groupname);
SHOW_STR (chroot_dir);
SHOW_STR (cd_dir);
-#ifdef HAVE_SETCON
+#ifdef ENABLE_SELINUX
SHOW_STR (selinux_context);
#endif
SHOW_STR (writepid);
}
options->cd_dir = p[1];
}
-#ifdef HAVE_SETCON
+#ifdef ENABLE_SELINUX
else if (streq (p[0], "setcon") && p[1])
{
VERIFY_PERMISSION (OPT_P_GENERAL);