chiark / gitweb /
systemctl: fix 'systemctl enable getty@.service'
[elogind.git] / src / load-fragment.c
index 1685c4adb76734a0d7f21687e55743a5c06e7020..740c11c3c2f3649d894bef523207c1cd0fd2df47 100644 (file)
@@ -1431,7 +1431,7 @@ static int open_follow(char **filename, FILE **_f, Set *names, char **_final) {
                  * unit name. */
                 name = file_name_from_path(*filename);
 
-                if (unit_name_is_valid(name)) {
+                if (unit_name_is_valid(name, false)) {
                         if (!(id = set_get(names, name))) {
 
                                 if (!(id = strdup(name)))
@@ -1883,9 +1883,15 @@ static int load_from_path(Unit *u, const char *path) {
                 goto finish;
         }
 
-        /* Now, parse the file contents */
-        if ((r = config_parse(filename, f, sections, items, false, u)) < 0)
-                goto finish;
+        if (null_or_empty(&st))
+                u->meta.load_state = UNIT_BANNED;
+        else {
+                /* Now, parse the file contents */
+                if ((r = config_parse(filename, f, sections, items, false, u)) < 0)
+                        goto finish;
+
+                u->meta.load_state = UNIT_LOADED;
+        }
 
         free(u->meta.fragment_path);
         u->meta.fragment_path = filename;
@@ -1893,7 +1899,6 @@ static int load_from_path(Unit *u, const char *path) {
 
         u->meta.fragment_mtime = timespec_load(&st.st_mtim);
 
-        u->meta.load_state = UNIT_LOADED;
         r = 0;
 
 finish: