mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-08 22:15:21 +00:00
selinux: convert to typesafe virConf accessors
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
740e4d7052
commit
b9c8af4d71
@ -400,9 +400,6 @@ virSecuritySELinuxGenNewContext(const char *basecontext,
|
|||||||
static int
|
static int
|
||||||
virSecuritySELinuxLXCInitialize(virSecurityManagerPtr mgr)
|
virSecuritySELinuxLXCInitialize(virSecurityManagerPtr mgr)
|
||||||
{
|
{
|
||||||
virConfValuePtr scon = NULL;
|
|
||||||
virConfValuePtr tcon = NULL;
|
|
||||||
virConfValuePtr dcon = NULL;
|
|
||||||
virConfPtr selinux_conf;
|
virConfPtr selinux_conf;
|
||||||
virSecuritySELinuxDataPtr data = virSecurityManagerGetPrivateData(mgr);
|
virSecuritySELinuxDataPtr data = virSecurityManagerGetPrivateData(mgr);
|
||||||
|
|
||||||
@ -420,35 +417,36 @@ virSecuritySELinuxLXCInitialize(virSecurityManagerPtr mgr)
|
|||||||
if (!(selinux_conf = virConfReadFile(selinux_lxc_contexts_path(), 0)))
|
if (!(selinux_conf = virConfReadFile(selinux_lxc_contexts_path(), 0)))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
scon = virConfGetValue(selinux_conf, "process");
|
if (virConfGetValueString(selinux_conf, "process", &data->domain_context) < 0)
|
||||||
if (! scon || scon->type != VIR_CONF_STRING || (! scon->str)) {
|
goto error;
|
||||||
virReportSystemError(errno,
|
|
||||||
_("cannot read 'process' value from selinux lxc contexts file '%s'"),
|
if (!data->domain_context) {
|
||||||
selinux_lxc_contexts_path());
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("missing 'process' value in selinux lxc contexts file '%s'"),
|
||||||
|
selinux_lxc_contexts_path());
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
tcon = virConfGetValue(selinux_conf, "file");
|
if (virConfGetValueString(selinux_conf, "file", &data->file_context) < 0)
|
||||||
if (! tcon || tcon->type != VIR_CONF_STRING || (! tcon->str)) {
|
goto error;
|
||||||
virReportSystemError(errno,
|
|
||||||
_("cannot read 'file' value from selinux lxc contexts file '%s'"),
|
if (!data->file_context) {
|
||||||
selinux_lxc_contexts_path());
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("missing 'file' value in selinux lxc contexts file '%s'"),
|
||||||
|
selinux_lxc_contexts_path());
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
dcon = virConfGetValue(selinux_conf, "content");
|
if (virConfGetValueString(selinux_conf, "content", &data->content_context) < 0)
|
||||||
if (! dcon || dcon->type != VIR_CONF_STRING || (! dcon->str)) {
|
goto error;
|
||||||
virReportSystemError(errno,
|
|
||||||
_("cannot read 'content' value from selinux lxc contexts file '%s'"),
|
if (!data->content_context) {
|
||||||
selinux_lxc_contexts_path());
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("missing 'content' value in selinux lxc contexts file '%s'"),
|
||||||
|
selinux_lxc_contexts_path());
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_STRDUP(data->domain_context, scon->str) < 0 ||
|
|
||||||
VIR_STRDUP(data->file_context, tcon->str) < 0 ||
|
|
||||||
VIR_STRDUP(data->content_context, dcon->str) < 0)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
if (!(data->mcs = virHashCreate(10, NULL)))
|
if (!(data->mcs = virHashCreate(10, NULL)))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user