Skip to content

Commit

Permalink
m4: fix st_SELINUX check
Browse files Browse the repository at this point in the history
* 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"
  • Loading branch information
ldv-alt committed Nov 29, 2021
1 parent 09e7903 commit 0532bfb
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions m4/st_selinux.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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])]
)
]
)
]
Expand Down

0 comments on commit 0532bfb

Please sign in to comment.