logo

overlay

My own overlay for experimentations, use with caution, no support is provided git clone https://hacktivis.me/git/overlay.git

bubblewrap-0.4.0_realpath-workaround.patch (1654B)


  1. https://git.alpinelinux.org/aports/plain/main/bubblewrap/realpath-workaround.patch
  2. Musl realpath() implementation currently depends on /proc which is
  3. not available when setting up pivot root. For the time being just
  4. fallback to a naive normalization algorithm originated from
  5. VoidLinux' xbps. If there was path that would have required advanced
  6. normalizing as provided by realpath() the following parse_mountinfo()
  7. will fail.
  8. diff --git bind-mount.c.orig bind-mount.c
  9. index 045fa0e..d05b540 100644
  10. --- ./bind-mount.c.orig
  11. +++ ./bind-mount.c
  12. @@ -23,6 +23,28 @@
  13. #include "utils.h"
  14. #include "bind-mount.h"
  15. +#ifndef __GLIBC__
  16. +static char *
  17. +normpath(char *path)
  18. +{
  19. + char *seg = NULL, *p = NULL;
  20. +
  21. + for (p = path, seg = NULL; *p; p++) {
  22. + if (strncmp(p, "/../", 4) == 0 || strncmp(p, "/..", 4) == 0) {
  23. + memmove(seg ? seg : p, p+3, strlen(p+3) + 1);
  24. + return normpath(path);
  25. + } else if (strncmp(p, "/./", 3) == 0 || strncmp(p, "/.", 3) == 0) {
  26. + memmove(p, p+2, strlen(p+2) + 1);
  27. + } else if (strncmp(p, "//", 2) == 0 || strncmp(p, "/", 2) == 0) {
  28. + memmove(p, p+1, strlen(p+1) + 1);
  29. + }
  30. + if (*p == '/')
  31. + seg = p;
  32. + }
  33. + return path;
  34. +}
  35. +#endif
  36. +
  37. static char *
  38. skip_token (char *line, bool eat_whitespace)
  39. {
  40. @@ -397,7 +419,11 @@ bind_mount (int proc_fd,
  41. path, so to find it in the mount table we need to do that too. */
  42. resolved_dest = realpath (dest, NULL);
  43. if (resolved_dest == NULL)
  44. +#ifdef __GLIBC__
  45. return 2;
  46. +#else
  47. + resolved_dest = normpath(strdup(dest));
  48. +#endif
  49. mount_tab = parse_mountinfo (proc_fd, resolved_dest);
  50. if (mount_tab[0].mountpoint == NULL)