Merge pull request #10324 from poettering/audit-serialize-bool
properly serialize in_audit boolean
This commit is contained in:
commit
cb5491ee4d
|
@ -2444,43 +2444,36 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, UnitNotifyFlag
|
||||||
if (!(flags & UNIT_NOTIFY_WILL_AUTO_RESTART))
|
if (!(flags & UNIT_NOTIFY_WILL_AUTO_RESTART))
|
||||||
unit_start_on_failure(u);
|
unit_start_on_failure(u);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (UNIT_IS_ACTIVE_OR_RELOADING(ns)) {
|
if (UNIT_IS_ACTIVE_OR_RELOADING(ns) && !UNIT_IS_ACTIVE_OR_RELOADING(os)) {
|
||||||
|
/* This unit just finished starting up */
|
||||||
|
|
||||||
if (u->type == UNIT_SERVICE &&
|
if (u->type == UNIT_SERVICE) {
|
||||||
!UNIT_IS_ACTIVE_OR_RELOADING(os) &&
|
/* Write audit record if we have just finished starting up */
|
||||||
!MANAGER_IS_RELOADING(m)) {
|
manager_send_unit_audit(m, u, AUDIT_SERVICE_START, true);
|
||||||
/* Write audit record if we have just finished starting up */
|
u->in_audit = true;
|
||||||
manager_send_unit_audit(m, u, AUDIT_SERVICE_START, true);
|
}
|
||||||
u->in_audit = true;
|
|
||||||
|
manager_send_unit_plymouth(m, u);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!UNIT_IS_ACTIVE_OR_RELOADING(os))
|
if (UNIT_IS_INACTIVE_OR_FAILED(ns) && !UNIT_IS_INACTIVE_OR_FAILED(os)) {
|
||||||
manager_send_unit_plymouth(m, u);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
if (UNIT_IS_INACTIVE_OR_FAILED(ns) &&
|
|
||||||
!UNIT_IS_INACTIVE_OR_FAILED(os)
|
|
||||||
&& !MANAGER_IS_RELOADING(m)) {
|
|
||||||
|
|
||||||
/* This unit just stopped/failed. */
|
/* This unit just stopped/failed. */
|
||||||
|
|
||||||
if (u->type == UNIT_SERVICE) {
|
if (u->type == UNIT_SERVICE) {
|
||||||
|
|
||||||
/* Hmm, if there was no start record written
|
if (u->in_audit) {
|
||||||
* write it now, so that we always have a nice
|
/* Write audit record if we have just finished shutting down */
|
||||||
* pair */
|
manager_send_unit_audit(m, u, AUDIT_SERVICE_STOP, ns == UNIT_INACTIVE);
|
||||||
if (!u->in_audit) {
|
u->in_audit = false;
|
||||||
|
} else {
|
||||||
|
/* Hmm, if there was no start record written write it now, so that we always
|
||||||
|
* have a nice pair */
|
||||||
manager_send_unit_audit(m, u, AUDIT_SERVICE_START, ns == UNIT_INACTIVE);
|
manager_send_unit_audit(m, u, AUDIT_SERVICE_START, ns == UNIT_INACTIVE);
|
||||||
|
|
||||||
if (ns == UNIT_INACTIVE)
|
if (ns == UNIT_INACTIVE)
|
||||||
manager_send_unit_audit(m, u, AUDIT_SERVICE_STOP, true);
|
manager_send_unit_audit(m, u, AUDIT_SERVICE_STOP, true);
|
||||||
} else
|
}
|
||||||
/* Write audit record if we have just finished shutting down */
|
|
||||||
manager_send_unit_audit(m, u, AUDIT_SERVICE_STOP, ns == UNIT_INACTIVE);
|
|
||||||
|
|
||||||
u->in_audit = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write a log message about consumed resources */
|
/* Write a log message about consumed resources */
|
||||||
|
@ -3245,6 +3238,8 @@ int unit_serialize(Unit *u, FILE *f, FDSet *fds, bool serialize_jobs) {
|
||||||
|
|
||||||
unit_serialize_item(u, f, "transient", yes_no(u->transient));
|
unit_serialize_item(u, f, "transient", yes_no(u->transient));
|
||||||
|
|
||||||
|
unit_serialize_item(u, f, "in-audit", yes_no(u->in_audit));
|
||||||
|
|
||||||
unit_serialize_item(u, f, "exported-invocation-id", yes_no(u->exported_invocation_id));
|
unit_serialize_item(u, f, "exported-invocation-id", yes_no(u->exported_invocation_id));
|
||||||
unit_serialize_item(u, f, "exported-log-level-max", yes_no(u->exported_log_level_max));
|
unit_serialize_item(u, f, "exported-log-level-max", yes_no(u->exported_log_level_max));
|
||||||
unit_serialize_item(u, f, "exported-log-extra-fields", yes_no(u->exported_log_extra_fields));
|
unit_serialize_item(u, f, "exported-log-extra-fields", yes_no(u->exported_log_extra_fields));
|
||||||
|
@ -3483,6 +3478,16 @@ int unit_deserialize(Unit *u, FILE *f, FDSet *fds) {
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
} else if (streq(l, "in-audit")) {
|
||||||
|
|
||||||
|
r = parse_boolean(v);
|
||||||
|
if (r < 0)
|
||||||
|
log_unit_debug(u, "Failed to parse in-audit bool %s, ignoring.", v);
|
||||||
|
else
|
||||||
|
u->in_audit = r;
|
||||||
|
|
||||||
|
continue;
|
||||||
|
|
||||||
} else if (streq(l, "exported-invocation-id")) {
|
} else if (streq(l, "exported-invocation-id")) {
|
||||||
|
|
||||||
r = parse_boolean(v);
|
r = parse_boolean(v);
|
||||||
|
|
Loading…
Reference in a new issue