From 8e764584fda9c153c1e1387b9f8fa2f2591c28ad Mon Sep 17 00:00:00 2001 From: Pádraig Brady Date: Tue, 1 Jul 2014 02:44:10 +0100 Subject: maint: fix const correctness warnings with security_context_t The security_context_t type was always an artificial separation from a standard char* string, and various libselinux using code assumed both were synonymous. In addition, prior to libselinux 2.3 function declarations were incorrect wrt constness of this type. Here we replace security_context_t with char*, and also provide a wrapper function to cater for the const issue on older libselinux. * src/system.h (se_const): A new function to avoid and identify the const issue on older libselinux. * src/copy.c: s/security_context_t/char */. * src/cp.c: Likewise. * src/id.c: Likewise. * src/install.c: Likewise. * src/ls.c: Likewise. * src/mkdir.c: Likewise. * src/mkfifo.c: Likewise. * src/mknod.c: Likewise. * src/runcon.c: Likewise. * src/selinux.c: Likewise. * tests/cp/no-ctx.sh: Likewise. * src/chcon.c: Likesize. --- src/system.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/system.h') diff --git a/src/system.h b/src/system.h index f295ad1c2..162446c11 100644 --- a/src/system.h +++ b/src/system.h @@ -657,3 +657,9 @@ stzncpy (char *restrict dest, char const *restrict src, size_t len) #ifndef ARRAY_CARDINALITY # define ARRAY_CARDINALITY(Array) (sizeof (Array) / sizeof *(Array)) #endif + +/* Avoid const warnings by casting to more portable type. + This is to cater for the incorrect const function declarations + in selinux.h before libselinux-2.3 (May 2014). + When version >= 2.3 is ubiquitous remove this function. */ +static inline char * se_const (char const * sctx) { return (char *) sctx; } -- cgit v1.2.3-54-g00ecf