Gentoo Archives: gentoo-musl

From: Felix Janda <felix.janda@××××××.de>
To: Lei Zhang <zhanglei.april@×××××.com>
Cc: gentoo-musl@l.g.o, Luca Barbato <lu_zero@g.o>
Subject: Re: [gentoo-musl] realpath() gives wrong result on a chroot musl system
Date: Mon, 06 Jun 2016 22:05:50
Message-Id: 20160606220452.GA461@nyan
In Reply to: [gentoo-musl] realpath() gives wrong result on a chroot musl system by Lei Zhang
1 Lei Zhang wrote:
2 > Hi,
3 >
4 > I was trying to run clang (built specifically for musl) on a chroot
5 > musl system, and met some strange issue. After some investigation, it
6 > turns out the function realpath() is giving me wrong results.
7 >
8 > I can reproduce the error with the following code snippet:
9 >
10 > #include <stdio.h>
11 > #include <stdlib.h>
12 > #include <limits.h>
13 >
14 > int main(int argc, char** argv) {
15 > const char* path = "/usr/bin/clang"; // suppose this is a valid path
16 > char resolved[PATH_MAX];
17 > char* ret = realpath(path, resolved);
18 >
19 > if (ret)
20 > printf("%s\n", ret);
21 > }
22 >
23 > If I build it against musl, it gives correct result on my host, but
24 > wrong result on chroot; If I build it against glibc (statically, since
25 > there's no glibc on chroot), it gives correct results on both
26 > environments. So it looks like musl is to blame on the chroot
27 > environment. I haven't yet confirmed if it's a bug.
28 >
29 > Any thoughts?
30
31 With musl, realpath() (and some other things) depend on having a
32 mounted /proc.
33
34 Felix

Replies

Subject Author
Re: [gentoo-musl] realpath() gives wrong result on a chroot musl system Lei Zhang <zhanglei.april@×××××.com>