+static int item_set_xattrs(Item *i, const char *path) {
+ char **name, **value;
+
+ assert(i);
+ assert(path);
+
+ STRV_FOREACH_PAIR(name, value, i->xattrs) {
+ int n;
+
+ n = strlen(*value);
+ if (lsetxattr(path, *name, *value, n, 0) < 0) {
+ log_error("Setting extended attribute %s=%s on %s failed: %m",
+ *name, *value, path);
+ return -errno;
+ }
+ }
+ return 0;
+}
+
+static int get_acls_from_arg(Item *item) {
+#ifdef HAVE_ACL
+ int r;
+ _cleanup_(acl_freep) acl_t a = NULL, d = NULL;
+
+ assert(item);
+
+ r = parse_acl(item->argument, &item->acl_access, &item->acl_default);
+ if (r < 0)
+ log_warning_errno(errno, "Failed to parse ACL \"%s\": %m. Ignoring",
+ item->argument);
+#else
+ log_warning_errno(ENOSYS, "ACLs are not supported. Ignoring");
+#endif
+
+ return 0;
+}
+
+static int item_set_acl(Item *item, const char *path) {
+#ifdef HAVE_ACL
+ int r;
+
+ assert(item);
+ assert(path);
+
+ if (item->acl_access) {
+ r = acl_set_file(path, ACL_TYPE_ACCESS, item->acl_access);
+ if (r < 0) {
+ _cleanup_(acl_free_charpp) char *t;
+
+ t = acl_to_any_text(item->acl_access, NULL, ',', TEXT_ABBREVIATE);
+ return log_error_errno(errno,
+ "Setting access ACL \"%s\" on %s failed: %m",
+ strna(t), path);
+ }
+ }
+
+ if (item->acl_default) {
+ r = acl_set_file(path, ACL_TYPE_DEFAULT, item->acl_default);
+ if (r < 0) {
+ _cleanup_(acl_free_charpp) char *t;
+
+ t = acl_to_any_text(item->acl_default, NULL, ',', TEXT_ABBREVIATE);
+ return log_error_errno(errno,
+ "Setting default ACL \"%s\" on %s failed: %m",
+ strna(t), path);
+ }
+ }
+#endif
+
+ return 0;