diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-06-22 09:24:02 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-06-24 10:16:46 +0200 |
commit | 1622ef77ee4466074e7d785feabf6bc9115297c8 (patch) | |
tree | 3e6c23b55ed2e87850d8d0c9886ede87752871f8 /src/shared/cryptsetup-util.c | |
parent | fff25ab22eec825a15c2647a84247221abd6b0c8 (diff) | |
download | systemd-1622ef77ee4466074e7d785feabf6bc9115297c8.tar.gz |
various: convert to the new dlopen_or_warn() helper
Diffstat (limited to 'src/shared/cryptsetup-util.c')
-rw-r--r-- | src/shared/cryptsetup-util.c | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/src/shared/cryptsetup-util.c b/src/shared/cryptsetup-util.c index 99c78f6858..b93f702aff 100644 --- a/src/shared/cryptsetup-util.c +++ b/src/shared/cryptsetup-util.c @@ -51,20 +51,10 @@ crypt_token_info (*sym_crypt_token_status)(struct crypt_device *cd, int token, c int (*sym_crypt_volume_key_get)(struct crypt_device *cd, int keyslot, char *volume_key, size_t *volume_key_size, const char *passphrase, size_t passphrase_size); int dlopen_cryptsetup(void) { - _cleanup_(dlclosep) void *dl = NULL; int r; - if (cryptsetup_dl) - return 0; /* Already loaded */ - - dl = dlopen("libcryptsetup.so.12", RTLD_LAZY); - if (!dl) - return log_debug_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), - "libcryptsetup support is not installed: %s", dlerror()); - - r = dlsym_many_or_warn( - dl, - LOG_DEBUG, + r = dlopen_many_sym_or_warn( + &cryptsetup_dl, "libcryptsetup.so.12", LOG_DEBUG, DLSYM_ARG(crypt_activate_by_passphrase), #if HAVE_CRYPT_ACTIVATE_BY_SIGNED_KEY DLSYM_ARG(crypt_activate_by_signed_key), @@ -104,15 +94,10 @@ int dlopen_cryptsetup(void) { DLSYM_ARG(crypt_token_max), #endif DLSYM_ARG(crypt_token_status), - DLSYM_ARG(crypt_volume_key_get), - NULL); - if (r < 0) + DLSYM_ARG(crypt_volume_key_get)); + if (r <= 0) return r; - /* Note that we never release the reference here, because there's no real reason to, after all this - * was traditionally a regular shared library dependency which lives forever too. */ - cryptsetup_dl = TAKE_PTR(dl); - /* Redirect the default logging calls of libcryptsetup to our own logging infra. (Note that * libcryptsetup also maintains per-"struct crypt_device" log functions, which we'll also set * whenever allocating a "struct crypt_device" context. Why set both? To be defensive: maybe some |