From 7184af1364d08ff7036557abd5d2c99d1383faa2 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Mon, 14 Jan 2013 18:33:44 +0000 Subject: [PATCH] Add missing stubs to securityselinuxhelper.c Make sure we override both the raw and non-raw stubs in securityselinuxhelper.c. Also add diagnostics if securityselinuxlabeltest fails a test item --- tests/securityselinuxhelper.c | 27 +++++++++++++++++++++++++-- tests/securityselinuxlabeltest.c | 4 ++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/tests/securityselinuxhelper.c b/tests/securityselinuxhelper.c index daad7dd43f..abe4d7cc49 100644 --- a/tests/securityselinuxhelper.c +++ b/tests/securityselinuxhelper.c @@ -46,6 +46,11 @@ int getcon_raw(security_context_t *context) return 0; } +int getcon(security_context_t *context) +{ + return getcon_raw(context); +} + int getpidcon_raw(pid_t pid, security_context_t *context) { if (pid != getpid()) { @@ -63,22 +68,36 @@ int getpidcon_raw(pid_t pid, security_context_t *context) return 0; } +int getpidcon(pid_t pid, security_context_t *context) +{ + return getpidcon_raw(pid, context); +} + int setcon_raw(security_context_t context) { return setenv("FAKE_CONTEXT", context, 1); } +int setcon(security_context_t context) +{ + return setcon_raw(context); +} + #if WITH_ATTR -int setfilecon(const char *path, security_context_t con) +int setfilecon_raw(const char *path, security_context_t con) { const char *constr = con; return setxattr(path, "user.libvirt.selinux", constr, strlen(constr), 0); } +int setfilecon(const char *path, security_context_t con) +{ + return setfilecon_raw(path, con); +} -int getfilecon(const char *path, security_context_t *con) +int getfilecon_raw(const char *path, security_context_t *con) { char *constr = NULL; ssize_t len = getxattr(path, "user.libvirt.selinux", @@ -96,4 +115,8 @@ int getfilecon(const char *path, security_context_t *con) constr[len] = '\0'; return 0; } +int getfilecon(const char *path, security_context_t *con) +{ + return getfilecon_raw(path, con); +} #endif diff --git a/tests/securityselinuxlabeltest.c b/tests/securityselinuxlabeltest.c index b108860f23..c0bb09b5bc 100644 --- a/tests/securityselinuxlabeltest.c +++ b/tests/securityselinuxlabeltest.c @@ -300,6 +300,10 @@ cleanup: VIR_FREE(files[i].context); } VIR_FREE(files); + if (ret < 0 && virTestGetVerbose()) { + virErrorPtr err = virGetLastError(); + fprintf(stderr, "%s\n", err ? err->message : ""); + } return ret; }