From f1feccec5ad848b4f763376480a006a9d58fa721 Mon Sep 17 00:00:00 2001 From: Ritesh Harjani Date: Wed, 6 Jun 2018 15:09:00 +0530 Subject: mkfs.ubifs: Implement selinux labelling support in mkfs.ubifs. This implements/adds selinux labelling support to mkfs.ubifs utility. It adds an extra option in configure to enable selinux labelling support and then finally in mkfs.ubifs adds an extra option to pass the file_contexts which is looked up for filesystem file labels. - Default behavior is kept without selinux so as to not break existing support where selinux library/headers may not be present. - If this is configured with --with-selinux then XATTR from the file_contexts(passed with --selinux option while mkfs.ubifs) will be taken and not from the host file's xattr. This is done to avoid the problem where the host OS may have selinux enabled and hence same xattr names will be present in both host filesystem files and from the --selinux=file passed. So the existing behavior is kept mutually exclusive and preference is given to selinux xattrs (if configured with --with-selinux). Signed-off-by: Ritesh Harjani Signed-off-by: David Oberhollenzer --- configure.ac | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index f5538a0..c05d362 100644 --- a/configure.ac +++ b/configure.ac @@ -68,6 +68,7 @@ need_zlib="no" need_lzo="no" need_xattr="no" need_cmocka="no" +need_selinux="no" AM_COND_IF([UNIT_TESTS], [ @@ -153,6 +154,15 @@ AC_ARG_WITH([lzo], *) AC_MSG_ERROR([bad value ${withval} for --without-lzo]) ;; esac]) +AC_ARG_WITH([selinux], + [AS_HELP_STRING([--with-selinux], + [Enable support for selinux extended attributes])], + [case "${withval}" in + yes) need_selinux="yes";; + no) ;; + *) AC_MSG_ERROR([bad value ${withval} for --with-selinux]) ;; + esac]) + ##### search for dependencies ##### clock_gettime_missing="no" @@ -162,11 +172,16 @@ zlib_missing="no" lzo_missing="no" xattr_missing="no" cmocka_missing="no" +selinux_missing="no" if test "x$need_zlib" = "xyes"; then PKG_CHECK_MODULES(ZLIB, [zlib], [], [zlib_missing="yes"]) fi +if test "x$need_selinux" = "xyes"; then + PKG_CHECK_MODULES(LIBSELINUX, [libselinux], [], [selinux_missing="yes"]) +fi + if test "x$need_uuid" = "xyes"; then PKG_CHECK_MODULES(UUID, [uuid], [], [uuid_missing="yes"]) fi @@ -195,6 +210,11 @@ if test "x$need_xattr" = "xyes"; then AC_CHECK_HEADERS([sys/acl.h], [], [xattr_missing="yes"]) fi +if test "x$need_selinux" = "xyes"; then + AC_CHECK_HEADERS([selinux/selinux.h], [], [selinux_missing="yes"]) + AC_CHECK_HEADERS([selinux/label.h], [], [selinux_missing="yes"]) +fi + if test "x$need_cmocka" = "xyes"; then PKG_CHECK_MODULES(CMOCKA, [cmocka], [], [cmocka_missing="yes"]) fi @@ -244,6 +264,12 @@ if test "x$xattr_missing" = "xyes"; then need_xattr="no" fi +if test "x$selinux_missing" = "xyes"; then + AC_MSG_WARN([cannot find headers for selinux library]) + AC_MSG_WARN([disabling SELINUX support]) + need_selinux="no" +fi + if test "x$cmocka_missing" = "xyes"; then AC_MSG_WARN([cannot find CMocka library required for unit tests]) AC_MSG_NOTICE([unit tests can optionally be disabled]) @@ -258,6 +284,7 @@ fi AM_CONDITIONAL([WITHOUT_LZO], [test "x$need_lzo" != "xyes"]) AM_CONDITIONAL([WITHOUT_XATTR], [test "x$need_xattr" != "xyes"]) +AM_CONDITIONAL([WITH_SELINUX], [test "x$need_selinux" == "xyes"]) AC_CHECK_SIZEOF([off_t]) AC_CHECK_SIZEOF([loff_t]) -- cgit v1.2.3