Blame SOURCES/0168-m4-fix-st_SELINUX-check.patch

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