|
|
548c8b |
From b8f375c2c8140e759122bca3e3469386d3ba5184 Mon Sep 17 00:00:00 2001
|
|
|
548c8b |
From: "Dmitry V. Levin" <ldv@strace.io>
|
|
|
548c8b |
Date: Mon, 29 Nov 2021 08:00:00 +0000
|
|
|
548c8b |
Subject: [PATCH 168/174] m4: fix st_SELINUX check
|
|
|
548c8b |
|
|
|
548c8b |
* m4/st_selinux.m4: Make sure selinux support is enabled only if
|
|
|
548c8b |
all expected functions are provided by libselinux.
|
|
|
548c8b |
|
|
|
548c8b |
Fixes: v5.12~49 "Implement --secontext[=full] option to display SELinux contexts"
|
|
|
548c8b |
---
|
|
|
548c8b |
m4/st_selinux.m4 | 36 ++++++++++++++++--------------------
|
|
|
548c8b |
1 file changed, 16 insertions(+), 20 deletions(-)
|
|
|
548c8b |
|
|
|
548c8b |
diff --git a/m4/st_selinux.m4 b/m4/st_selinux.m4
|
|
|
548c8b |
index da72a48..7b24eba 100644
|
|
|
548c8b |
--- a/m4/st_selinux.m4
|
|
|
548c8b |
+++ b/m4/st_selinux.m4
|
|
|
548c8b |
@@ -34,29 +34,25 @@ AS_IF([test "x$with_libselinux" != xno],
|
|
|
548c8b |
AS_IF([test "x$found_selinux_h" = xyes],
|
|
|
548c8b |
[saved_LDFLAGS="$LDFLAGS"
|
|
|
548c8b |
LDFLAGS="$LDFLAGS $libselinux_LDFLAGS"
|
|
|
548c8b |
- AC_CHECK_LIB([selinux],[getpidcon],
|
|
|
548c8b |
- [libselinux_LIBS="-lselinux"
|
|
|
548c8b |
- enable_secontext=yes
|
|
|
548c8b |
- ],
|
|
|
548c8b |
- [if test "x$with_libselinux" != xcheck; then
|
|
|
548c8b |
- AC_MSG_FAILURE([failed to find getpidcon in libselinux])
|
|
|
548c8b |
- fi
|
|
|
548c8b |
- ]
|
|
|
548c8b |
- )
|
|
|
548c8b |
- AC_CHECK_LIB([selinux],[getfilecon],
|
|
|
548c8b |
- [libselinux_LIBS="-lselinux"
|
|
|
548c8b |
- enable_secontext=yes
|
|
|
548c8b |
- ],
|
|
|
548c8b |
- [if test "x$with_libselinux" != xcheck; then
|
|
|
548c8b |
- AC_MSG_FAILURE([failed to find getfilecon in libselinux])
|
|
|
548c8b |
- fi
|
|
|
548c8b |
- ]
|
|
|
548c8b |
+ missing=
|
|
|
548c8b |
+ for func in getpidcon getfilecon; do
|
|
|
548c8b |
+ AC_CHECK_LIB([selinux], [$func], [:],
|
|
|
548c8b |
+ [missing="$missing $func"])
|
|
|
548c8b |
+ done
|
|
|
548c8b |
+ AS_IF([test "x$missing" = x],
|
|
|
548c8b |
+ [libselinux_LIBS="-lselinux"
|
|
|
548c8b |
+ enable_secontext=yes
|
|
|
548c8b |
+ ],
|
|
|
548c8b |
+ [AS_IF([test "x$with_libselinux" != xcheck],
|
|
|
548c8b |
+ [AC_MSG_FAILURE([failed to find in libselinux:$missing])]
|
|
|
548c8b |
+ )
|
|
|
548c8b |
+ ]
|
|
|
548c8b |
)
|
|
|
548c8b |
LDFLAGS="$saved_LDFLAGS"
|
|
|
548c8b |
],
|
|
|
548c8b |
- [if test "x$with_libselinux" != xcheck; then
|
|
|
548c8b |
- AC_MSG_FAILURE([failed to find selinux.h])
|
|
|
548c8b |
- fi
|
|
|
548c8b |
+ [AS_IF([test "x$with_libselinux" != xcheck],
|
|
|
548c8b |
+ [AC_MSG_FAILURE([failed to find selinux.h])]
|
|
|
548c8b |
+ )
|
|
|
548c8b |
]
|
|
|
548c8b |
)
|
|
|
548c8b |
]
|
|
|
548c8b |
--- old/configure 2022-02-07 20:17:58.364068436 +0100
|
|
|
548c8b |
+++ new/configure 2022-02-07 20:19:17.092067347 +0100
|
|
|
548c8b |
@@ -18437,9 +18437,12 @@
|
|
|
548c8b |
if test "x$found_selinux_h" = xyes; then :
|
|
|
548c8b |
saved_LDFLAGS="$LDFLAGS"
|
|
|
548c8b |
LDFLAGS="$LDFLAGS $libselinux_LDFLAGS"
|
|
|
548c8b |
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getpidcon in -lselinux" >&5
|
|
|
548c8b |
-$as_echo_n "checking for getpidcon in -lselinux... " >&6; }
|
|
|
548c8b |
-if ${ac_cv_lib_selinux_getpidcon+:} false; then :
|
|
|
548c8b |
+ missing=
|
|
|
548c8b |
+ for func in getpidcon getfilecon; do
|
|
|
548c8b |
+ as_ac_Lib=`$as_echo "ac_cv_lib_selinux_$func" | $as_tr_sh`
|
|
|
548c8b |
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $func in -lselinux" >&5
|
|
|
548c8b |
+$as_echo_n "checking for $func in -lselinux... " >&6; }
|
|
|
548c8b |
+if eval \${$as_ac_Lib+:} false; then :
|
|
|
548c8b |
$as_echo_n "(cached) " >&6
|
|
|
548c8b |
else
|
|
|
548c8b |
ac_check_lib_save_LIBS=$LIBS
|
|
|
548c8b |
@@ -18453,101 +18456,59 @@
|
|
|
548c8b |
#ifdef __cplusplus
|
|
|
548c8b |
extern "C"
|
|
|
548c8b |
#endif
|
|
|
548c8b |
-char getpidcon ();
|
|
|
548c8b |
+char $func ();
|
|
|
548c8b |
int
|
|
|
548c8b |
main ()
|
|
|
548c8b |
{
|
|
|
548c8b |
-return getpidcon ();
|
|
|
548c8b |
+return $func ();
|
|
|
548c8b |
;
|
|
|
548c8b |
return 0;
|
|
|
548c8b |
}
|
|
|
548c8b |
_ACEOF
|
|
|
548c8b |
if ac_fn_c_try_link "$LINENO"; then :
|
|
|
548c8b |
- ac_cv_lib_selinux_getpidcon=yes
|
|
|
548c8b |
+ eval "$as_ac_Lib=yes"
|
|
|
548c8b |
else
|
|
|
548c8b |
- ac_cv_lib_selinux_getpidcon=no
|
|
|
548c8b |
+ eval "$as_ac_Lib=no"
|
|
|
548c8b |
fi
|
|
|
548c8b |
rm -f core conftest.err conftest.$ac_objext \
|
|
|
548c8b |
conftest$ac_exeext conftest.$ac_ext
|
|
|
548c8b |
LIBS=$ac_check_lib_save_LIBS
|
|
|
548c8b |
fi
|
|
|
548c8b |
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_selinux_getpidcon" >&5
|
|
|
548c8b |
-$as_echo "$ac_cv_lib_selinux_getpidcon" >&6; }
|
|
|
548c8b |
-if test "x$ac_cv_lib_selinux_getpidcon" = xyes; then :
|
|
|
548c8b |
- libselinux_LIBS="-lselinux"
|
|
|
548c8b |
- enable_secontext=yes
|
|
|
548c8b |
-
|
|
|
548c8b |
+eval ac_res=\$$as_ac_Lib
|
|
|
548c8b |
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
|
|
|
548c8b |
+$as_echo "$ac_res" >&6; }
|
|
|
548c8b |
+if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then :
|
|
|
548c8b |
+ :
|
|
|
548c8b |
else
|
|
|
548c8b |
- if test "x$with_libselinux" != xcheck; then
|
|
|
548c8b |
- { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
|
|
|
548c8b |
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
|
|
|
548c8b |
-as_fn_error $? "failed to find getpidcon in libselinux
|
|
|
548c8b |
-See \`config.log' for more details" "$LINENO" 5; }
|
|
|
548c8b |
- fi
|
|
|
548c8b |
-
|
|
|
548c8b |
-
|
|
|
548c8b |
+ missing="$missing $func"
|
|
|
548c8b |
fi
|
|
|
548c8b |
|
|
|
548c8b |
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getfilecon in -lselinux" >&5
|
|
|
548c8b |
-$as_echo_n "checking for getfilecon in -lselinux... " >&6; }
|
|
|
548c8b |
-if ${ac_cv_lib_selinux_getfilecon+:} false; then :
|
|
|
548c8b |
- $as_echo_n "(cached) " >&6
|
|
|
548c8b |
-else
|
|
|
548c8b |
- ac_check_lib_save_LIBS=$LIBS
|
|
|
548c8b |
-LIBS="-lselinux $LIBS"
|
|
|
548c8b |
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
|
|
548c8b |
-/* end confdefs.h. */
|
|
|
548c8b |
-
|
|
|
548c8b |
-/* Override any GCC internal prototype to avoid an error.
|
|
|
548c8b |
- Use char because int might match the return type of a GCC
|
|
|
548c8b |
- builtin and then its argument prototype would still apply. */
|
|
|
548c8b |
-#ifdef __cplusplus
|
|
|
548c8b |
-extern "C"
|
|
|
548c8b |
-#endif
|
|
|
548c8b |
-char getfilecon ();
|
|
|
548c8b |
-int
|
|
|
548c8b |
-main ()
|
|
|
548c8b |
-{
|
|
|
548c8b |
-return getfilecon ();
|
|
|
548c8b |
- ;
|
|
|
548c8b |
- return 0;
|
|
|
548c8b |
-}
|
|
|
548c8b |
-_ACEOF
|
|
|
548c8b |
-if ac_fn_c_try_link "$LINENO"; then :
|
|
|
548c8b |
- ac_cv_lib_selinux_getfilecon=yes
|
|
|
548c8b |
-else
|
|
|
548c8b |
- ac_cv_lib_selinux_getfilecon=no
|
|
|
548c8b |
-fi
|
|
|
548c8b |
-rm -f core conftest.err conftest.$ac_objext \
|
|
|
548c8b |
- conftest$ac_exeext conftest.$ac_ext
|
|
|
548c8b |
-LIBS=$ac_check_lib_save_LIBS
|
|
|
548c8b |
-fi
|
|
|
548c8b |
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_selinux_getfilecon" >&5
|
|
|
548c8b |
-$as_echo "$ac_cv_lib_selinux_getfilecon" >&6; }
|
|
|
548c8b |
-if test "x$ac_cv_lib_selinux_getfilecon" = xyes; then :
|
|
|
548c8b |
+ done
|
|
|
548c8b |
+ if test "x$missing" = x; then :
|
|
|
548c8b |
libselinux_LIBS="-lselinux"
|
|
|
548c8b |
- enable_secontext=yes
|
|
|
548c8b |
+ enable_secontext=yes
|
|
|
548c8b |
|
|
|
548c8b |
else
|
|
|
548c8b |
- if test "x$with_libselinux" != xcheck; then
|
|
|
548c8b |
- { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
|
|
|
548c8b |
+ if test "x$with_libselinux" != xcheck; then :
|
|
|
548c8b |
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
|
|
|
548c8b |
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
|
|
|
548c8b |
-as_fn_error $? "failed to find getfilecon in libselinux
|
|
|
548c8b |
+as_fn_error $? "failed to find in libselinux:$missing
|
|
|
548c8b |
See \`config.log' for more details" "$LINENO" 5; }
|
|
|
548c8b |
- fi
|
|
|
548c8b |
-
|
|
|
548c8b |
|
|
|
548c8b |
fi
|
|
|
548c8b |
|
|
|
548c8b |
+
|
|
|
548c8b |
+fi
|
|
|
548c8b |
LDFLAGS="$saved_LDFLAGS"
|
|
|
548c8b |
|
|
|
548c8b |
else
|
|
|
548c8b |
- if test "x$with_libselinux" != xcheck; then
|
|
|
548c8b |
- { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
|
|
|
548c8b |
+ if test "x$with_libselinux" != xcheck; then :
|
|
|
548c8b |
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
|
|
|
548c8b |
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
|
|
|
548c8b |
as_fn_error $? "failed to find selinux.h
|
|
|
548c8b |
See \`config.log' for more details" "$LINENO" 5; }
|
|
|
548c8b |
- fi
|
|
|
548c8b |
+
|
|
|
548c8b |
+fi
|
|
|
548c8b |
|
|
|
548c8b |
|
|
|
548c8b |
fi
|
|
|
548c8b |
--
|
|
|
548c8b |
2.1.4
|
|
|
548c8b |
|