Skip to content

Commit dc7c3d9

Browse files
committed
Skip python magic expectation on RHEL 8
RHEL 8 carries an older libmagic behavior for /usr/bin/python3 scripts. The file_type_detect_test expected text/x-script.python from the system magic database, but RHEL 8 reports text/x-python, which made the test fail even though that platform-specific result is acceptable for an old extended-support platform. Configure now detects RHEL 8 from /etc/os-release in a subshell and defines FAPOLICYD_RHEL8. Keeping the os-release variables contained matters because os-release also defines VERSION, and clobbering Automake's VERSION breaks make dist on newer Fedora hosts. The file type detection test includes config.h and skips only the full-python-usr-bin system-libmagic assertion when FAPOLICYD_RHEL8 is present, leaving the newer-platform expectation active everywhere else.
1 parent 8ed94ea commit dc7c3d9

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

configure.ac

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,31 @@ AM_INIT_AUTOMAKE(foreign subdir-objects)
1111
LT_INIT
1212
AC_SUBST(LIBTOOL_DEPS)
1313

14+
AC_MSG_CHECKING([whether build host is RHEL 8])
15+
fapolicyd_rhel8=no
16+
if test -r /etc/os-release; then
17+
fapolicyd_rhel8=`(
18+
. /etc/os-release
19+
if test "x$ID" = xrhel; then
20+
case "$VERSION_ID" in
21+
8|8.*)
22+
echo yes
23+
;;
24+
*)
25+
echo no
26+
;;
27+
esac
28+
else
29+
echo no
30+
fi
31+
)`
32+
fi
33+
AC_MSG_RESULT([$fapolicyd_rhel8])
34+
if test "x$fapolicyd_rhel8" = xyes; then
35+
AC_DEFINE([FAPOLICYD_RHEL8], [1],
36+
[Define if the build host is Red Hat Enterprise Linux 8])
37+
fi
38+
1439
echo .
1540
echo Checking for programs
1641
AC_PROG_CC

src/tests/file_type_detect_test.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
*/
44

55
#define _GNU_SOURCE
6+
#include "config.h"
7+
68
#include <errno.h>
79
#include <error.h>
810
#include <fcntl.h>
@@ -271,10 +273,17 @@ int main(void)
271273
"text/x-perl");
272274
close(fd);
273275

276+
#ifndef FAPOLICYD_RHEL8
277+
/*
278+
* RHEL 8 libmagic reports this as text/x-python. Keep the current
279+
* expectation for newer systems and drop this guard when RHEL 8
280+
* support is no longer needed.
281+
*/
274282
fd = create_tmp_file("#!/usr/bin/python3\nprint(1)\n");
275283
expect_magic_descriptor("full-python-usr-bin", magic_full, fd,
276284
"text/x-script.python");
277285
close(fd);
286+
#endif
278287

279288
fd = create_tmp_file("#!/usr/bin/R\nprint(1)\n");
280289
expect_magic_descriptor("full-r-usr-bin", magic_full, fd, "text/plain");

0 commit comments

Comments
 (0)