[PATCH] maint: cleanup detection of const'ness of selinux ctx

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit 292d3f2d fixed the build with libselinux 2.3, but missed
some suggestions by eblake

https://www.redhat.com/archives/libvir-list/2014-May/msg00977.html

This patch changes the macro introduced in 292d3f2d to either be
empty in the case of newer libselinux, or contain 'const' in the
case of older libselinux.  The macro is then used directly in
tests/securityselinuxhelper.c.
---
 m4/virt-selinux.m4            |    7 +++++--
 tests/securityselinuxhelper.c |   24 ++++--------------------
 2 files changed, 9 insertions(+), 22 deletions(-)

diff --git a/m4/virt-selinux.m4 b/m4/virt-selinux.m4
index 1d899d5..a6f89ba 100644
--- a/m4/virt-selinux.m4
+++ b/m4/virt-selinux.m4
@@ -39,8 +39,11 @@ int setcon(const security_context_t context);
          [gt_cv_setcon_param='security_context_t'],
          [gt_cv_setcon_param='const char*'])])
     if test "$gt_cv_setcon_param" = 'const char*'; then
-       AC_DEFINE_UNQUOTED([SELINUX_CTX_CHAR_PTR], 1,
-                          [SELinux uses newer char * for security context])
+       AC_DEFINE([VIR_SELINUX_CTX_CONST], [const],
+                          [SELinux uses newer const char * for security context])
+    else
+       AC_DEFINE([VIR_SELINUX_CTX_CONST], [],
+                          [SELinux uses newer const char * for security context])
     fi
 
     AC_MSG_CHECKING([SELinux mount point])
diff --git a/tests/securityselinuxhelper.c b/tests/securityselinuxhelper.c
index af4fae4..1252c15 100644
--- a/tests/securityselinuxhelper.c
+++ b/tests/securityselinuxhelper.c
@@ -156,11 +156,7 @@ int getpidcon(pid_t pid, security_context_t *context)
     return getpidcon_raw(pid, context);
 }
 
-#ifdef SELINUX_CTX_CHAR_PTR
-int setcon_raw(const char *context)
-#else
-int setcon_raw(security_context_t context)
-#endif
+int setcon_raw(VIR_SELINUX_CTX_CONST char *context)
 {
     if (!is_selinux_enabled()) {
         errno = EINVAL;
@@ -169,21 +165,13 @@ int setcon_raw(security_context_t context)
     return setenv("FAKE_SELINUX_CONTEXT", context, 1);
 }
 
-#ifdef SELINUX_CTX_CHAR_PTR
-int setcon(const char *context)
-#else
-int setcon(security_context_t context)
-#endif
+int setcon(VIR_SELINUX_CTX_CONST char *context)
 {
     return setcon_raw(context);
 }
 
 
-#ifdef SELINUX_CTX_CHAR_PTR
-int setfilecon_raw(const char *path, const char *con)
-#else
-int setfilecon_raw(const char *path, security_context_t con)
-#endif
+int setfilecon_raw(const char *path, VIR_SELINUX_CTX_CONST char *con)
 {
     const char *constr = con;
     if (STRPREFIX(path, abs_builddir "/securityselinuxlabeldata/nfs/")) {
@@ -194,11 +182,7 @@ int setfilecon_raw(const char *path, security_context_t con)
                     constr, strlen(constr), 0);
 }
 
-#ifdef SELINUX_CTX_CHAR_PTR
-int setfilecon(const char *path, const char *con)
-#else
-int setfilecon(const char *path, security_context_t con)
-#endif
+int setfilecon(const char *path, VIR_SELINUX_CTX_CONST char *con)
 {
     return setfilecon_raw(path, con);
 }
-- 
1.7.9.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]