Blob Blame History Raw
From b8f375c2c8140e759122bca3e3469386d3ba5184 Mon Sep 17 00:00:00 2001
From: "Dmitry V. Levin" <ldv@strace.io>
Date: Mon, 29 Nov 2021 08:00:00 +0000
Subject: [PATCH 168/174] m4: fix st_SELINUX check

* m4/st_selinux.m4: Make sure selinux support is enabled only if
all expected functions are provided by libselinux.

Fixes: v5.12~49 "Implement --secontext[=full] option to display SELinux contexts"
---
 m4/st_selinux.m4 | 36 ++++++++++++++++--------------------
 1 file changed, 16 insertions(+), 20 deletions(-)

diff --git a/m4/st_selinux.m4 b/m4/st_selinux.m4
index da72a48..7b24eba 100644
--- a/m4/st_selinux.m4
+++ b/m4/st_selinux.m4
@@ -34,29 +34,25 @@ AS_IF([test "x$with_libselinux" != xno],
        AS_IF([test "x$found_selinux_h" = xyes],
 	     [saved_LDFLAGS="$LDFLAGS"
 	      LDFLAGS="$LDFLAGS $libselinux_LDFLAGS"
-	      AC_CHECK_LIB([selinux],[getpidcon],
-		[libselinux_LIBS="-lselinux"
-		 enable_secontext=yes
-		],
-		[if test "x$with_libselinux" != xcheck; then
-		   AC_MSG_FAILURE([failed to find getpidcon in libselinux])
-		 fi
-		]
-	      )
-	      AC_CHECK_LIB([selinux],[getfilecon],
-		[libselinux_LIBS="-lselinux"
-		 enable_secontext=yes
-		],
-		[if test "x$with_libselinux" != xcheck; then
-		   AC_MSG_FAILURE([failed to find getfilecon in libselinux])
-		 fi
-		]
+	      missing=
+	      for func in getpidcon getfilecon; do
+		AC_CHECK_LIB([selinux], [$func], [:],
+			     [missing="$missing $func"])
+	      done
+	      AS_IF([test "x$missing" = x],
+	            [libselinux_LIBS="-lselinux"
+		     enable_secontext=yes
+		    ],
+		    [AS_IF([test "x$with_libselinux" != xcheck],
+			   [AC_MSG_FAILURE([failed to find in libselinux:$missing])]
+		     )
+		    ]
 	      )
 	      LDFLAGS="$saved_LDFLAGS"
 	     ],
-	     [if test "x$with_libselinux" != xcheck; then
-		AC_MSG_FAILURE([failed to find selinux.h])
-	      fi
+	     [AS_IF([test "x$with_libselinux" != xcheck],
+		    [AC_MSG_FAILURE([failed to find selinux.h])]
+	      )
 	     ]
        )
       ]
-- 
2.1.4