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
This commit is contained in:
Daniel P. Berrange 2013-01-14 18:33:44 +00:00
parent 688b3ecfe9
commit 7184af1364
2 changed files with 29 additions and 2 deletions

View File

@ -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

View File

@ -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 : "<unknown>");
}
return ret;
}