Skip to content

avoid noise if systemd not running#55

Merged
thkukuk merged 2 commits into
thkukuk:mainfrom
andy-bower:silence-failure-to-count-soft-reboots
Jan 12, 2026
Merged

avoid noise if systemd not running#55
thkukuk merged 2 commits into
thkukuk:mainfrom
andy-bower:silence-failure-to-count-soft-reboots

Conversation

@andy-bower
Copy link
Copy Markdown
Contributor

Hi,

If wtmpdb is run without systemd then a message is printed every boot about failing to count soft reboots (also similarly in a minimal system without even dbus).

It seems to me that if this happens then soft reboot counts are irrelevant because they are a systemd concept to begin with so it is sufficient to fail silently.

If the system is broken in some more fundamental way then I think that will not need wtmpdb to be the means by which the user is informed - so I suspect the value of these messages might only be during development.

Debian has carried this patch for 10 months without any issue - would you be prepared to take it or something equivalent/better upstream?

Thanks!

@thkukuk
Copy link
Copy Markdown
Owner

thkukuk commented Jan 10, 2026

I agree that if no dbus is running, we should ignore that silently. So the first change is Ok.

But I don't agree with the second one: in this case, dbus is running and a real error happened. Cases like systemd is too old are already ignored and don't lead to an error message. But real errors should be logged, so that people see something is broken and can fix it. Else debugging problems will be pretty difficult.

@andy-bower
Copy link
Copy Markdown
Contributor Author

But I don't agree with the second one: in this case, dbus is running and a real error happened. Cases like systemd is too old are already ignored and don't lead to an error message. But real errors should be logged, so that people see something is broken and can fix it. Else debugging problems will be pretty difficult.

In that case, how about adding sd_booted() && (untested) to this condition?

      if (!sd_bus_error_has_name (&error, SD_BUS_ERROR_UNKNOWN_PROPERTY))

@andy-bower andy-bower force-pushed the silence-failure-to-count-soft-reboots branch from cecce5d to 3ad0338 Compare January 10, 2026 17:16
@andy-bower
Copy link
Copy Markdown
Contributor Author

Force-push checks the error code specifically for no systemd.

Without:

$ ./wtmpdb boot -f foo
Failed to get SoftRebootsCount property: The name org.freedesktop.systemd1 was not provided by any .service files
Boot time too far in the past, using current time:
Boot time: Sat Jan 10 12:18:33 2026
Current time: Sat Jan 10 17:10:59 2026

With:

$ ./wtmpdb boot -f foo
Boot time too far in the past, using current time:
Boot time: Sat Jan 10 12:18:33 2026
Current time: Sat Jan 10 17:15:43 2026

@thkukuk thkukuk merged commit d3a5bd6 into thkukuk:main Jan 12, 2026
3 checks passed
@thkukuk
Copy link
Copy Markdown
Owner

thkukuk commented Jan 12, 2026

Thanks

@andy-bower andy-bower deleted the silence-failure-to-count-soft-reboots branch January 12, 2026 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants