build: fix build with libselinux 2.3

Several function signatures changed in libselinux 2.3, now taking
a 'const char *' instead of 'security_context_t'.  The latter is
defined in selinux/selinux.h as

  typedef char *security_context_t;

Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
Cédric Bosdonnat
2014-05-28 14:44:08 +02:00
committed by Eric Blake
parent 0b317d61fc
commit 292d3f2d38
2 changed files with 32 additions and 1 deletions

View File

@@ -156,7 +156,11 @@ 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
{
if (!is_selinux_enabled()) {
errno = EINVAL;
@@ -165,13 +169,21 @@ 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
{
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
{
const char *constr = con;
if (STRPREFIX(path, abs_builddir "/securityselinuxlabeldata/nfs/")) {
@@ -182,7 +194,11 @@ 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
{
return setfilecon_raw(path, con);
}