VIR_AUTOFREE(char *) attr_name = NULL;
VIR_AUTOFREE(char *) value = NULL;
unsigned int refcount = 0;
- int rc;
*label = NULL;
- if ((rc = virSecurityValidateTimestamp(name, path)) < 0)
- return rc;
-
if (!(ref_name = virSecurityGetRefCountAttrName(name)))
return -1;
return -1;
}
+ if (value) {
+ int rc;
+
+ /* Do this after we've tried to get refcounter to ensure underlying FS
+ * supports XATTRs and @path has refcounter attribute set, because
+ * validator might throws a warning. */
+ if ((rc = virSecurityValidateTimestamp(name, path)) < 0)
+ return rc;
+
+ /* Invalid label is like a non-existent one */
+ if (rc == 1)
+ return -2;
+ }
+
if (virStrToLong_ui(value, NULL, 10, &refcount) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("malformed refcount %s on %s"),
VIR_AUTOFREE(char *) attr_name = NULL;
VIR_AUTOFREE(char *) value = NULL;
unsigned int refcount = 0;
- int rc;
-
- if ((rc = virSecurityValidateTimestamp(name, path)) < 0)
- return rc;
if (!(ref_name = virSecurityGetRefCountAttrName(name)))
return -1;
}
}
+ if (value) {
+ int rc;
+
+ /* Do this after we've tried to get refcounter to ensure underlying FS
+ * supports XATTRs and @path has refcounter attribute set, because
+ * validator might throws a warning. */
+ if ((rc = virSecurityValidateTimestamp(name, path)) < 0)
+ return rc;
+
+ /* Invalid label is like a non-existent one */
+ if (rc == 1)
+ VIR_FREE(value);
+ }
+
if (value &&
virStrToLong_ui(value, NULL, 10, &refcount) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,