]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
maint: cleanup detection of const'ness of selinux ctx
authorJim Fehlig <jfehlig@suse.com>
Wed, 28 May 2014 19:48:21 +0000 (13:48 -0600)
committerEric Blake <eblake@redhat.com>
Tue, 23 Dec 2014 18:23:00 +0000 (11:23 -0700)
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.

(cherry picked from commit b109c097654c4fe003e8535481191f37a35d5d7b)

Conflicts:
tests/securityselinuxhelper.c - context: no commit 95577af

m4/virt-selinux.m4
tests/securityselinuxhelper.c

index dff1c2813e5da0e208f06ac6575f9a2bed180bee..f4fc9e2d8e6f98ef81820ed8cc051156f4e965c4 100644 (file)
@@ -28,19 +28,18 @@ AC_DEFUN([LIBVIRT_CHECK_SELINUX],[
 
   if test "$with_selinux" = "yes"; then
     # libselinux changed signatures between 2.2 and 2.3
-    AC_CACHE_CHECK([for selinux setcon parameter type], [gt_cv_setcon_param],
+    AC_CACHE_CHECK([for selinux setcon parameter type], [lv_cv_setcon_param],
     [AC_COMPILE_IFELSE(
       [AC_LANG_PROGRAM(
          [[
 #include <selinux/selinux.h>
-int setcon(const security_context_t context);
+int setcon(char *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])
-    fi
+         [lv_cv_setcon_const=''],
+         [lv_cv_setcon_const='const'])])
+    AC_DEFINE_UNQUOTED([VIR_SELINUX_CTX_CONST], [$lv_cv_setcon_const],
+      [Define to empty or 'const' depending on how SELinux qualifies its
+       security context parameters])
 
     AC_MSG_CHECKING([SELinux mount point])
     if test "$with_selinux_mount" = "check" || test -z "$with_selinux_mount"; then
index b10167afbcea72534ce83a06e027b0fe6c1fd94b..58f847b0acc92a335201784223fe480706e8eb82 100644 (file)
@@ -72,42 +72,26 @@ 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)
 {
     return setenv("FAKE_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);
 }
 
 
 #if WITH_ATTR
-# 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;
     return setxattr(path, "user.libvirt.selinux",
                     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);
 }