Extend test-dlopen-so to also cover cases when built without support
Let's make things more consistent and have all dlopen_xxx() functions return EOPNOTSUPP on failure and verify this behavior in test-dlopen-so.
This commit is contained in:
committed by
Luca Boccassi
parent
9736f634c8
commit
ff33c8f87d
+12
-6
@@ -144,8 +144,8 @@ bool compression_supported(Compression c) {
|
||||
return BIT_SET(supported, c);
|
||||
}
|
||||
|
||||
#if HAVE_XZ
|
||||
int dlopen_lzma(void) {
|
||||
#if HAVE_XZ
|
||||
ELF_NOTE_DLOPEN("lzma",
|
||||
"Support lzma compression in journal and coredump files",
|
||||
COMPRESSION_PRIORITY_XZ,
|
||||
@@ -160,8 +160,10 @@ int dlopen_lzma(void) {
|
||||
DLSYM_ARG(lzma_stream_buffer_encode),
|
||||
DLSYM_ARG(lzma_lzma_preset),
|
||||
DLSYM_ARG(lzma_stream_decoder));
|
||||
}
|
||||
#else
|
||||
return -EOPNOTSUPP;
|
||||
#endif
|
||||
}
|
||||
|
||||
int compress_blob_xz(const void *src, uint64_t src_size,
|
||||
void *dst, size_t dst_alloc_size, size_t *dst_size, int level) {
|
||||
@@ -213,8 +215,8 @@ int compress_blob_xz(const void *src, uint64_t src_size,
|
||||
#endif
|
||||
}
|
||||
|
||||
#if HAVE_LZ4
|
||||
int dlopen_lz4(void) {
|
||||
#if HAVE_LZ4
|
||||
ELF_NOTE_DLOPEN("lz4",
|
||||
"Support lz4 compression in journal and coredump files",
|
||||
COMPRESSION_PRIORITY_LZ4,
|
||||
@@ -238,8 +240,10 @@ int dlopen_lz4(void) {
|
||||
DLSYM_ARG(LZ4_decompress_safe),
|
||||
DLSYM_ARG(LZ4_decompress_safe_partial),
|
||||
DLSYM_ARG(LZ4_versionNumber));
|
||||
}
|
||||
#else
|
||||
return -EOPNOTSUPP;
|
||||
#endif
|
||||
}
|
||||
|
||||
int compress_blob_lz4(const void *src, uint64_t src_size,
|
||||
void *dst, size_t dst_alloc_size, size_t *dst_size, int level) {
|
||||
@@ -278,8 +282,8 @@ int compress_blob_lz4(const void *src, uint64_t src_size,
|
||||
#endif
|
||||
}
|
||||
|
||||
#if HAVE_ZSTD
|
||||
int dlopen_zstd(void) {
|
||||
#if HAVE_ZSTD
|
||||
ELF_NOTE_DLOPEN("zstd",
|
||||
"Support zstd compression in journal and coredump files",
|
||||
COMPRESSION_PRIORITY_ZSTD,
|
||||
@@ -304,8 +308,10 @@ int dlopen_zstd(void) {
|
||||
DLSYM_ARG(ZSTD_isError),
|
||||
DLSYM_ARG(ZSTD_createDCtx),
|
||||
DLSYM_ARG(ZSTD_createCCtx));
|
||||
}
|
||||
#else
|
||||
return -EOPNOTSUPP;
|
||||
#endif
|
||||
}
|
||||
|
||||
int compress_blob_zstd(
|
||||
const void *src, uint64_t src_size,
|
||||
|
||||
@@ -62,17 +62,9 @@ int decompress_stream_xz(int fdf, int fdt, uint64_t max_size);
|
||||
int decompress_stream_lz4(int fdf, int fdt, uint64_t max_size);
|
||||
int decompress_stream_zstd(int fdf, int fdt, uint64_t max_size);
|
||||
|
||||
#if HAVE_LZ4
|
||||
int dlopen_lz4(void);
|
||||
#endif
|
||||
|
||||
#if HAVE_ZSTD
|
||||
int dlopen_zstd(void);
|
||||
#endif
|
||||
|
||||
#if HAVE_XZ
|
||||
int dlopen_lzma(void);
|
||||
#endif
|
||||
|
||||
static inline int compress_blob(
|
||||
Compression compression,
|
||||
|
||||
+12
-4
@@ -1,11 +1,11 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#if HAVE_GCRYPT
|
||||
|
||||
#include <sys/syslog.h>
|
||||
|
||||
#include "gcrypt-util.h"
|
||||
|
||||
#if HAVE_GCRYPT
|
||||
|
||||
static void *gcrypt_dl = NULL;
|
||||
|
||||
static DLSYM_PROTOTYPE(gcry_control) = NULL;
|
||||
@@ -40,8 +40,10 @@ DLSYM_PROTOTYPE(gcry_mpi_sub_ui) = NULL;
|
||||
DLSYM_PROTOTYPE(gcry_prime_check) = NULL;
|
||||
DLSYM_PROTOTYPE(gcry_randomize) = NULL;
|
||||
DLSYM_PROTOTYPE(gcry_strerror) = NULL;
|
||||
#endif
|
||||
|
||||
static int dlopen_gcrypt(void) {
|
||||
int dlopen_gcrypt(void) {
|
||||
#if HAVE_GCRYPT
|
||||
ELF_NOTE_DLOPEN("gcrypt",
|
||||
"Support for journald forward-sealing",
|
||||
ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED,
|
||||
@@ -82,9 +84,13 @@ static int dlopen_gcrypt(void) {
|
||||
DLSYM_ARG(gcry_prime_check),
|
||||
DLSYM_ARG(gcry_randomize),
|
||||
DLSYM_ARG(gcry_strerror));
|
||||
#else
|
||||
return -EOPNOTSUPP;
|
||||
#endif
|
||||
}
|
||||
|
||||
int initialize_libgcrypt(bool secmem) {
|
||||
#if HAVE_GCRYPT
|
||||
int r;
|
||||
|
||||
r = dlopen_gcrypt();
|
||||
@@ -105,5 +111,7 @@ int initialize_libgcrypt(bool secmem) {
|
||||
sym_gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
return -EOPNOTSUPP;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -4,6 +4,10 @@
|
||||
|
||||
#include "forward.h"
|
||||
|
||||
int dlopen_gcrypt(void);
|
||||
|
||||
int initialize_libgcrypt(bool secmem);
|
||||
|
||||
#if HAVE_GCRYPT
|
||||
#include <gcrypt.h> /* IWYU pragma: export */
|
||||
|
||||
@@ -40,8 +44,6 @@ extern DLSYM_PROTOTYPE(gcry_prime_check);
|
||||
extern DLSYM_PROTOTYPE(gcry_randomize);
|
||||
extern DLSYM_PROTOTYPE(gcry_strerror);
|
||||
|
||||
int initialize_libgcrypt(bool secmem);
|
||||
|
||||
/* Copied from gcry_md_putc from gcrypt.h due to the need to call the sym_ variant */
|
||||
#define sym_gcry_md_putc(h,c) \
|
||||
do { \
|
||||
|
||||
Reference in New Issue
Block a user