Reputation: 548
I am trying to execute a Java program inside a chroot jail . I have bind-mounted /dev
, /proc
, /lib
, /lib32
, /lib64
, and /usr/java/jdk1.8.0_251/jre
to directories of the same names inside the jail.
If I try to run jail /usr/java/jdk1.8.0_251/jre/bin/java MainClass
(jail
being a program that sets up the jail and runs a given command inside it), I get an error: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory
.
I add /bin/strace
to the jail and run jail /bin/strace /usr/java/jdk1.8.0_251/java/jre/bin/java MainClass
, and this gives the same error but strace
tells me that the file it is looking for is /usr/java/jdk1.8.0_251/jre/bin/../lib/amd64/jli/libjli.so
(which exists).
Trying to verify that the file exists, I add /bin/bash
to the jail and run jail /bin/bash
. Yes, the file exists. From bash, I run /usr/java/jdk1.8.0_251/jre/bin/java MainClass
. And suddenly it works.
Now, with /bin/bash
in the jail, I see the following behaviour:
jail /usr/java/jdk1.8.0_251/jre/bin/java MainClass
fails (libjli.so
not found)jail /bin/bash -c "/usr/java/jdk1.8.0_251/jre/bin/java MainClass"
works.Happy as I am to have found a workaround, I am totally baffled. Does anyone have any idea why the use of bash
to run the Java interpreter would give a different result from running it directly?
Upvotes: 0
Views: 28