]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared: Add more dlopen() tests
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 1 Mar 2022 17:04:13 +0000 (17:04 +0000)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 1 Mar 2022 21:07:17 +0000 (21:07 +0000)
Add dlopen_dw(), dlopen_elf() and dlopen_pcre2() to the dlopen test.
To enable adding dlopen_pcre2(), we move pcre2-dlopen.h/c from
src/journal to src/shared.

src/journal/meson.build
src/shared/elf-util.c
src/shared/elf-util.h
src/shared/meson.build
src/shared/pcre2-dlopen.c [moved from src/journal/pcre2-dlopen.c with 100% similarity]
src/shared/pcre2-dlopen.h [moved from src/journal/pcre2-dlopen.h with 100% similarity]
src/test/test-dlopen-so.c

index 73265e2c6d69fcb5afbb7d5c7eec5f53d44b0a39..ff9463f7c4be2464345b790a3e0480386f9a1b4d 100644 (file)
@@ -49,8 +49,6 @@ systemd_cat_sources = files('cat.c')
 
 journalctl_sources = files('''
         journalctl.c
-        pcre2-dlopen.c
-        pcre2-dlopen.h
 '''.split())
 
 if install_sysconfdir_samples
index 8cb4a9929880c1f6b909d003e717212a8a8f7af3..cc0fce56d9908a53fd028d18904b32f988711c9e 100644 (file)
@@ -80,7 +80,7 @@ unsigned int (*sym_elf_version)(unsigned int);
 GElf_Phdr *(*sym_gelf_getphdr)(Elf *, int, GElf_Phdr *);
 size_t (*sym_gelf_getnote)(Elf_Data *, size_t, GElf_Nhdr *, size_t *, size_t *);
 
-static int dlopen_dw(void) {
+int dlopen_dw(void) {
         int r;
 
         r = dlopen_many_sym_or_warn(
@@ -123,7 +123,7 @@ static int dlopen_dw(void) {
         return 1;
 }
 
-static int dlopen_elf(void) {
+int dlopen_elf(void) {
         int r;
 
         r = dlopen_many_sym_or_warn(
index cf3d9be12844f4972ca341059af6e57ef47221bf..b28e64cea6519cdd0dda79e67e3e7807f09c322c 100644 (file)
@@ -4,6 +4,9 @@
 #include "json.h"
 
 #if HAVE_ELFUTILS
+int dlopen_dw(void);
+int dlopen_elf(void);
+
 /* Parse an ELF object in a forked process, so that errors while iterating over
  * untrusted and potentially malicious data do not propagate to the main caller's process.
  * If fork_disable_dump, the child process will not dump core if it crashes. */
index 66715e00c3cc3df714ef923b08f5531f6e62531d..dfa025deec6ca618cbcd9916f49c55c92fb5caf0 100644 (file)
@@ -243,6 +243,8 @@ shared_sources = files('''
         parse-argument.h
         parse-socket-bind-item.c
         parse-socket-bind-item.h
+        pcre2-dlopen.c
+        pcre2-dlopen.h
         pe-header.h
         pkcs11-util.c
         pkcs11-util.h
index ea2ef31b1fdd2a28c7f305134ae5571c258fdbd9..002f666ed85556130833111c9438df851d1afb70 100644 (file)
@@ -5,10 +5,12 @@
 
 #include "bpf-dlopen.h"
 #include "cryptsetup-util.h"
+#include "elf-util.h"
 #include "idn-util.h"
 #include "libfido2-util.h"
 #include "macro.h"
 #include "main-func.h"
+#include "pcre2-dlopen.h"
 #include "pwquality-util.h"
 #include "qrcode-util.h"
 #include "tests.h"
@@ -49,6 +51,15 @@ static int run(int argc, char **argv) {
         assert_se(dlopen_bpf() >= 0);
 #endif
 
+#if HAVE_ELFUTILS
+        assert_se(dlopen_dw() >= 0);
+        assert_se(dlopen_elf() >= 0);
+#endif
+
+#if HAVE_PCRE2
+        assert_se(dlopen_pcre2() >= 0);
+#endif
+
         return 0;
 }