Merge pull request #31131 from poettering/dlopen-kmod

turn libkmod into a dlopen() dependency, too
This commit is contained in:
Luca Boccassi
2024-04-06 13:19:27 +01:00
committed by GitHub
16 changed files with 202 additions and 92 deletions
+5 -2
View File
@@ -265,7 +265,10 @@ executables += [
},
test_template + {
'sources' : files('test-dlopen-so.c'),
'dependencies' : libp11kit_cflags
'dependencies' : [
libp11kit_cflags,
libkmod_cflags,
],
},
test_template + {
# only static linking apart from libdl, to make sure that the
@@ -335,7 +338,7 @@ executables += [
},
test_template + {
'sources' : files('test-netlink-manual.c'),
'dependencies' : libkmod,
'dependencies' : libkmod_cflags,
'conditions' : ['HAVE_KMOD'],
'type' : 'manual',
},
+5
View File
@@ -13,6 +13,7 @@
#include "libfido2-util.h"
#include "macro.h"
#include "main-func.h"
#include "module-util.h"
#include "password-quality-util-passwdqc.h"
#include "password-quality-util-pwquality.h"
#include "pcre2-util.h"
@@ -93,6 +94,10 @@ static int run(int argc, char **argv) {
assert_se(initialize_libgcrypt(/* secmem= */ false) >= 0);
#endif
#if HAVE_KMOD
assert_se(dlopen_libkmod() >= 0);
#endif
return 0;
}
+12 -8
View File
@@ -13,25 +13,29 @@
#include "tests.h"
static int load_module(const char *mod_name) {
_cleanup_(kmod_unrefp) struct kmod_ctx *ctx = NULL;
_cleanup_(kmod_module_unref_listp) struct kmod_list *list = NULL;
_cleanup_(sym_kmod_unrefp) struct kmod_ctx *ctx = NULL;
_cleanup_(sym_kmod_module_unref_listp) struct kmod_list *list = NULL;
struct kmod_list *l;
int r;
ctx = kmod_new(NULL, NULL);
r = dlopen_libkmod();
if (r < 0)
return log_error_errno(r, "Failed to load libkmod: %m");
ctx = sym_kmod_new(NULL, NULL);
if (!ctx)
return log_oom();
r = kmod_module_new_from_lookup(ctx, mod_name, &list);
r = sym_kmod_module_new_from_lookup(ctx, mod_name, &list);
if (r < 0)
return r;
kmod_list_foreach(l, list) {
_cleanup_(kmod_module_unrefp) struct kmod_module *mod = NULL;
sym_kmod_list_foreach(l, list) {
_cleanup_(sym_kmod_module_unrefp) struct kmod_module *mod = NULL;
mod = kmod_module_get_module(l);
mod = sym_kmod_module_get_module(l);
r = kmod_module_probe_insert_module(mod, 0, NULL, NULL, NULL, NULL);
r = sym_kmod_module_probe_insert_module(mod, 0, NULL, NULL, NULL, NULL);
if (r > 0)
r = -EINVAL;
}