makedb: fix build with libselinux >= 3.1 (Bug 26233)
commitf278835f594740f5913001430641cf1da4878670
authorAurelien Jarno <aurelien@aurel32.net>
Sun, 11 Sep 2022 15:30:17 +0000 (11 11:30 -0400)
committerCarlos O'Donell <carlos@redhat.com>
Mon, 12 Sep 2022 22:26:49 +0000 (12 18:26 -0400)
tree3dac090e7414f49f06a94510e5c0b82c693f1ff9
parent1918241b55540536fee45b3096e786b7b7f9277a
makedb: fix build with libselinux >= 3.1 (Bug 26233)

glibc doesn't build with libselinux 3.1 that has been released recently
due to new deprecations introduced in that version and the fact that
glibc is built with -Werror by default:

| makedb.c: In function ‘set_file_creation_context’:
| makedb.c:849:3: error: ‘security_context_t’ is deprecated [-Werror=deprecated-declarations]
|   849 |   security_context_t ctx;
|       |   ^~~~~~~~~~~~~~~~~~
| makedb.c:863:3: error: ‘matchpathcon’ is deprecated: Use selabel_lookup instead [-Werror=deprecated-declarations]
|   863 |   if (matchpathcon (outname, S_IFREG | mode, &ctx) == 0 && ctx != NULL)
|       |   ^~
| In file included from makedb.c:50:
| /usr/include/selinux/selinux.h:500:12: note: declared here
|   500 | extern int matchpathcon(const char *path,
|       |            ^~~~~~~~~~~~
| cc1: all warnings being treated as errors

This patch fixes the makedb half of bug 26233 by moving to the new
SELinux APIs and removes the existing compiler pragmas as no longer
required. Upstream API usage feedback gathered by Arjun is integrated
into this version of the fix.

The built makedb was tested and operates as expected on x86_64 with
SELinu in enforcing mode.

No regressions on x86_64 with libselinux 3.3.

Co-authored-by: Arjun Shankar <arjun@redhat.com>
Co-authored-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
nss/makedb.c