virReportSystemError(errno,
_("Failed to read AppArmor profiles list "
"\'%s\'"), APPARMOR_PROFILES_PATH);
- goto clean;
+ goto cleanup;
}
if (strstr(content, tmp) != NULL)
}
VIR_FREE(content);
- clean:
+ cleanup:
VIR_FREE(tmp);
VIR_FREE(etmp);
_("cannot update AppArmor profile "
"\'%s\'"),
secdef->imagelabel);
- goto clean;
+ goto cleanup;
}
}
rc = 0;
- clean:
+ cleanup:
VIR_FREE(profile_name);
return rc;
if (!virFileExists(template)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("template \'%s\' does not exist"), template);
- goto clean;
+ goto cleanup;
}
rc = SECURITY_DRIVER_ENABLE;
- clean:
+ cleanup:
VIR_FREE(template);
return rc;
secdef->label = strndup(profile_name, strlen(profile_name));
if (!secdef->label) {
virReportOOMError();
- goto clean;
+ goto cleanup;
}
/* set imagelabel the same as label (but we won't use it) */
}
rc = 0;
- goto clean;
+ goto cleanup;
err:
VIR_FREE(secdef->label);
VIR_FREE(secdef->imagelabel);
VIR_FREE(secdef->model);
- clean:
+ cleanup:
VIR_FREE(profile_name);
return rc;
VIR_SECURITY_LABEL_BUFLEN) == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("error copying profile name"));
- goto clean;
+ goto cleanup;
}
if ((sec->enforcing = profile_status(profile_name, 1)) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("error calling profile_status()"));
- goto clean;
+ goto cleanup;
}
rc = 0;
- clean:
+ cleanup:
VIR_FREE(profile_name);
return rc;
"hypervisor driver is \'%s\'."),
secdef->model, SECURITY_APPARMOR_NAME);
if (use_apparmor() > 0)
- goto clean;
+ goto cleanup;
}
if (aa_change_profile(profile_name) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("error calling aa_change_profile()"));
- goto clean;
+ goto cleanup;
}
rc = 0;
- clean:
+ cleanup:
VIR_FREE(profile_name);
return rc;
_("cannot update AppArmor profile "
"\'%s\'"),
secdef->imagelabel);
- goto clean;
+ goto cleanup;
}
}
}
rc = 0;
- clean:
+ cleanup:
VIR_FREE(profile_name);
return rc;
if (append && virFileExists(include_file)) {
if (virAsprintf(&pcontent, "%s%s", existing, included_files) == -1) {
vah_error(NULL, 0, _("could not allocate memory for profile"));
- goto clean;
+ goto cleanup;
}
} else {
if (virAsprintf(&pcontent, "%s%s", warning, included_files) == -1) {
vah_error(NULL, 0, _("could not allocate memory for profile"));
- goto clean;
+ goto cleanup;
}
}
plen = strlen(pcontent);
if (plen > MAX_FILE_LEN) {
vah_error(NULL, 0, _("invalid length for new profile"));
- goto clean;
+ goto cleanup;
}
/* only update the disk profile if it is different */
if (flen > 0 && flen == plen && STREQLEN(existing, pcontent, plen)) {
rc = 0;
- goto clean;
+ goto cleanup;
}
/* write the file */
if ((fd = open(include_file, O_CREAT | O_TRUNC | O_WRONLY, 0644)) == -1) {
vah_error(NULL, 0, _("failed to create include file"));
- goto clean;
+ goto cleanup;
}
if (safewrite(fd, pcontent, plen) < 0) { /* don't write the '\0' */
VIR_FORCE_CLOSE(fd);
vah_error(NULL, 0, _("failed to write to profile"));
- goto clean;
+ goto cleanup;
}
if (VIR_CLOSE(fd) != 0) {
vah_error(NULL, 0, _("failed to close or write to profile"));
- goto clean;
+ goto cleanup;
}
rc = 0;
- clean:
+ cleanup:
VIR_FREE(pcontent);
VIR_FREE(existing);
vah_error(NULL, 0, path);
vah_error(NULL, 0, _("skipped restricted file"));
}
- goto clean;
+ goto cleanup;
}
virBufferAsprintf(buf, " \"%s\" %s,\n", tmp, perms);
virBufferAsprintf(buf, " deny \"%s\" w,\n", tmp);
}
- clean:
+ cleanup:
VIR_FREE(tmp);
return rc;
/* add the pipe input */
if (virAsprintf(&pipe_in, "%s.in", path) == -1) {
vah_error(NULL, 0, _("could not allocate memory"));
- goto clean;
+ goto cleanup;
}
if (vah_add_file(buf, pipe_in, perms) != 0)
} else {
/* add the file */
if (vah_add_file(buf, path, perms) != 0)
- goto clean;
+ goto cleanup;
rc = 0;
}
- clean:
+ cleanup:
return rc;
}
if (STRNEQ(uuid, ctl->uuid)) {
vah_error(ctl, 0, _("given uuid does not match XML uuid"));
- goto clean;
+ goto cleanup;
}
for (i = 0; i < ctl->def->ndisks; i++) {
* careful than just ignoring them.
*/
if (virDomainDiskDefForeachPath(disk, true, add_file_path, &buf) < 0)
- goto clean;
+ goto cleanup;
}
for (i = 0; i < ctl->def->nserials; i++)
ctl->def->serials[i]->source.data.file.path,
"rw",
ctl->def->serials[i]->source.type) != 0)
- goto clean;
+ goto cleanup;
for (i = 0; i < ctl->def->nconsoles; i++)
if (ctl->def->consoles[i] &&
ctl->def->consoles[i]->source.data.file.path)
if (vah_add_file(&buf,
ctl->def->consoles[i]->source.data.file.path, "rw") != 0)
- goto clean;
+ goto cleanup;
for (i = 0 ; i < ctl->def->nparallels; i++)
if (ctl->def->parallels[i] &&
ctl->def->parallels[i]->source.data.file.path,
"rw",
ctl->def->parallels[i]->source.type) != 0)
- goto clean;
+ goto cleanup;
for (i = 0 ; i < ctl->def->nchannels; i++)
if (ctl->def->channels[i] &&
ctl->def->channels[i]->source.data.file.path,
"rw",
ctl->def->channels[i]->source.type) != 0)
- goto clean;
+ goto cleanup;
if (ctl->def->os.kernel)
if (vah_add_file(&buf, ctl->def->os.kernel, "r") != 0)
- goto clean;
+ goto cleanup;
if (ctl->def->os.initrd)
if (vah_add_file(&buf, ctl->def->os.initrd, "r") != 0)
- goto clean;
+ goto cleanup;
if (ctl->def->os.dtb)
if (vah_add_file(&buf, ctl->def->os.dtb, "r") != 0)
- goto clean;
+ goto cleanup;
if (ctl->def->os.loader && ctl->def->os.loader)
if (vah_add_file(&buf, ctl->def->os.loader, "r") != 0)
- goto clean;
+ goto cleanup;
for (i = 0; i < ctl->def->ngraphics; i++) {
if (ctl->def->graphics[i]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC &&
ctl->def->graphics[i]->data.vnc.socket &&
vah_add_file(&buf, ctl->def->graphics[i]->data.vnc.socket, "rw"))
- goto clean;
+ goto cleanup;
}
if (ctl->def->ngraphics == 1 &&
ctl->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_SDL)
if (vah_add_file(&buf, ctl->def->graphics[0]->data.sdl.xauth,
"r") != 0)
- goto clean;
+ goto cleanup;
for (i = 0; i < ctl->def->nhostdevs; i++)
if (ctl->def->hostdevs[i]) {
rc = virUSBDeviceFileIterate(usb, file_iterate_hostdev_cb, &buf);
virUSBDeviceFree(usb);
if (rc != 0)
- goto clean;
+ goto cleanup;
break;
}
if (ctl->newfile)
if (vah_add_file(&buf, ctl->newfile, "rw") != 0)
- goto clean;
+ goto cleanup;
if (virBufferError(&buf)) {
virBufferFreeAndReset(&buf);
vah_error(NULL, 0, _("failed to allocate file buffer"));
- goto clean;
+ goto cleanup;
}
rc = 0;
ctl->files = virBufferContentAndReset(&buf);
- clean:
+ cleanup:
VIR_FREE(uuid);
return rc;
}
if (ctl->append && ctl->newfile) {
if (vah_add_file(&buf, ctl->newfile, "rw") != 0)
- goto clean;
+ goto cleanup;
} else {
virBufferAsprintf(&buf, " \"%s/log/libvirt/**/%s.log\" w,\n",
LOCALSTATEDIR, ctl->def->name);
} else if ((rc = update_include_file(include_file,
included_files,
ctl->append)) != 0)
- goto clean;
+ goto cleanup;
/* create the profile from TEMPLATE */
if (virAsprintf(&tmp, " #include <libvirt/%s.files>\n",
ctl->uuid) == -1) {
vah_error(ctl, 0, _("could not allocate memory"));
- goto clean;
+ goto cleanup;
}
if (ctl->dryrun) {
unlink(profile);
}
}
- clean:
+ cleanup:
VIR_FREE(included_files);
}