summaryrefslogtreecommitdiff
path: root/utils.c
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2021-06-23 09:30:42 -0400
committerGitHub <noreply@github.com>2021-06-23 09:30:42 -0400
commitdca0a31f036139fb3b65b765da75a4ff6d7d0a89 (patch)
tree7acee0b80b4f7c3bb7957ad403c841e822610d5a /utils.c
parent136b3166bb8ea0d4e4e56d2c34c704ba69aa05d2 (diff)
parenteb48ee8347ee07be15f5ed08089a9ddfd6a906fb (diff)
downloadbubblewrap-dca0a31f036139fb3b65b765da75a4ff6d7d0a89.tar.gz
Merge pull request #429 from smcv/selinux-warnings
utils: Remove security_context_t casts for libselinux >= 2.3
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/utils.c b/utils.c
index 530552f..ea343df 100644
--- a/utils.c
+++ b/utils.c
@@ -24,6 +24,13 @@
#include <selinux/selinux.h>
#endif
+#ifndef HAVE_SELINUX_2_3
+/* libselinux older than 2.3 weren't const-correct */
+#define setexeccon(x) setexeccon ((security_context_t) x)
+#define setfscreatecon(x) setfscreatecon ((security_context_t) x)
+#define security_check_context(x) security_check_context ((security_context_t) x)
+#endif
+
void
die_with_error (const char *format, ...)
{
@@ -65,7 +72,7 @@ die_unless_label_valid (const char *label)
#ifdef HAVE_SELINUX
if (is_selinux_enabled () == 1)
{
- if (security_check_context ((security_context_t) label) < 0)
+ if (security_check_context (label) < 0)
die_with_error ("invalid label %s", label);
return;
}
@@ -853,7 +860,7 @@ label_create_file (const char *file_label)
{
#ifdef HAVE_SELINUX
if (is_selinux_enabled () > 0 && file_label)
- return setfscreatecon ((security_context_t) file_label);
+ return setfscreatecon (file_label);
#endif
return 0;
}
@@ -863,7 +870,7 @@ label_exec (const char *exec_label)
{
#ifdef HAVE_SELINUX
if (is_selinux_enabled () > 0 && exec_label)
- return setexeccon ((security_context_t) exec_label);
+ return setexeccon (exec_label);
#endif
return 0;
}