1
0
mirror of https://github.com/openbsd/src.git synced 2026-06-18 15:23:33 +02:00

usr.sbin/ifstated: timestamp sync external tests

When external_exec() runs a test synchronously, it refreshes prevstatus
but left lastexec unchanged. A later status change could therefore be
ignored by eval_state(), because that code gates body evaluation on the
first external test timestamp for the current state.

Set lastexec together with prevstatus for synchronous runs; this keeps
the cached test status and execution time consistent across state
re-entry.

OK: deraadt@
This commit is contained in:
kirill
2026-05-19 01:12:49 +00:00
parent 6e40f20752
commit b88051becf
+4 -2
View File
@@ -1,4 +1,4 @@
/* $OpenBSD: ifstated.c,v 1.68 2024/04/23 13:34:51 jsg Exp $ */
/* $OpenBSD: ifstated.c,v 1.69 2026/05/19 01:12:49 kirill Exp $ */
/*
* Copyright (c) 2004 Marco Pfatschbacher <mpf@openbsd.org>
@@ -340,8 +340,10 @@ external_exec(struct ifsd_external *external, int async)
if (!async) {
waitpid(external->pid, &s, 0);
external->pid = 0;
if (WIFEXITED(s))
if (WIFEXITED(s)) {
external->prevstatus = WEXITSTATUS(s);
external->lastexec = time(NULL);
}
}
}