static bool arg_create = false;
static bool arg_clean = false;
static bool arg_remove = false;
+static bool arg_boot = false;
static char **include_prefixes = NULL;
static char **exclude_prefixes = NULL;
}
static int item_set_perms_full(Item *i, const char *path, bool ignore_enoent) {
- int r;
-
/* not using i->path directly because it may be a glob */
if (i->mode_set)
if (chmod(path, i->mode) < 0) {
}
}
- r = label_fix(path, false, false);
- return r == -ENOENT && ignore_enoent ? 0 : r;
+ return label_fix(path, ignore_enoent, false);
}
static int item_set_perms(Item *i, const char *path) {
break;
case CREATE_SYMLINK: {
- char *x;
+ _cleanup_free_ char *x = NULL;
label_context_set(i->path, S_IFLNK);
r = symlink(i->argument, i->path);
}
if (!streq(i->argument, x)) {
- free(x);
log_error("%s is not the right symlinks.", i->path);
return -EEXIST;
}
- free(x);
break;
}
_cleanup_item_free_ Item *i = NULL;
Item *existing;
_cleanup_free_ char
- *mode = NULL, *user = NULL, *group = NULL, *age = NULL, *path = NULL;
+ *action = NULL, *mode = NULL, *user = NULL, *group = NULL, *age = NULL, *path = NULL;
char type;
Hashmap *h;
int r, n = -1;
assert(buffer);
r = sscanf(buffer,
- "%c %ms %ms %ms %ms %ms %n",
- &type,
+ "%ms %ms %ms %ms %ms %ms %n",
+ &action,
&path,
&mode,
&user,
return -EIO;
}
+ if (strlen(action) > 2 || (strlen(action) > 1 && action[1] != '!')) {
+ log_error("[%s:%u] Unknown modifier '%s'", fname, line, action);
+ return -EINVAL;
+ } else if (strlen(action) > 1 && !arg_boot)
+ return 0;
+
+ type = action[0];
+
i = new0(Item, 1);
if (!i)
return log_oom();
" --create Create marked files/directories\n"
" --clean Clean up marked directories\n"
" --remove Remove marked files/directories\n"
+ " --boot Execute actions only safe at boot\n"
" --prefix=PATH Only apply rules that apply to paths with the specified prefix\n"
" --exclude-prefix=PATH Ignore rules that apply to paths with the specified prefix\n",
program_invocation_short_name);
ARG_CREATE,
ARG_CLEAN,
ARG_REMOVE,
+ ARG_BOOT,
ARG_PREFIX,
ARG_EXCLUDE_PREFIX,
};
{ "create", no_argument, NULL, ARG_CREATE },
{ "clean", no_argument, NULL, ARG_CLEAN },
{ "remove", no_argument, NULL, ARG_REMOVE },
+ { "boot", no_argument, NULL, ARG_BOOT },
{ "prefix", required_argument, NULL, ARG_PREFIX },
{ "exclude-prefix", required_argument, NULL, ARG_EXCLUDE_PREFIX },
{}
arg_remove = true;
break;
+ case ARG_BOOT:
+ arg_boot = true;
+ break;
+
case ARG_PREFIX:
- if (strv_extend(&include_prefixes, optarg) < 0)
+ if (strv_push(&include_prefixes, optarg) < 0)
return log_oom();
break;
case ARG_EXCLUDE_PREFIX:
- if (strv_extend(&exclude_prefixes, optarg) < 0)
+ if (strv_push(&exclude_prefixes, optarg) < 0)
return log_oom();
break;
hashmap_free(items);
hashmap_free(globs);
- strv_free(include_prefixes);
+ free(include_prefixes);
+ free(exclude_prefixes);
set_free_free(unix_sockets);