1 |
Boyd Stephen Smith Jr. napisa³(a): |
2 |
> The chroot binary uses the chroot and exec C-library functions to do it's |
3 |
> job. |
4 |
> As library functions, they don't write out error messages and exit the |
5 |
> program directly. (The program calling them might write the messages |
6 |
> somewhere other than stderr or discard them entirely. Also, it may be able |
7 |
> to recover.) Instead they either return an error *code* directly, or place |
8 |
> it in a well-known location that the caller should check. These error |
9 |
> codes |
10 |
> can be mapped to generic messages, but may not completely specify the |
11 |
> error; |
12 |
> in this case, exec (actually, probably even deeper in the bowels of glibc) |
13 |
> tried to open a library and couldn't find it [probably looked in 1/2 dozen |
14 |
> places for it, too :(] and returned the generic "File Not Found" error |
15 |
> code. |
16 |
> The chroot binary knows how it was called ("chroot"), what it was trying to |
17 |
> do (execute "/bin/bash"), and the error code. It crams these bits of |
18 |
> information together to try and give a human-readable error, but computers |
19 |
> are stupid and it comes up with the misleading, "chroot: cannot run command |
20 |
> `/bin/bash': No such file or directory", despite the fact that clearly |
21 |
> exists |
22 |
> in the chroot. |
23 |
> |
24 |
|
25 |
I will add my few words: |
26 |
You are almost correct, but there is defined errno for error with |
27 |
loading dynamic libraries. When I execute binary with missing libraries, |
28 |
I get following error: |
29 |
|
30 |
./busybox: can't load library 'libcrypt.so.0' |
31 |
|
32 |
I think that the actual problem is lack of /lib/ld-*.so.* (usually |
33 |
/lib/ld-linux.so.2). When I remove it, I get the following error: |
34 |
|
35 |
-bash: ./busybox: No such file or directory |
36 |
|
37 |
As you can see, this error is written by bash. However, when dynamic |
38 |
library can't be loaded, error is written by binary itself. Precisely, |
39 |
this is done by /lib/ld-*.so.*. It has few basic library functions |
40 |
compiled in it, so error can be printed even without libc loaded. You |
41 |
can see this by executing 'objdump -Tt /lib/ld-linux.so.2'. Among |
42 |
functions used to load libraries, there is implementation of malloc, |
43 |
getcwd, some string functions, write/read and many more. If you take |
44 |
ld-uClibc.so.0 (if you have it, of course), there are only few of them |
45 |
and you can see that it is really small subset of all libc functions. |
46 |
|
47 |
To sum up, when application can't load its libraries, it is still able |
48 |
to inform a user about it. The misleading 'File not found' error is |
49 |
written only when appropriate /lib/ld-*.so.* can't be found. It is |
50 |
probably caused by way in which dynamic libraries are handled, but I |
51 |
can't tell you more about it. |
52 |
|
53 |
Regards, |
54 |
Marek Wróbel |
55 |
-- |
56 |
gentoo-amd64@g.o mailing list |