1 |
2016-06-07 2:35 GMT+08:00 Luca Barbato <lu_zero@g.o>: |
2 |
> On 06/06/16 16:11, 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 |
>> BTW, I built my musl system with the GRS tool, using the |
33 |
>> desktop-amd64-musl-hardened profile. |
34 |
> |
35 |
> would help seeing the wrong results, I guess. |
36 |
|
37 |
The return value of realpath() is NULL, and strerror(errno) is "No |
38 |
such file or directory". |
39 |
|
40 |
|
41 |
Lei |