mirror of
https://github.com/systemd/systemd.git
synced 2025-02-23 13:57:33 +03:00
service: add basic validation hooks
This commit is contained in:
parent
dd8f71ee9f
commit
243b1432c6
16
service.c
16
service.c
@ -726,6 +726,20 @@ static void service_init(Unit *u) {
|
||||
RATELIMIT_INIT(s->ratelimit, 10*USEC_PER_SEC, 5);
|
||||
}
|
||||
|
||||
static int service_verify(Service *s) {
|
||||
assert(s);
|
||||
|
||||
if (UNIT(s)->meta.load_state != UNIT_LOADED)
|
||||
return 0;
|
||||
|
||||
if (!s->exec_command[SERVICE_EXEC_START]) {
|
||||
log_error("%s lacks ExecStart setting. Refusing.", unit_id(UNIT(s)));
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int service_load(Unit *u) {
|
||||
int r;
|
||||
Service *s = SERVICE(u);
|
||||
@ -762,7 +776,7 @@ static int service_load(Unit *u) {
|
||||
return r;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return service_verify(s);
|
||||
}
|
||||
|
||||
static void service_dump(Unit *u, FILE *f, const char *prefix) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user