chiark / gitweb /
tmpfiles: simplification
[elogind.git] / src / tmpfiles / tmpfiles.c
index 881c3b0d7818fe963bb4dfa5435f3599efa285d6..6e36dc79ddd9bf738cb221a63dd78ce8aa8a64ca 100644 (file)
@@ -107,7 +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_unsafe = false;
+static bool arg_boot = false;
 
 static char **include_prefixes = NULL;
 static char **exclude_prefixes = NULL;
@@ -436,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) {
@@ -458,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) {
@@ -734,7 +731,7 @@ static int create_item(Item *i) {
                 break;
 
         case CREATE_SYMLINK: {
-                char *x;
+                _cleanup_free_ char *x = NULL;
 
                 label_context_set(i->path, S_IFLNK);
                 r = symlink(i->argument, i->path);
@@ -754,12 +751,10 @@ static int create_item(Item *i) {
                 }
 
                 if (!streq(i->argument, x)) {
-                        free(x);
                         log_error("%s is not the right symlinks.", i->path);
                         return -EEXIST;
                 }
 
-                free(x);
                 break;
         }
 
@@ -1104,7 +1099,7 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) {
         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_unsafe)
+        } else if (strlen(action) > 1 && !arg_boot)
                 return 0;
 
         type = action[0];
@@ -1280,7 +1275,7 @@ static int help(void) {
                "     --create               Create marked files/directories\n"
                "     --clean                Clean up marked directories\n"
                "     --remove               Remove marked files/directories\n"
-               "     --unsafe               Execute actions only safe at boot\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);
@@ -1295,7 +1290,7 @@ static int parse_argv(int argc, char *argv[]) {
                 ARG_CREATE,
                 ARG_CLEAN,
                 ARG_REMOVE,
-                ARG_UNSAFE,
+                ARG_BOOT,
                 ARG_PREFIX,
                 ARG_EXCLUDE_PREFIX,
         };
@@ -1306,7 +1301,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         },
-                { "unsafe",         no_argument,         NULL, ARG_UNSAFE         },
+                { "boot",           no_argument,         NULL, ARG_BOOT           },
                 { "prefix",         required_argument,   NULL, ARG_PREFIX         },
                 { "exclude-prefix", required_argument,   NULL, ARG_EXCLUDE_PREFIX },
                 {}
@@ -1341,17 +1336,17 @@ static int parse_argv(int argc, char *argv[]) {
                         arg_remove = true;
                         break;
 
-                case ARG_UNSAFE:
-                        arg_unsafe = true;
+                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;
 
@@ -1511,7 +1506,8 @@ finish:
         hashmap_free(items);
         hashmap_free(globs);
 
-        strv_free(include_prefixes);
+        free(include_prefixes);
+        free(exclude_prefixes);
 
         set_free_free(unix_sockets);