compress: split compress_blob() and friends to minimize dlopen dependencies
Previously, even though sd-journal does not support bzip2 and gzip compression, the dlopen ELF notes for those libraries were still being attached to libsystemd.so and various journal-handling executables. This occurred because the unified compression/decompression interfaces handled all formats unconditionally, causing the compiler and linker to pull in all associated dlopen notes across the board. To resolve this, split these functions into generic and journal-specific variants (e.g., introducing compress_blob_journal() and decompress_blob_journal()). The journal-specific variants only handle formats actually supported by the journal (LZ4, XZ, and ZSTD). By updating sd-journal, journald, journalctl, and related utilities to use these new `_journal` interfaces and switching them to the narrower COMPRESS_JOURNAL_NOTE macro, we ensure that unnecessary dlopen notes (for bzip2 and gzip) are no longer embedded into these binaries.
This commit is contained in:
@@ -365,7 +365,7 @@ static Compression getenv_compression(void) {
|
||||
return DEFAULT_COMPRESSION;
|
||||
}
|
||||
|
||||
if (!compression_supported(c)) {
|
||||
if (!compression_supported_journal(c)) {
|
||||
log_debug("Unsupported compression algorithm specified, ignoring: %s", e);
|
||||
return DEFAULT_COMPRESSION;
|
||||
}
|
||||
@@ -1861,7 +1861,7 @@ static int maybe_compress_payload(
|
||||
return 0;
|
||||
}
|
||||
|
||||
r = compress_blob(c, src, size, dst, size - 1, rsize, /* level= */ -1);
|
||||
r = compress_blob_journal(c, src, size, dst, size - 1, rsize, /* level= */ -1);
|
||||
if (r < 0)
|
||||
return log_debug_errno(r, "Failed to compress data object using %s, ignoring: %m", compression_to_string(c));
|
||||
|
||||
@@ -1983,7 +1983,7 @@ static int maybe_decompress_payload(
|
||||
int r;
|
||||
|
||||
if (field) {
|
||||
r = decompress_startswith(compression, payload, size, &f->compress_buffer, field,
|
||||
r = decompress_startswith_journal(compression, payload, size, &f->compress_buffer, field,
|
||||
field_length, '=');
|
||||
if (r < 0)
|
||||
return log_debug_errno(r,
|
||||
@@ -2003,7 +2003,7 @@ static int maybe_decompress_payload(
|
||||
return 1;
|
||||
}
|
||||
|
||||
r = decompress_blob(compression, payload, size, &f->compress_buffer, &rsize, DATA_SIZE_MAX);
|
||||
r = decompress_blob_journal(compression, payload, size, &f->compress_buffer, &rsize, DATA_SIZE_MAX);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ static int hash_payload(JournalFile *f, Object *o, uint64_t offset, const uint8_
|
||||
_cleanup_free_ void *b = NULL;
|
||||
size_t b_size;
|
||||
|
||||
r = decompress_blob(c, src, size, &b, &b_size, DATA_SIZE_MAX);
|
||||
r = decompress_blob_journal(c, src, size, &b, &b_size, DATA_SIZE_MAX);
|
||||
if (r < 0) {
|
||||
error_errno(offset, r, "%s decompression failed: %m",
|
||||
compression_to_string(c));
|
||||
|
||||
Reference in New Issue
Block a user