X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Ftmpfiles%2Ftmpfiles.c;h=bff95271f526e5ab160c94f69834b4914a5c2e63;hp=e83a73e2793c3ffc014644d82415ea3349ecadba;hb=f58ceb21e9cdc4b79586283743351750ae35c175;hpb=d78096b343400d7a9f513a55b76c8de28adb2e08 diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index e83a73e27..bff95271f 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -107,6 +107,7 @@ static Set *unix_sockets = NULL; 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; @@ -360,7 +361,7 @@ static int dir_cleanup( continue; if (i->type != IGNORE_DIRECTORY_PATH || !streq(dent->d_name, p)) { - log_debug("rmdir '%s'\n", sub_path); + log_debug("rmdir '%s'", sub_path); if (unlinkat(dirfd(d), dent->d_name, AT_REMOVEDIR) < 0) { if (errno != ENOENT && errno != ENOTEMPTY) { @@ -408,7 +409,7 @@ static int dir_cleanup( if (age >= cutoff) continue; - log_debug("unlink '%s'\n", sub_path); + log_debug("unlink '%s'", sub_path); if (unlinkat(dirfd(d), dent->d_name, 0) < 0) { if (errno != ENOENT) { @@ -435,8 +436,6 @@ finish: } 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) { @@ -457,8 +456,7 @@ static int item_set_perms_full(Item *i, const char *path, bool ignore_enoent) { } } - 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) { @@ -1077,7 +1075,7 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) { _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; @@ -1087,8 +1085,8 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) { assert(buffer); r = sscanf(buffer, - "%c %ms %ms %ms %ms %ms %n", - &type, + "%ms %ms %ms %ms %ms %ms %n", + &action, &path, &mode, &user, @@ -1100,6 +1098,14 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) { 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(); @@ -1271,6 +1277,7 @@ static int help(void) { " --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); @@ -1285,6 +1292,7 @@ static int parse_argv(int argc, char *argv[]) { ARG_CREATE, ARG_CLEAN, ARG_REMOVE, + ARG_BOOT, ARG_PREFIX, ARG_EXCLUDE_PREFIX, }; @@ -1295,6 +1303,7 @@ static int parse_argv(int argc, char *argv[]) { { "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 }, {} @@ -1329,6 +1338,10 @@ static int parse_argv(int argc, char *argv[]) { arg_remove = true; break; + case ARG_BOOT: + arg_boot = true; + break; + case ARG_PREFIX: if (strv_extend(&include_prefixes, optarg) < 0) return log_oom();