{
char *label;
int ret = -1;
+ int rv;
- if (virSecurityGetRememberedLabel(SECURITY_DAC_NAME,
- path, &label) < 0)
- goto cleanup;
+ rv = virSecurityGetRememberedLabel(SECURITY_DAC_NAME, path, &label);
+ if (rv < 0)
+ return rv;
if (!label)
return 1;
}
refcount = virSecurityDACRememberLabel(priv, path, sb.st_uid, sb.st_gid);
- if (refcount < 0) {
+ if (refcount == -2) {
+ /* Not supported. Don't error though. */
+ } else if (refcount < 0) {
return -1;
} else if (refcount > 1) {
/* Refcount is greater than 1 which means that there
if (recall && path) {
rv = virSecurityDACRecallLabel(priv, path, &uid, &gid);
- if (rv < 0)
+ if (rv == -2) {
+ /* Not supported. Don't error though. */
+ } else if (rv < 0) {
return -1;
- if (rv > 0)
+ } else if (rv > 0) {
return 0;
+ }
}
VIR_INFO("Restoring DAC user and group on '%s' to %ld:%ld",
virSecuritySELinuxRecallLabel(const char *path,
security_context_t *con)
{
- if (virSecurityGetRememberedLabel(SECURITY_SELINUX_NAME,
- path, con) < 0)
- return -1;
+ int rv;
+
+ rv = virSecurityGetRememberedLabel(SECURITY_SELINUX_NAME, path, con);
+ if (rv < 0)
+ return rv;
if (!*con)
return 1;
if (econ) {
refcount = virSecuritySELinuxRememberLabel(path, econ);
- if (refcount < 0) {
+ if (refcount == -2) {
+ /* Not supported. Don't error though. */
+ } else if (refcount < 0) {
goto cleanup;
} else if (refcount > 1) {
/* Refcount is greater than 1 which means that there
}
if (recall) {
- if ((rc = virSecuritySELinuxRecallLabel(newpath, &fcon)) < 0) {
+ rc = virSecuritySELinuxRecallLabel(newpath, &fcon);
+ if (rc == -2) {
+ /* Not supported. Lookup the default label below. */
+ } else if (rc < 0) {
goto cleanup;
} else if (rc > 0) {
ret = 0;
goto cleanup;
}
- } else {
+ }
+
+ if (!recall || rc == -2) {
if (stat(newpath, &buf) != 0) {
VIR_WARN("cannot stat %s: %s", newpath,
virStrerror(errno, ebuf, sizeof(ebuf)));
* zero) and returns zero.
*
* Returns: 0 on success,
+ * -2 if underlying file system doesn't support XATTRs,
* -1 otherwise (with error reported)
*/
int
if (virFileGetXAttrQuiet(path, ref_name, &value) < 0) {
if (errno == ENOSYS || errno == ENODATA || errno == ENOTSUP) {
- ret = 0;
+ ret = -2;
} else {
virReportSystemError(errno,
_("Unable to get XATTR %s on %s"),
* See also virSecurityGetRememberedLabel.
*
* Returns: the new refcount value on success,
+ * -2 if underlying file system doesn't support XATTRs,
* -1 otherwise (with error reported)
*/
int
if (virFileGetXAttrQuiet(path, ref_name, &value) < 0) {
if (errno == ENOSYS || errno == ENOTSUP) {
- ret = 0;
+ ret = -2;
goto cleanup;
} else if (errno != ENODATA) {
virReportSystemError(errno,