*/
ignore_value(virAsprintf(&opts,
- "mode=755,size=65536%s",(sec_mount_options ? sec_mount_options : "")));
+ "mode=755,size=65536%s", sec_mount_options));
if (!opts) {
virReportOOMError();
goto cleanup;
char *data = NULL;
if (virAsprintf(&data,
- "size=%lldk%s", fs->usage, (sec_mount_options ? sec_mount_options : "")) < 0) {
+ "size=%lldk%s", fs->usage, sec_mount_options) < 0) {
virReportOOMError();
goto cleanup;
}
}
if (virAsprintf(&opts,
- "mode=755,size=65536%s",(sec_mount_options ? sec_mount_options : "")) < 0) {
+ "mode=755,size=65536%s", sec_mount_options) < 0) {
virReportOOMError();
return -1;
}
if (lxcContainerResolveSymlinks(vmDef) < 0)
return -1;
- sec_mount_options = virSecurityManagerGetMountOptions(securityDriver, vmDef);
+ if (!(sec_mount_options = virSecurityManagerGetMountOptions(securityDriver, vmDef)))
+ return -1;
+
if (root && root->src)
rc = lxcContainerSetupPivotRoot(vmDef, root, ttyPaths, nttyPaths, sec_mount_options);
else
return 0;
}
+
+static char *
+AppArmorGetMountOptions(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
+ virDomainDefPtr vm ATTRIBUTE_UNUSED)
+{
+ char *opts;
+
+ if (!(opts = strdup(""))) {
+ virReportOOMError();
+ return NULL;
+ }
+ return opts;
+}
+
+
virSecurityDriver virAppArmorSecurityDriver = {
.privateDataLen = 0,
.name = SECURITY_APPARMOR_NAME,
.domainSetSecurityImageFDLabel = AppArmorSetImageFDLabel,
.domainSetSecurityTapFDLabel = AppArmorSetTapFDLabel,
+
+ .domainGetSecurityMountOptions = AppArmorGetMountOptions,
};
if (mgr->drv->domainGetSecurityMountOptions)
return mgr->drv->domainGetSecurityMountOptions(mgr, vm);
- /*
- I don't think this is an error, these should be optional
- virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
- */
+ virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
return NULL;
}
#include "security_nop.h"
+#include "virterror_internal.h"
+
+#define VIR_FROM_THIS VIR_FROM_SECURITY
+
static virSecurityDriverStatus virSecurityDriverProbeNop(const char *virtDriver ATTRIBUTE_UNUSED)
{
return SECURITY_DRIVER_ENABLE;
}
static char *virSecurityDomainGetMountOptionsNop(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
- virDomainDefPtr vm ATTRIBUTE_UNUSED) {
- return NULL;
+ virDomainDefPtr vm ATTRIBUTE_UNUSED)
+{
+ char *opts;
+
+ if (!(opts = strdup(""))) {
+ virReportOOMError();
+ return NULL;
+ }
+ return opts;
}
virSecurityDriver virSecurityDriverNop = {
char *opts = NULL;
virSecurityLabelDefPtr secdef;
- secdef = virDomainDefGetSecurityLabelDef(def, SECURITY_SELINUX_NAME);
- if (secdef == NULL)
- return NULL;
-
- if (! secdef->imagelabel)
- secdef->imagelabel = virSecuritySELinuxGenImageLabel(mgr,def);
+ if ((secdef = virDomainDefGetSecurityLabelDef(def, SECURITY_SELINUX_NAME))) {
+ if (!secdef->imagelabel)
+ secdef->imagelabel = virSecuritySELinuxGenImageLabel(mgr, def);
+
+ if (secdef->imagelabel &&
+ virAsprintf(&opts,
+ ",context=\"%s\"",
+ (const char*) secdef->imagelabel) < 0) {
+ virReportOOMError();
+ return NULL;
+ }
+ }
- if (secdef->imagelabel) {
- virAsprintf(&opts,
- ",context=\"%s\"",
- (const char*) secdef->imagelabel);
+ if (!opts &&
+ !(opts = strdup(""))) {
+ virReportOOMError();
+ return NULL;
}
- VIR_DEBUG("imageLabel=%s", secdef->imagelabel);
+ VIR_DEBUG("imageLabel=%s opts=%s", secdef->imagelabel, opts);
return opts;
}