From 5780790772450753b1e72457dbc11bafb3cba1c2 Mon Sep 17 00:00:00 2001 From: Enno Boland Date: Wed, 13 Jun 2018 13:17:42 +0200 Subject: [PATCH] bubblewrap: resolve paths as good as possible, even if realpath fails. --- .../patches/realpath-workaround.patch | 53 ++++++++++++++----- srcpkgs/bubblewrap/template | 2 +- 2 files changed, 41 insertions(+), 14 deletions(-) diff --git a/srcpkgs/bubblewrap/patches/realpath-workaround.patch b/srcpkgs/bubblewrap/patches/realpath-workaround.patch index d25b31a5bfc..434da769657 100644 --- a/srcpkgs/bubblewrap/patches/realpath-workaround.patch +++ b/srcpkgs/bubblewrap/patches/realpath-workaround.patch @@ -1,19 +1,46 @@ -Musl realpath() implementation currently depends on /proc which is -not available when setting up pivot root. For the time being just -fallback to given path if realpath() fails. If there was symlinks -that would have required normalizing the following parse_mountinfo() -will fail. - -diff --git bind-mount.c bind-mount.c -index 7d3543f..c33b701 100644 ---- bind-mount.c +add normpath(), originally written for xbps. +diff --git bind-mount.c.orig bind-mount.c +index 045fa0e..d05b540 100644 +--- bind-mount.c.orig +++ bind-mount.c -@@ -397,7 +397,7 @@ bind_mount (int proc_fd, +@@ -23,6 +23,28 @@ + #include "utils.h" + #include "bind-mount.h" + ++#ifndef __GLIBC__ ++static char * ++normpath(char *path) ++{ ++ char *seg = NULL, *p = NULL; ++ ++ for (p = path, seg = NULL; *p; p++) { ++ if (strncmp(p, "/../", 4) == 0 || strncmp(p, "/..", 4) == 0) { ++ memmove(seg ? seg : p, p+3, strlen(p+3) + 1); ++ return normpath(path); ++ } else if (strncmp(p, "/./", 3) == 0 || strncmp(p, "/.", 3) == 0) { ++ memmove(p, p+2, strlen(p+2) + 1); ++ } else if (strncmp(p, "//", 2) == 0 || strncmp(p, "/", 2) == 0) { ++ memmove(p, p+1, strlen(p+1) + 1); ++ } ++ if (*p == '/') ++ seg = p; ++ } ++ return path; ++} ++#endif ++ + static char * + skip_token (char *line, bool eat_whitespace) + { +@@ -397,7 +419,11 @@ bind_mount (int proc_fd, path, so to find it in the mount table we need to do that too. */ resolved_dest = realpath (dest, NULL); if (resolved_dest == NULL) -- return 2; -+ resolved_dest = strdup (dest); - ++#ifdef __GLIBC__ + return 2; ++#else ++ resolved_dest = normpath(strdup(dest)); ++#endif + mount_tab = parse_mountinfo (proc_fd, resolved_dest); if (mount_tab[0].mountpoint == NULL) diff --git a/srcpkgs/bubblewrap/template b/srcpkgs/bubblewrap/template index 418d1f79db7..b22968fd06f 100644 --- a/srcpkgs/bubblewrap/template +++ b/srcpkgs/bubblewrap/template @@ -1,7 +1,7 @@ # Template file for 'bubblewrap' pkgname=bubblewrap version=0.2.1 -revision=1 +revision=2 build_style=gnu-configure hostmakedepends="automake pkg-config" makedepends="libcap-devel"