journalctl: read env vars that override compiled catalog database and source files

This makes it a bit easier to test catalog files without installing
systemd.
This commit is contained in:
Lennart Poettering 2023-06-27 23:15:27 +02:00
parent b6a3fe2666
commit fba84e121b
3 changed files with 18 additions and 4 deletions

View file

@ -514,7 +514,7 @@ SYSTEMD_HOME_DEBUG_SUFFIX=foo \
unconditionally as a child process by another tool, such as package managers
running kernel-install in a postinstall script.
`systemd-journald`:
`systemd-journald`, `journalctl`:
* `$SYSTEMD_JOURNAL_COMPACT` Takes a boolean. If enabled, journal files are written
in a more compact format that reduces the amount of disk space required by the
@ -529,6 +529,13 @@ SYSTEMD_HOME_DEBUG_SUFFIX=foo \
specified algorithm takes an effect immediately, you need to explicitly run
`journalctl --rotate`.
* `$SYSTEMD_CATALOG` path to the compiled catalog database file to use for
`journalctl -x`, `journalctl --update-catalog`, `journalctl --list-catalog`
and related calls.
* `$SYSTEMD_CATALOG_SOURCES` path to the catalog database input source
directory to use for `journalctl --update-catalog`.
`systemd-pcrphase`, `systemd-cryptsetup`:
* `$SYSTEMD_FORCE_MEASURE=1` — If set, force measuring of resources (which are

View file

@ -2400,12 +2400,19 @@ static int run(int argc, char *argv[]) {
case ACTION_UPDATE_CATALOG: {
_cleanup_free_ char *database = NULL;
database = path_join(arg_root, CATALOG_DATABASE);
database = path_join(arg_root, secure_getenv("SYSTEMD_CATALOG") ?: CATALOG_DATABASE);
if (!database)
return log_oom();
if (arg_action == ACTION_UPDATE_CATALOG) {
r = catalog_update(database, arg_root, catalog_file_dirs);
const char *e;
e = secure_getenv("SYSTEMD_CATALOG_SOURCES");
r = catalog_update(
database,
arg_root,
e ? (const char* const*) STRV_MAKE(e) : catalog_file_dirs);
if (r < 0)
return log_error_errno(r, "Failed to list catalog: %m");
} else {

View file

@ -3496,7 +3496,7 @@ _public_ int sd_journal_get_catalog(sd_journal *j, char **ret) {
if (r < 0)
return r;
r = catalog_get(CATALOG_DATABASE, id, &text);
r = catalog_get(secure_getenv("SYSTEMD_CATALOG") ?: CATALOG_DATABASE, id, &text);
if (r < 0)
return r;