X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fload-fragment.c;h=50008101a1d2e81c2d594166d41df27ef8cad4a5;hb=36adffeab07c74470bc96417b17a72b53055ee42;hp=8e4ec74b0735b98e55ee2bcd1ee665298fa2a673;hpb=3b6fdb5b5afebc49a7e987e3e3bf7aa2615d1671;p=elogind.git diff --git a/src/load-fragment.c b/src/load-fragment.c index 8e4ec74b0..50008101a 100644 --- a/src/load-fragment.c +++ b/src/load-fragment.c @@ -29,6 +29,7 @@ #include #include #include +#include #include "unit.h" #include "strv.h" @@ -1558,11 +1559,13 @@ static int load_from_path(Unit *u, const char *path) { { "Conflicts", config_parse_deps, UINT_TO_PTR(UNIT_CONFLICTS), "Unit" }, { "Before", config_parse_deps, UINT_TO_PTR(UNIT_BEFORE), "Unit" }, { "After", config_parse_deps, UINT_TO_PTR(UNIT_AFTER), "Unit" }, + { "OnFailure", config_parse_deps, UINT_TO_PTR(UNIT_ON_FAILURE), "Unit" }, { "RecursiveStop", config_parse_bool, &u->meta.recursive_stop, "Unit" }, { "StopWhenUnneeded", config_parse_bool, &u->meta.stop_when_unneeded, "Unit" }, { "OnlyByDependency", config_parse_bool, &u->meta.only_by_dependency, "Unit" }, { "DefaultDependencies", config_parse_bool, &u->meta.default_dependencies, "Unit" }, { "IgnoreDependencyFailure",config_parse_bool, &u->meta.ignore_dependency_failure, "Unit" }, + { "JobTimeoutSec", config_parse_usec, &u->meta.job_timeout, "Unit" }, { "PIDFile", config_parse_path, &u->service.pid_file, "Service" }, { "ExecStartPre", config_parse_exec, u->service.exec_command+SERVICE_EXEC_START_PRE, "Service" }, @@ -1653,6 +1656,7 @@ static int load_from_path(Unit *u, const char *path) { FILE *f = NULL; char *filename = NULL, *id = NULL; Unit *merged; + struct stat st; if (!u) { /* Dirty dirty hack. */ @@ -1740,6 +1744,17 @@ static int load_from_path(Unit *u, const char *path) { goto finish; } + zero(st); + if (fstat(fileno(f), &st) < 0) { + r = -errno; + goto finish; + } + + if (!S_ISREG(st.st_mode)) { + r = -ENOENT; + goto finish; + } + /* Now, parse the file contents */ if ((r = config_parse(filename, f, sections, items, false, u)) < 0) goto finish; @@ -1748,6 +1763,8 @@ static int load_from_path(Unit *u, const char *path) { u->meta.fragment_path = filename; filename = NULL; + u->meta.fragment_mtime = timespec_load(&st.st_mtim); + u->meta.load_state = UNIT_LOADED; r = 0;