From eba9ef598fd9fb9687e322a31b3396461320e7ef Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Mon, 14 Dec 2020 15:44:59 +0100 Subject: [PATCH] libmount: don't use deprecated security_context_t libselinux >= 3.1 makes security_context_t type deprecated. Let's ifdef it to avoid unwanted warnings. Signed-off-by: Karel Zak --- libmount/src/optstr.c | 12 ++++++++++-- sys-utils/mount.c | 10 +++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/libmount/src/optstr.c b/libmount/src/optstr.c index 68b7bc383e..be0c3ee8a2 100644 --- a/libmount/src/optstr.c +++ b/libmount/src/optstr.c @@ -871,8 +871,12 @@ int mnt_optstr_fix_secontext(char **optstr, char **next) { int rc = 0; +# ifdef HAVE_SELINUX_CONTEXT_T + security_context_t raw = NULL; /* deprecated */ +# else + char *raw = NULL; /* since libselinux >= 3.1 */ +# endif - security_context_t raw = NULL; char *p, *val, *begin, *end; size_t sz; @@ -898,7 +902,11 @@ int mnt_optstr_fix_secontext(char **optstr, /* translate the context */ - rc = selinux_trans_to_raw_context((security_context_t) p, &raw); + rc = selinux_trans_to_raw_context( +# ifdef HAVE_SELINUX_CONTEXT_T + (security_context_t) +# endif + p, &raw); DBG(CXT, ul_debug("SELinux context '%s' translated to '%s'", p, rc == -1 ? "FAILED" : (char *) raw)); diff --git a/sys-utils/mount.c b/sys-utils/mount.c index 65ac20b5bb..225b01c2c7 100644 --- a/sys-utils/mount.c +++ b/sys-utils/mount.c @@ -312,14 +312,18 @@ static void success_message(struct libmnt_context *cxt) } #if defined(HAVE_LIBSELINUX) && defined(HAVE_SECURITY_GET_INITIAL_CONTEXT) -#include -#include +# include +# include static void selinux_warning(struct libmnt_context *cxt, const char *tgt) { if (tgt && mnt_context_is_verbose(cxt) && is_selinux_enabled() > 0) { - security_context_t raw = NULL, def = NULL; +# ifdef HAVE_SELINUX_CONTEXT_T + security_context_t raw = NULL, def = NULL; /* deprecated */ +# else + char *raw = NULL, *def = NULL; /* since libselinux >= 3.1 */ +# endif if (getfilecon(tgt, &raw) > 0 && security_get_initial_context("file", &def) == 0) { -- 2.47.3