From 67e03d71423862db11ece7244527d48360a5b47a Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@collabora.com>
Date: Tue, 10 Sep 2019 17:40:35 +0100
Subject: [PATCH] wrap: If using host libc.so.6, also pick up host libidn2.so.0

Recent glibc versions dlopen this instead of libcidn.so.1.

Signed-off-by: Simon McVittie <smcv@collabora.com>
---
 src/wrap.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/src/wrap.c b/src/wrap.c
index 424c142a1..23ee4dc33 100644
--- a/src/wrap.c
+++ b/src/wrap.c
@@ -639,6 +639,27 @@ bind_runtime (FlatpakBwrap *bwrap,
                                       ld_so_in_runtime,
                                       NULL);
 
+              /* Collect miscellaneous libraries that libc might dlopen.
+               * At the moment this is just libidn2. */
+              temp_bwrap = flatpak_bwrap_new (NULL);
+              g_warn_if_fail (mount_runtime_on_scratch->fds == NULL
+                              || mount_runtime_on_scratch->fds->len == 0);
+              flatpak_bwrap_append_bwrap (temp_bwrap, mount_runtime_on_scratch);
+              flatpak_bwrap_add_args (temp_bwrap,
+                                      tool_path,
+                                      "--container", scratch,
+                                      "--link-target", "/run/host",
+                                      "--dest", libdir_on_host,
+                                      "--provider", "/",
+                                      "if-exists:libidn2.so.0",
+                                      NULL);
+              flatpak_bwrap_finish (temp_bwrap);
+
+              if (!pv_bwrap_run_sync (temp_bwrap, NULL, NULL, error))
+                return FALSE;
+
+              g_clear_pointer (&temp_bwrap, flatpak_bwrap_free);
+
               any_libc_from_host = TRUE;
             }
           else
-- 
GitLab