bubblewrap-musl.patch (1292B)
1 add normpath(), originally written for xbps. 2 diff --git bind-mount.c.orig bind-mount.c 3 index 045fa0e..d05b540 100644 4 --- a/bubblewrap/bind-mount.c.orig 5 +++ b/bubblewrap/bind-mount.c 6 @@ -23,6 +23,28 @@ 7 #include "utils.h" 8 #include "bind-mount.h" 9 10 +#ifndef __GLIBC__ 11 +static char * 12 +normpath(char *path) 13 +{ 14 + char *seg = NULL, *p = NULL; 15 + 16 + for (p = path, seg = NULL; *p; p++) { 17 + if (strncmp(p, "/../", 4) == 0 || strncmp(p, "/..", 4) == 0) { 18 + memmove(seg ? seg : p, p+3, strlen(p+3) + 1); 19 + return normpath(path); 20 + } else if (strncmp(p, "/./", 3) == 0 || strncmp(p, "/.", 3) == 0) { 21 + memmove(p, p+2, strlen(p+2) + 1); 22 + } else if (strncmp(p, "//", 2) == 0 || strncmp(p, "/", 2) == 0) { 23 + memmove(p, p+1, strlen(p+1) + 1); 24 + } 25 + if (*p == '/') 26 + seg = p; 27 + } 28 + return path; 29 +} 30 +#endif 31 + 32 static char * 33 skip_token (char *line, bool eat_whitespace) 34 { 35 @@ -397,7 +419,11 @@ bind_mount (int proc_fd, 36 path, so to find it in the mount table we need to do that too. */ 37 resolved_dest = realpath (dest, NULL); 38 if (resolved_dest == NULL) 39 +#ifdef __GLIBC__ 40 return 2; 41 +#else 42 + resolved_dest = normpath(strdup(dest)); 43 +#endif 44 45 mount_tab = parse_mountinfo (proc_fd, resolved_dest); 46 if (mount_tab[0].mountpoint == NULL)