mirror of https://gitee.com/openkylin/libvirt.git
Replace use of virSecurityReportError with virReportError
Update the security drivers to use virReportError instead of the virSecurityReportError custom macro Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
0653554bc5
commit
b8605b22e5
1
cfg.mk
1
cfg.mk
|
@ -530,7 +530,6 @@ msg_gen_function += virRaiseError
|
|||
msg_gen_function += virReportError
|
||||
msg_gen_function += virReportErrorHelper
|
||||
msg_gen_function += virReportSystemError
|
||||
msg_gen_function += virSecurityReportError
|
||||
msg_gen_function += virXenError
|
||||
msg_gen_function += virXenInotifyError
|
||||
msg_gen_function += virXenStoreError
|
||||
|
|
|
@ -238,7 +238,7 @@ use_apparmor(void)
|
|||
char *libvirt_daemon = NULL;
|
||||
|
||||
if (virFileResolveLink("/proc/self/exe", &libvirt_daemon) < 0) {
|
||||
virSecurityReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("could not find libvirtd"));
|
||||
return rc;
|
||||
}
|
||||
|
@ -275,7 +275,7 @@ reload_profile(virSecurityManagerPtr mgr,
|
|||
/* Update the profile only if it is loaded */
|
||||
if (profile_loaded(secdef->imagelabel) >= 0) {
|
||||
if (load_profile(mgr, secdef->imagelabel, def, fn, append) < 0) {
|
||||
virSecurityReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("cannot update AppArmor profile "
|
||||
"\'%s\'"),
|
||||
secdef->imagelabel);
|
||||
|
@ -299,7 +299,7 @@ AppArmorSetSecurityUSBLabel(usbDevice *dev ATTRIBUTE_UNUSED,
|
|||
|
||||
if (reload_profile(ptr->mgr, def, file, true) < 0) {
|
||||
const virSecurityLabelDefPtr secdef = &def->seclabel;
|
||||
virSecurityReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("cannot update AppArmor profile "
|
||||
"\'%s\'"),
|
||||
secdef->imagelabel);
|
||||
|
@ -317,7 +317,7 @@ AppArmorSetSecurityPCILabel(pciDevice *dev ATTRIBUTE_UNUSED,
|
|||
|
||||
if (reload_profile(ptr->mgr, def, file, true) < 0) {
|
||||
const virSecurityLabelDefPtr secdef = &def->seclabel;
|
||||
virSecurityReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("cannot update AppArmor profile "
|
||||
"\'%s\'"),
|
||||
secdef->imagelabel);
|
||||
|
@ -347,7 +347,7 @@ AppArmorSecurityManagerProbe(const char *virtDriver)
|
|||
}
|
||||
|
||||
if (!virFileExists(template)) {
|
||||
virSecurityReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("template \'%s\' does not exist"), template);
|
||||
goto clean;
|
||||
}
|
||||
|
@ -403,14 +403,14 @@ AppArmorGenSecurityLabel(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
|
|||
return 0;
|
||||
|
||||
if (def->seclabel.baselabel) {
|
||||
virSecurityReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
"%s", _("Cannot set a base label with AppArmour"));
|
||||
return rc;
|
||||
}
|
||||
|
||||
if ((def->seclabel.label) ||
|
||||
(def->seclabel.model) || (def->seclabel.imagelabel)) {
|
||||
virSecurityReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s",
|
||||
_("security label already defined for VM"));
|
||||
return rc;
|
||||
|
@ -441,7 +441,7 @@ AppArmorGenSecurityLabel(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
|
|||
|
||||
/* Now that we have a label, load the profile into the kernel. */
|
||||
if (load_profile(mgr, def->seclabel.label, def, NULL, false) < 0) {
|
||||
virSecurityReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("cannot load AppArmor profile "
|
||||
"\'%s\'"), def->seclabel.label);
|
||||
goto err;
|
||||
|
@ -493,13 +493,13 @@ AppArmorGetSecurityProcessLabel(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
|
|||
|
||||
if (virStrcpy(sec->label, profile_name,
|
||||
VIR_SECURITY_LABEL_BUFLEN) == NULL) {
|
||||
virSecurityReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("error copying profile name"));
|
||||
goto clean;
|
||||
}
|
||||
|
||||
if ((sec->enforcing = profile_status(profile_name, 1)) < 0) {
|
||||
virSecurityReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("error calling profile_status()"));
|
||||
goto clean;
|
||||
}
|
||||
|
@ -538,7 +538,7 @@ AppArmorRestoreSecurityAllLabel(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
|
|||
|
||||
if (secdef->type == VIR_DOMAIN_SECLABEL_DYNAMIC) {
|
||||
if ((rc = remove_profile(secdef->label)) != 0) {
|
||||
virSecurityReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("could not remove profile for \'%s\'"),
|
||||
secdef->label);
|
||||
}
|
||||
|
@ -560,7 +560,7 @@ AppArmorSetSecurityProcessLabel(virSecurityManagerPtr mgr, virDomainDefPtr def)
|
|||
return rc;
|
||||
|
||||
if (STRNEQ(virSecurityManagerGetModel(mgr), secdef->model)) {
|
||||
virSecurityReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("security label driver mismatch: "
|
||||
"\'%s\' model configured for domain, but "
|
||||
"hypervisor driver is \'%s\'."),
|
||||
|
@ -570,7 +570,7 @@ AppArmorSetSecurityProcessLabel(virSecurityManagerPtr mgr, virDomainDefPtr def)
|
|||
}
|
||||
|
||||
if (aa_change_profile(profile_name) < 0) {
|
||||
virSecurityReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("error calling aa_change_profile()"));
|
||||
goto clean;
|
||||
}
|
||||
|
@ -634,7 +634,7 @@ AppArmorSetSecurityImageLabel(virSecurityManagerPtr mgr,
|
|||
if (secdef->imagelabel) {
|
||||
/* if the device doesn't exist, error out */
|
||||
if (!virFileExists(disk->src)) {
|
||||
virSecurityReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("\'%s\' does not exist"), disk->src);
|
||||
return rc;
|
||||
}
|
||||
|
@ -646,7 +646,7 @@ AppArmorSetSecurityImageLabel(virSecurityManagerPtr mgr,
|
|||
if (profile_loaded(secdef->imagelabel) >= 0) {
|
||||
if (load_profile(mgr, secdef->imagelabel, def, disk->src,
|
||||
false) < 0) {
|
||||
virSecurityReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("cannot update AppArmor profile "
|
||||
"\'%s\'"),
|
||||
secdef->imagelabel);
|
||||
|
@ -670,7 +670,7 @@ AppArmorSecurityVerify(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
|
|||
|
||||
if (secdef->type == VIR_DOMAIN_SECLABEL_STATIC) {
|
||||
if (use_apparmor() < 0 || profile_status(secdef->label, 0) < 0) {
|
||||
virSecurityReportError(VIR_ERR_XML_ERROR,
|
||||
virReportError(VIR_ERR_XML_ERROR,
|
||||
_("Invalid security label \'%s\'"),
|
||||
secdef->label);
|
||||
return -1;
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
|
||||
#include "security_nop.h"
|
||||
|
||||
#define VIR_FROM_THIS VIR_FROM_SECURITY
|
||||
|
||||
static virSecurityDriverPtr security_drivers[] = {
|
||||
#ifdef WITH_SECDRIVER_SELINUX
|
||||
&virSecurityDriverSELinux,
|
||||
|
@ -69,7 +71,7 @@ virSecurityDriverPtr virSecurityDriverLookup(const char *name,
|
|||
}
|
||||
|
||||
if (!drv) {
|
||||
virSecurityReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Security driver %s not found"),
|
||||
NULLSTR(name));
|
||||
return NULL;
|
||||
|
|
|
@ -125,7 +125,7 @@ virSecurityManagerPtr virSecurityManagerNew(const char *name,
|
|||
/* driver "none" needs some special handling of *Confined bools */
|
||||
if (STREQ(drv->name, "none")) {
|
||||
if (requireConfined) {
|
||||
virSecurityReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("Security driver \"none\" cannot create confined guests"));
|
||||
return NULL;
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ virSecurityManagerGetDOI(virSecurityManagerPtr mgr)
|
|||
if (mgr->drv->getDOI)
|
||||
return mgr->drv->getDOI(mgr);
|
||||
|
||||
virSecurityReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -190,7 +190,7 @@ virSecurityManagerGetModel(virSecurityManagerPtr mgr)
|
|||
if (mgr->drv->getModel)
|
||||
return mgr->drv->getModel(mgr);
|
||||
|
||||
virSecurityReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -216,7 +216,7 @@ int virSecurityManagerRestoreImageLabel(virSecurityManagerPtr mgr,
|
|||
if (mgr->drv->domainRestoreSecurityImageLabel)
|
||||
return mgr->drv->domainRestoreSecurityImageLabel(mgr, vm, disk);
|
||||
|
||||
virSecurityReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -226,7 +226,7 @@ int virSecurityManagerSetDaemonSocketLabel(virSecurityManagerPtr mgr,
|
|||
if (mgr->drv->domainSetSecurityDaemonSocketLabel)
|
||||
return mgr->drv->domainSetSecurityDaemonSocketLabel(mgr, vm);
|
||||
|
||||
virSecurityReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -236,7 +236,7 @@ int virSecurityManagerSetSocketLabel(virSecurityManagerPtr mgr,
|
|||
if (mgr->drv->domainSetSecuritySocketLabel)
|
||||
return mgr->drv->domainSetSecuritySocketLabel(mgr, vm);
|
||||
|
||||
virSecurityReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -246,7 +246,7 @@ int virSecurityManagerClearSocketLabel(virSecurityManagerPtr mgr,
|
|||
if (mgr->drv->domainClearSecuritySocketLabel)
|
||||
return mgr->drv->domainClearSecuritySocketLabel(mgr, vm);
|
||||
|
||||
virSecurityReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -257,7 +257,7 @@ int virSecurityManagerSetImageLabel(virSecurityManagerPtr mgr,
|
|||
if (mgr->drv->domainSetSecurityImageLabel)
|
||||
return mgr->drv->domainSetSecurityImageLabel(mgr, vm, disk);
|
||||
|
||||
virSecurityReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -268,7 +268,7 @@ int virSecurityManagerRestoreHostdevLabel(virSecurityManagerPtr mgr,
|
|||
if (mgr->drv->domainRestoreSecurityHostdevLabel)
|
||||
return mgr->drv->domainRestoreSecurityHostdevLabel(mgr, vm, dev);
|
||||
|
||||
virSecurityReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -279,7 +279,7 @@ int virSecurityManagerSetHostdevLabel(virSecurityManagerPtr mgr,
|
|||
if (mgr->drv->domainSetSecurityHostdevLabel)
|
||||
return mgr->drv->domainSetSecurityHostdevLabel(mgr, vm, dev);
|
||||
|
||||
virSecurityReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -290,7 +290,7 @@ int virSecurityManagerSetSavedStateLabel(virSecurityManagerPtr mgr,
|
|||
if (mgr->drv->domainSetSavedStateLabel)
|
||||
return mgr->drv->domainSetSavedStateLabel(mgr, vm, savefile);
|
||||
|
||||
virSecurityReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -301,7 +301,7 @@ int virSecurityManagerRestoreSavedStateLabel(virSecurityManagerPtr mgr,
|
|||
if (mgr->drv->domainRestoreSavedStateLabel)
|
||||
return mgr->drv->domainRestoreSavedStateLabel(mgr, vm, savefile);
|
||||
|
||||
virSecurityReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -317,7 +317,7 @@ int virSecurityManagerGenLabel(virSecurityManagerPtr mgr,
|
|||
|
||||
if ((vm->seclabel.type == VIR_DOMAIN_SECLABEL_NONE) &&
|
||||
mgr->requireConfined) {
|
||||
virSecurityReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("Unconfined guests are not allowed on this host"));
|
||||
return -1;
|
||||
}
|
||||
|
@ -325,7 +325,7 @@ int virSecurityManagerGenLabel(virSecurityManagerPtr mgr,
|
|||
if (mgr->drv->domainGenSecurityLabel)
|
||||
return mgr->drv->domainGenSecurityLabel(mgr, vm);
|
||||
|
||||
virSecurityReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -336,7 +336,7 @@ int virSecurityManagerReserveLabel(virSecurityManagerPtr mgr,
|
|||
if (mgr->drv->domainReserveSecurityLabel)
|
||||
return mgr->drv->domainReserveSecurityLabel(mgr, vm, pid);
|
||||
|
||||
virSecurityReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -346,7 +346,7 @@ int virSecurityManagerReleaseLabel(virSecurityManagerPtr mgr,
|
|||
if (mgr->drv->domainReleaseSecurityLabel)
|
||||
return mgr->drv->domainReleaseSecurityLabel(mgr, vm);
|
||||
|
||||
virSecurityReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -357,7 +357,7 @@ int virSecurityManagerSetAllLabel(virSecurityManagerPtr mgr,
|
|||
if (mgr->drv->domainSetSecurityAllLabel)
|
||||
return mgr->drv->domainSetSecurityAllLabel(mgr, vm, stdin_path);
|
||||
|
||||
virSecurityReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -368,7 +368,7 @@ int virSecurityManagerRestoreAllLabel(virSecurityManagerPtr mgr,
|
|||
if (mgr->drv->domainRestoreSecurityAllLabel)
|
||||
return mgr->drv->domainRestoreSecurityAllLabel(mgr, vm, migrated);
|
||||
|
||||
virSecurityReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -380,7 +380,7 @@ int virSecurityManagerGetProcessLabel(virSecurityManagerPtr mgr,
|
|||
if (mgr->drv->domainGetSecurityProcessLabel)
|
||||
return mgr->drv->domainGetSecurityProcessLabel(mgr, vm, pid, sec);
|
||||
|
||||
virSecurityReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -390,7 +390,7 @@ int virSecurityManagerSetProcessLabel(virSecurityManagerPtr mgr,
|
|||
if (mgr->drv->domainSetSecurityProcessLabel)
|
||||
return mgr->drv->domainSetSecurityProcessLabel(mgr, vm);
|
||||
|
||||
virSecurityReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -408,7 +408,7 @@ int virSecurityManagerVerify(virSecurityManagerPtr mgr,
|
|||
if (mgr->drv->domainSecurityVerify)
|
||||
return mgr->drv->domainSecurityVerify(mgr, def);
|
||||
|
||||
virSecurityReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -419,7 +419,7 @@ int virSecurityManagerSetImageFDLabel(virSecurityManagerPtr mgr,
|
|||
if (mgr->drv->domainSetSecurityImageFDLabel)
|
||||
return mgr->drv->domainSetSecurityImageFDLabel(mgr, vm, fd);
|
||||
|
||||
virSecurityReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -431,7 +431,7 @@ char *virSecurityManagerGetMountOptions(virSecurityManagerPtr mgr,
|
|||
|
||||
/*
|
||||
I don't think this is an error, these should be optional
|
||||
virSecurityReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
*/
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -23,11 +23,6 @@
|
|||
#ifndef VIR_SECURITY_MANAGER_H__
|
||||
# define VIR_SECURITY_MANAGER_H__
|
||||
|
||||
# define virSecurityReportError(code, ...) \
|
||||
virReportErrorHelper(VIR_FROM_SECURITY, code, __FILE__, \
|
||||
__FUNCTION__, __LINE__, __VA_ARGS__)
|
||||
|
||||
|
||||
typedef struct _virSecurityManager virSecurityManager;
|
||||
typedef virSecurityManager *virSecurityManagerPtr;
|
||||
|
||||
|
|
|
@ -277,27 +277,27 @@ SELinuxGenSecurityLabel(virSecurityManagerPtr mgr,
|
|||
if ((def->seclabel.type == VIR_DOMAIN_SECLABEL_DYNAMIC) &&
|
||||
!def->seclabel.baselabel &&
|
||||
def->seclabel.model) {
|
||||
virSecurityReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("security model already defined for VM"));
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (def->seclabel.type == VIR_DOMAIN_SECLABEL_DYNAMIC &&
|
||||
def->seclabel.label) {
|
||||
virSecurityReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("security label already defined for VM"));
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (def->seclabel.imagelabel) {
|
||||
virSecurityReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("security image label already defined for VM"));
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (def->seclabel.model &&
|
||||
STRNEQ(def->seclabel.model, SECURITY_SELINUX_NAME)) {
|
||||
virSecurityReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("security label model %s is not supported with selinux"),
|
||||
def->seclabel.model);
|
||||
return rc;
|
||||
|
@ -350,7 +350,7 @@ SELinuxGenSecurityLabel(virSecurityManagerPtr mgr,
|
|||
def->seclabel.baselabel :
|
||||
data->domain_context, mcs);
|
||||
if (! def->seclabel.label) {
|
||||
virSecurityReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("cannot generate selinux context for %s"), mcs);
|
||||
goto cleanup;
|
||||
}
|
||||
|
@ -361,7 +361,7 @@ SELinuxGenSecurityLabel(virSecurityManagerPtr mgr,
|
|||
break;
|
||||
|
||||
default:
|
||||
virSecurityReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("unexpected security label type '%s'"),
|
||||
virDomainSeclabelTypeToString(def->seclabel.type));
|
||||
goto cleanup;
|
||||
|
@ -370,7 +370,7 @@ SELinuxGenSecurityLabel(virSecurityManagerPtr mgr,
|
|||
if (!def->seclabel.norelabel) {
|
||||
def->seclabel.imagelabel = SELinuxGenNewContext(data->file_context, mcs);
|
||||
if (!def->seclabel.imagelabel) {
|
||||
virSecurityReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("cannot generate selinux context for %s"), mcs);
|
||||
goto cleanup;
|
||||
}
|
||||
|
@ -517,7 +517,7 @@ SELinuxGetSecurityProcessLabel(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
|
|||
}
|
||||
|
||||
if (strlen((char *) ctx) >= VIR_SECURITY_LABEL_BUFLEN) {
|
||||
virSecurityReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("security label exceeds "
|
||||
"maximum length: %d"),
|
||||
VIR_SECURITY_LABEL_BUFLEN - 1);
|
||||
|
@ -1106,7 +1106,7 @@ SELinuxRestoreSecuritySmartcardCallback(virDomainDefPtr def,
|
|||
return SELinuxRestoreSecurityChardevLabel(def, &dev->data.passthru);
|
||||
|
||||
default:
|
||||
virSecurityReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("unknown smartcard type %d"),
|
||||
dev->type);
|
||||
return -1;
|
||||
|
@ -1225,7 +1225,7 @@ SELinuxSecurityVerify(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
|
|||
{
|
||||
const virSecurityLabelDefPtr secdef = &def->seclabel;
|
||||
if (!STREQ(virSecurityManagerGetModel(mgr), secdef->model)) {
|
||||
virSecurityReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("security label driver mismatch: "
|
||||
"'%s' model configured for domain, but "
|
||||
"hypervisor driver is '%s'."),
|
||||
|
@ -1235,7 +1235,7 @@ SELinuxSecurityVerify(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
|
|||
|
||||
if (secdef->type == VIR_DOMAIN_SECLABEL_STATIC) {
|
||||
if (security_check_context(secdef->label) != 0) {
|
||||
virSecurityReportError(VIR_ERR_XML_ERROR,
|
||||
virReportError(VIR_ERR_XML_ERROR,
|
||||
_("Invalid security label %s"), secdef->label);
|
||||
return -1;
|
||||
}
|
||||
|
@ -1255,7 +1255,7 @@ SELinuxSetSecurityProcessLabel(virSecurityManagerPtr mgr,
|
|||
return 0;
|
||||
|
||||
if (!STREQ(virSecurityManagerGetModel(mgr), secdef->model)) {
|
||||
virSecurityReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("security label driver mismatch: "
|
||||
"'%s' model configured for domain, but "
|
||||
"hypervisor driver is '%s'."),
|
||||
|
@ -1290,7 +1290,7 @@ SELinuxSetSecurityDaemonSocketLabel(virSecurityManagerPtr mgr,
|
|||
return 0;
|
||||
|
||||
if (!STREQ(virSecurityManagerGetModel(mgr), secdef->model)) {
|
||||
virSecurityReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("security label driver mismatch: "
|
||||
"'%s' model configured for domain, but "
|
||||
"hypervisor driver is '%s'."),
|
||||
|
@ -1357,7 +1357,7 @@ SELinuxSetSecuritySocketLabel(virSecurityManagerPtr mgr,
|
|||
return 0;
|
||||
|
||||
if (!STREQ(virSecurityManagerGetModel(mgr), secdef->model)) {
|
||||
virSecurityReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("security label driver mismatch: "
|
||||
"'%s' model configured for domain, but "
|
||||
"hypervisor driver is '%s'."),
|
||||
|
@ -1394,7 +1394,7 @@ SELinuxClearSecuritySocketLabel(virSecurityManagerPtr mgr,
|
|||
return 0;
|
||||
|
||||
if (!STREQ(virSecurityManagerGetModel(mgr), secdef->model)) {
|
||||
virSecurityReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("security label driver mismatch: "
|
||||
"'%s' model configured for domain, but "
|
||||
"hypervisor driver is '%s'."),
|
||||
|
@ -1451,7 +1451,7 @@ SELinuxSetSecuritySmartcardCallback(virDomainDefPtr def,
|
|||
return SELinuxSetSecurityChardevLabel(def, &dev->data.passthru);
|
||||
|
||||
default:
|
||||
virSecurityReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("unknown smartcard type %d"),
|
||||
dev->type);
|
||||
return -1;
|
||||
|
|
Loading…
Reference in New Issue