if (VIR_ALLOC(item) < 0)
return -1;
- if (VIR_STRDUP(item->path, path) < 0 || VIR_STRDUP(item->tcon, tcon) < 0)
- goto cleanup;
+ item->path = g_strdup(path);
+ item->tcon = g_strdup(tcon);
item->remember = remember;
item->restore = restore;
if (!(contextRange = context_range_get(ourContext)))
contextRange = "s0";
- if (VIR_STRDUP(*sens, contextRange) < 0)
- goto cleanup;
+ *sens = g_strdup(contextRange);
/* Find and blank out the category part (if any) */
tmp = strchr(*sens, ':');
_("Unable to format SELinux context"));
goto cleanup;
}
- if (VIR_STRDUP(ret, str) < 0)
- goto cleanup;
+ ret = g_strdup(str);
VIR_DEBUG("Generated context '%s'", ret);
cleanup:
freecon(ourSecContext);
*ptr = '\0';
ptr++;
if (*ptr != '\0') {
- if (VIR_STRDUP(data->alt_domain_context, ptr) < 0)
- goto error;
+ data->alt_domain_context = g_strdup(ptr);
ptr = strchrnul(data->alt_domain_context, '\n');
if (ptr && *ptr == '\n')
*ptr = '\0';
ptr = strchrnul(data->file_context, '\n');
if (ptr && *ptr == '\n') {
*ptr = '\0';
- if (VIR_STRDUP(data->content_context, ptr + 1) < 0)
- goto error;
+ data->content_context = g_strdup(ptr + 1);
ptr = strchrnul(data->content_context, '\n');
if (ptr && *ptr == '\n')
*ptr = '\0';
virReportSystemError(errno, "%s", _("unable to get selinux context range"));
goto cleanup;
}
- if (VIR_STRDUP(mcs, range) < 0)
- goto cleanup;
+ mcs = g_strdup(range);
break;
case VIR_DOMAIN_SECLABEL_DYNAMIC:
&catMax) < 0)
goto cleanup;
- if (VIR_STRDUP(mcs, sens) < 0)
- goto cleanup;
+ mcs = g_strdup(sens);
break;
dev->source.caps.u.storage.block) < 0)
return -1;
} else {
- if (VIR_STRDUP(path, dev->source.caps.u.storage.block) < 0)
- return -1;
+ path = g_strdup(dev->source.caps.u.storage.block);
}
ret = virSecuritySELinuxSetFilecon(mgr, path, secdef->imagelabel, true);
VIR_FREE(path);
dev->source.caps.u.misc.chardev) < 0)
return -1;
} else {
- if (VIR_STRDUP(path, dev->source.caps.u.misc.chardev) < 0)
- return -1;
+ path = g_strdup(dev->source.caps.u.misc.chardev);
}
ret = virSecuritySELinuxSetFilecon(mgr, path, secdef->imagelabel, true);
VIR_FREE(path);
dev->source.caps.u.storage.block) < 0)
return -1;
} else {
- if (VIR_STRDUP(path, dev->source.caps.u.storage.block) < 0)
- return -1;
+ path = g_strdup(dev->source.caps.u.storage.block);
}
ret = virSecuritySELinuxRestoreFileLabel(mgr, path, true);
VIR_FREE(path);
dev->source.caps.u.misc.chardev) < 0)
return -1;
} else {
- if (VIR_STRDUP(path, dev->source.caps.u.misc.chardev) < 0)
- return -1;
+ path = g_strdup(dev->source.caps.u.misc.chardev);
}
ret = virSecuritySELinuxRestoreFileLabel(mgr, path, true);
VIR_FREE(path);
}
range = context_range_get(ctx);
if (range) {
- if (VIR_STRDUP(mcs, range) < 0)
- goto cleanup;
+ mcs = g_strdup(range);
if (!(label = virSecuritySELinuxGenNewContext(data->file_context,
mcs, true)))
goto cleanup;
* 3. re-combine the realpath with the remaining suffix
* Note: A totally non existent path is used as-is
*/
- if (VIR_STRDUP_QUIET(pathdir, path) < 0)
- goto cleanup;
+ pathdir = g_strdup(path);
while (!virFileExists(pathdir)) {
if ((pathtmp = mdir_name(pathdir)) == NULL)
goto cleanup;
if (strlen(pathdir) == 1) {
/* nothing of the path does exist yet */
- if (VIR_STRDUP_QUIET(tmp, path) < 0)
- goto cleanup;
+ tmp = g_strdup(path);
} else {
- if (VIR_STRDUP_QUIET(pathtmp, path+strlen(pathdir)) < 0)
- goto cleanup;
+ pathtmp = g_strdup(path + strlen(pathdir));
if ((pathreal = realpath(pathdir, NULL)) == NULL) {
vah_error(NULL, 0, pathdir);
vah_error(NULL, 0, _("could not find realpath"));
goto cleanup;
}
- if (VIR_STRDUP_QUIET(perms_new, perms) < 0)
- goto cleanup;
+ perms_new = g_strdup(perms);
if (strchr(perms_new, 'w') != NULL) {
readonly = false;
break;
case 'f':
case 'F':
- if (VIR_STRDUP_QUIET(ctl->newfile, optarg) < 0)
- vah_error(ctl, 1, _("could not allocate memory for disk"));
+ ctl->newfile = g_strdup(optarg);
ctl->append = arg == 'F';
break;
case 'h':