]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: don't use deprecated security_context_t
authorKarel Zak <kzak@redhat.com>
Mon, 14 Dec 2020 14:44:59 +0000 (15:44 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 14 Dec 2020 14:54:08 +0000 (15:54 +0100)
libselinux >= 3.1 makes security_context_t type deprecated. Let's
ifdef it to avoid unwanted warnings.

Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/optstr.c
sys-utils/mount.c

index 68b7bc383e527f84caba6a067a938a1f79cca503..be0c3ee8a2464916d381946bad87bd32b4413d89 100644 (file)
@@ -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));
index 65ac20b5bb45d26eb4e799f23c1e426d0c306bf8..225b01c2c70d0f0b3545a9be0e01a48552c782c3 100644 (file)
@@ -312,14 +312,18 @@ static void success_message(struct libmnt_context *cxt)
 }
 
 #if defined(HAVE_LIBSELINUX) && defined(HAVE_SECURITY_GET_INITIAL_CONTEXT)
-#include <selinux/selinux.h>
-#include <selinux/context.h>
+# include <selinux/selinux.h>
+# include <selinux/context.h>
 
 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) {