From 8663d6d7d38bb27e568abc672b413f03db55c190 Mon Sep 17 00:00:00 2001 From: Simon McVittie <smcv@collabora.com> Date: Thu, 1 Aug 2019 13:52:00 +0100 Subject: [PATCH] wrap: bind_usr: Create /lib etc. as a symlink if required If we are using a "merged-/usr" sysroot as our runtime, and we bind-mount a /lib symlink (which is really /usr/lib) on /lib, it changes the meaning of relative symlinks and breaks our ability to override ld.so correctly. Signed-off-by: Simon McVittie <smcv@collabora.com> --- src/wrap.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/wrap.c b/src/wrap.c index 115bacc65..7ab733d89 100644 --- a/src/wrap.c +++ b/src/wrap.c @@ -260,16 +260,24 @@ bind_usr (FlatpakBwrap *bwrap, "--symlink", target, dest, NULL); } - /* TODO: else if it's a symlink, create the same symlink in the - * container? */ else { g_autofree gchar *path = g_build_filename (host_path, member, NULL); + g_autofree gchar *target = glnx_readlinkat_malloc (-1, path, NULL, NULL); - flatpak_bwrap_add_args (bwrap, - "--ro-bind", path, dest, - NULL); + if (target != NULL) + { + flatpak_bwrap_add_args (bwrap, + "--symlink", target, dest, + NULL); + } + else + { + flatpak_bwrap_add_args (bwrap, + "--ro-bind", path, dest, + NULL); + } } g_clear_pointer (&dest, g_free); -- GitLab