mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
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:
@@ -46,6 +46,11 @@ int getcon_raw(security_context_t *context)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getcon(security_context_t *context)
|
||||||
|
{
|
||||||
|
return getcon_raw(context);
|
||||||
|
}
|
||||||
|
|
||||||
int getpidcon_raw(pid_t pid, security_context_t *context)
|
int getpidcon_raw(pid_t pid, security_context_t *context)
|
||||||
{
|
{
|
||||||
if (pid != getpid()) {
|
if (pid != getpid()) {
|
||||||
@@ -63,22 +68,36 @@ int getpidcon_raw(pid_t pid, security_context_t *context)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getpidcon(pid_t pid, security_context_t *context)
|
||||||
|
{
|
||||||
|
return getpidcon_raw(pid, context);
|
||||||
|
}
|
||||||
|
|
||||||
int setcon_raw(security_context_t context)
|
int setcon_raw(security_context_t context)
|
||||||
{
|
{
|
||||||
return setenv("FAKE_CONTEXT", context, 1);
|
return setenv("FAKE_CONTEXT", context, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int setcon(security_context_t context)
|
||||||
|
{
|
||||||
|
return setcon_raw(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#if WITH_ATTR
|
#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;
|
const char *constr = con;
|
||||||
return setxattr(path, "user.libvirt.selinux",
|
return setxattr(path, "user.libvirt.selinux",
|
||||||
constr, strlen(constr), 0);
|
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;
|
char *constr = NULL;
|
||||||
ssize_t len = getxattr(path, "user.libvirt.selinux",
|
ssize_t len = getxattr(path, "user.libvirt.selinux",
|
||||||
@@ -96,4 +115,8 @@ int getfilecon(const char *path, security_context_t *con)
|
|||||||
constr[len] = '\0';
|
constr[len] = '\0';
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
int getfilecon(const char *path, security_context_t *con)
|
||||||
|
{
|
||||||
|
return getfilecon_raw(path, con);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -300,6 +300,10 @@ cleanup:
|
|||||||
VIR_FREE(files[i].context);
|
VIR_FREE(files[i].context);
|
||||||
}
|
}
|
||||||
VIR_FREE(files);
|
VIR_FREE(files);
|
||||||
|
if (ret < 0 && virTestGetVerbose()) {
|
||||||
|
virErrorPtr err = virGetLastError();
|
||||||
|
fprintf(stderr, "%s\n", err ? err->message : "<unknown>");
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user