dlopen: take log_level argument and log in fallback stubs
Every dlopen_xxx() helper now takes an int log_level argument. It is passed through to dlopen_many_sym_or_warn() (which in turn propagates it to dlopen_verbose() for the library-not-installed case), and is used by the fallback stub when support for the library is not compiled in to emit a "<lib> support is not compiled in." message at the caller's level. Callers pass LOG_DEBUG when gracefully degrading, or a higher level when the failure should surface, and no longer need to log redundantly at the call site. As part of this, dlopen_bpf_full() (which already took a log_level) is merged into dlopen_bpf() rather than keeping both. The static inline fallbacks used to live in the headers, which required pulling log.h in from every header that declared a dlopen_xxx(). Move them into the .c files instead: the declaration is always outside the #if HAVE_XXX block, the impl sits outside the outer #if HAVE_XXX wrap with its own internal #if HAVE_XXX/#else/#endif, and apparmor-util.c, idn-util.c, libmount-util.c and pam-util.c are now always compiled so they can host their stubs.
This commit is contained in:
committed by
Zbigniew Jędrzejewski-Szmek
parent
2d28d3cb91
commit
d49f3f287a
@@ -5,6 +5,7 @@
|
||||
#include "sd-dlopen.h"
|
||||
|
||||
#include "gcrypt-util.h"
|
||||
#include "log.h" /* IWYU pragma: keep */
|
||||
|
||||
#if HAVE_GCRYPT
|
||||
|
||||
@@ -44,7 +45,7 @@ DLSYM_PROTOTYPE(gcry_randomize) = NULL;
|
||||
DLSYM_PROTOTYPE(gcry_strerror) = NULL;
|
||||
#endif
|
||||
|
||||
int dlopen_gcrypt(void) {
|
||||
int dlopen_gcrypt(int log_level) {
|
||||
#if HAVE_GCRYPT
|
||||
SD_ELF_NOTE_DLOPEN(
|
||||
"gcrypt",
|
||||
@@ -54,7 +55,7 @@ int dlopen_gcrypt(void) {
|
||||
|
||||
return dlopen_many_sym_or_warn(
|
||||
&gcrypt_dl,
|
||||
"libgcrypt.so.20", LOG_DEBUG,
|
||||
"libgcrypt.so.20", log_level,
|
||||
DLSYM_ARG(gcry_control),
|
||||
DLSYM_ARG(gcry_check_version),
|
||||
DLSYM_ARG(gcry_md_close),
|
||||
@@ -88,7 +89,8 @@ int dlopen_gcrypt(void) {
|
||||
DLSYM_ARG(gcry_randomize),
|
||||
DLSYM_ARG(gcry_strerror));
|
||||
#else
|
||||
return -EOPNOTSUPP;
|
||||
return log_full_errno(log_level, SYNTHETIC_ERRNO(EOPNOTSUPP),
|
||||
"gcrypt support is not compiled in.");
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -96,7 +98,7 @@ int initialize_libgcrypt(bool secmem) {
|
||||
#if HAVE_GCRYPT
|
||||
int r;
|
||||
|
||||
r = dlopen_gcrypt();
|
||||
r = dlopen_gcrypt(LOG_DEBUG);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user