Compare commits

...

2 Commits

Author SHA1 Message Date
Luca Boccassi c65a84c977
Merge 1f071f0429 into 69af4849aa 2024-11-21 04:17:57 +09:00
Luca Boccassi 1f071f0429 test-audit-util: do not assert on pid1 state
The test can be ran on systems that are not booted on systemd, so
making assertions based on the precise state of an unknown, foreign
pid1 is not guaranteed to yield the expected results and may fail
at any given time.

More specifically, this happens when building systemd on the buildd
network, which is used to build packages in Debian/Ubuntu:

 Assertion 'audit_session_from_pid(&pid1, &sessionid) == -ENODATA' failed at src/test/test-audit-util.c:27, function test_audit_loginuid_from_pid(). Aborting.

https://buildd.debian.org/status/fetch.php?pkg=systemd&arch=amd64&ver=257%7Erc2-1&stamp=1731712935&raw=0

Fixes https://github.com/systemd/systemd/issues/35249
2024-11-20 17:44:29 +00:00
1 changed files with 6 additions and 1 deletions

View File

@ -26,7 +26,12 @@ TEST(audit_loginuid_from_pid) {
if (r >= 0)
log_info("self audit session id: %" PRIu32, sessionid);
ASSERT_ERROR(audit_session_from_pid(&pid1, &sessionid), ENODATA);
/* pid1 at build time does not necessarily have to be systemd, it could be anything and be in any
* state outside of our control, so print a log message instead of asserting. As a specific example,
* on the Debian buildd network the stub pid1 is not systemd, and has a sessionid */
r = audit_session_from_pid(&pid1, &sessionid);
if (r != -ENODATA)
log_error("audit_session_from_pid on pid1 unexpectedly returned %d instead of -ENODATA", r);
}
static int intro(void) {