Skip to content

feat: use systemd-journal-logger when running as systemd service - #437

Open
erictapen wants to merge 2 commits into
pando85:masterfrom
erictapen:systemd-log
Open

feat: use systemd-journal-logger when running as systemd service#437
erictapen wants to merge 2 commits into
pando85:masterfrom
erictapen:systemd-log

Conversation

@erictapen

Copy link
Copy Markdown

This produces nicer logging output with colors for log levels and no duplicate time stamps.

Currently it looks like this:

Aug 21 14:03:34 maschine systemd[2827]: Started Passless FIDO2 Software Authenticator.
Aug 21 14:03:34 maschine passless[151280]: [2026-08-21T12:03:34.633Z INFO  passless_core::config] Loading configuration from: /nix/store/xgfdwsd064n55ycjn8c1vamicr73qyn7-passless.toml
Aug 21 14:03:34 maschine passless[151280]: [2026-08-21T12:03:34.633Z INFO  passless] Enabling verbose logging...
Aug 21 14:03:34 maschine passless[151280]: [2026-08-21T12:03:34.633Z DEBUG passless] Verbose logging enabled
Aug 21 14:03:34 maschine passless[151280]: [2026-08-21T12:03:34.633Z INFO  passless] Applying security hardening...
Aug 21 14:03:34 maschine passless[151280]: [2026-08-21T12:03:34.633Z DEBUG passless_core::config] Disabling core dumps to prevent credential leakage
Aug 21 14:03:34 maschine passless[151280]: [2026-08-21T12:03:34.633Z DEBUG passless_core::config] Check mlock capability
Aug 21 14:03:34 maschine passless[151280]: [2026-08-21T12:03:34.633Z DEBUG passless_core::config] MLOCK is enabled - sensitive data will not be swapped to disk
Aug 21 14:03:34 maschine passless[151280]: [2026-08-21T12:03:34.634Z INFO  passless] Acquiring instance lock...
Aug 21 14:03:34 maschine passless[151280]: [2026-08-21T12:03:34.634Z DEBUG passless] Instance lock acquired at /run/user/1001/passless/1acd256aa9f526d1cd5a3aab21ccd746.lock
Aug 21 14:03:34 maschine passless[151280]: [2026-08-21T12:03:34.634Z INFO  passless] Creating UHID device...
Aug 21 14:03:34 maschine passless[151280]: [2026-08-21T12:03:34.734Z INFO  passless] Creating authenticator service...
Aug 21 14:03:34 maschine passless[151280]: [2026-08-21T12:03:34.734Z INFO  passless::storage::pass] Using pass (password-store) backend
Aug 21 14:03:34 maschine passless[151280]: [2026-08-21T12:03:34.734Z INFO  passless::storage::pass] Store path: /home/kerstin/.local/share/password-store
Aug 21 14:03:34 maschine passless[151280]: [2026-08-21T12:03:34.734Z INFO  passless::storage::pass] Path: fido2
Aug 21 14:03:34 maschine passless[151280]: [2026-08-21T12:03:34.734Z INFO  passless::storage::pass] GPG backend: gpg

This produces nicer logging output with colors for log levels and no
duplicate time stamps.
@pando85

pando85 commented Aug 21, 2026

Copy link
Copy Markdown
Owner

Thanks for the PR, this will be an improvement in our logging stack.

@pando85 pando85 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this — I like the direction and the native journal integration is a real improvement. I’d like to get this merged; there are just a few small compatibility details I’d like us to keep from the current logging behavior:

  1. Preserve PASSLESS_LOG_LEVEL when journald is active. Right now the journal branch bypasses the env_logger filter entirely, so values such as warn or module-specific filters stop working under systemd. We can keep the native JournalLog and use an env_logger::Logger built with Builder::build() purely as the filtering layer in front of it (it implements log::Log and can be nested), so no extra dependency should be necessary.

  2. Fall back instead of panicking if the native journal socket is unavailable. connected_to_journal() only checks JOURNAL_STREAM against stderr; JournalLog::new() separately connects to the native journal socket and can fail, for example in some container/root-image setups. If JournalLog::new() fails, falling back to the existing stderr env_logger path would keep Passless usable. A short eprintln! explaining the fallback would be useful too.

  3. Keep the agent journal identifier. contrib/systemd/passless-agent.service intentionally uses SyslogIdentifier=passless-agent, while the new native logger always writes SYSLOG_IDENTIFIER=passless. Because native journal fields bypass systemd’s stdout/stderr SyslogIdentifier= handling, agent logs would become passless. I suggest an env override such as PASSLESS_SYSLOG_IDENTIFIER (defaulting to passless) and setting Environment=PASSLESS_SYSLOG_IDENTIFIER=passless-agent in the agent unit. The normal service can keep the default.

PASSLESS_LOG_STYLE can remain relevant only to the stderr fallback; native journald already carries the priority structurally, so that part does not need to be emulated.

There is also an unrelated getrandom lockfile bump through tempfile; nice to avoid if Cargo lets us, but I would not block the PR on that.

Thanks again for the contribution — the core approach is good; these are mostly Passless-specific integration details rather than a change in direction.

@erictapen

Copy link
Copy Markdown
Author
  1. Shouldn't log::set_max_level already do this?
  2. done
  3. Couldn't we just detect wether we are running as root and set the syslog identifier accordingly?

Feel free to squash this when merging.

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