Gentoo Archives: gentoo-musl

From: Lei Zhang <zhanglei.april@×××××.com>
To: Felix Janda <felix.janda@××××××.de>
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: Tue, 07 Jun 2016 00:19:45
Message-Id: CAOYuCc0ry8DqnkHT9Bo-v7nbV6zj+Qw4JW6twNwL=pk07grqRw@mail.gmail.com
In Reply to: Re: [gentoo-musl] realpath() gives wrong result on a chroot musl system by Felix Janda
1 2016-06-07 6:04 GMT+08:00 Felix Janda <felix.janda@××××××.de>:
2 > Lei Zhang wrote:
3 >> Hi,
4 >>
5 >> I was trying to run clang (built specifically for musl) on a chroot
6 >> musl system, and met some strange issue. After some investigation, it
7 >> turns out the function realpath() is giving me wrong results.
8 >>
9 >> I can reproduce the error with the following code snippet:
10 >>
11 >> #include <stdio.h>
12 >> #include <stdlib.h>
13 >> #include <limits.h>
14 >>
15 >> int main(int argc, char** argv) {
16 >> const char* path = "/usr/bin/clang"; // suppose this is a valid path
17 >> char resolved[PATH_MAX];
18 >> char* ret = realpath(path, resolved);
19 >>
20 >> if (ret)
21 >> printf("%s\n", ret);
22 >> }
23 >>
24 >> If I build it against musl, it gives correct result on my host, but
25 >> wrong result on chroot; If I build it against glibc (statically, since
26 >> there's no glibc on chroot), it gives correct results on both
27 >> environments. So it looks like musl is to blame on the chroot
28 >> environment. I haven't yet confirmed if it's a bug.
29 >>
30 >> Any thoughts?
31 >
32 > With musl, realpath() (and some other things) depend on having a
33 > mounted /proc.
34
35 You're right!
36
37 After mounting /proc on the chroot system, the issue is resolved. At
38 this point I'm really not sure if this is musl's bug. Is it legit to
39 unconditionally depends on the presence of a mounted /proc?
40
41
42 Lei

Replies

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