Closed mortim closed 1 year ago
Can you try strace
-ing the JVM
to see what chdir
does it try to do?
Can you try
strace
-ing theJVM
to see whatchdir
does it try to do?
I tried this but I have the same error:
isolate -p --cg --cg-mem 256000 --run /usr/bin/strace /usr/lib/jvm/java-11-openjdk-amd64/bin/java -cp program.jar: HelloWorld
chdir: No such file or directory
so I strace
-ed in the box directory /var/local/lib/isolate/0/box
and here is the output https://termbin.com/ncbnr
Ah, I see it :)
You did not put --
after--run
as recommended, so -cp
was interpreted as options of isolate
, not of java
. So you requested chdir to a directory called p
.
Ah, I see it :)
You did not put
--
after--run
as recommended, so-cp
was interpreted as options ofisolate
, not ofjava
. So you requested chdir to a directory calledp
.
Another problem...
$ isolate -p --cg --cg-mem 256000 --run -- /usr/lib/jvm/java-11-openjdk-amd64/bin/java -cp program.jar: HelloWorld
Cannot write /sys/fs/cgroup/memory/box-0/tasks: No such file or directory
but cgroups memory is enabled (I'm on Linux Mint 21.1):
$ cat /proc/cmdline
BOOT_IMAGE=/boot/vmlinuz-5.15.0-56-generic root=UUID=765ef15b-0e4a-4eab-99ef-a459d88f2765 ro cgroup_enable=memory swapaccount=1 systemd.unified_cgroup_hierarchy=false systemd.legacy_systemd_cgroup_controller=false quiet splash
Did you --init
the sandbox with --cg
?
Did you
--init
the sandbox with--cg
?
It works now (I created a new sandbox to be sure) but is it normal that the stdout didn't stop. I have to interrupt it with ctrl+c
What do you mean by "stdout didn't stop"?
Maybe you wanted to specify a time limit?
What do you mean by "stdout didn't stop"?
Maybe you wanted to specify a time limit?
$ isolate -p --cg --cg-mem 256000 --run -- /usr/lib/jvm/java-11-openjdk-amd64/bin/java -cp program.jar: HelloWorld
Hello
^CInterrupted
I have to ctrl-c, to interrupt the terminal 'prompt'
What does your program do?
What does your program do?
It just prints "Hello, World"
Strange, indeed... Could you please try stracing it inside the sandbox? (Please use strace -f
, so that strace follows creation of processes and threads.)
Strange, indeed... Could you please try stracing it inside the sandbox? (Please use
strace -f
, so that strace follows creation of processes and threads.)
Could you also post the source of your Java program? From the strace, it seems that it is trying to change settings of the terminal.
Could you also post the source of your Java program? From the strace, it seems that it is trying to change settings of the terminal.
class HelloWorld extends Program {
void algorithm() {
println("Hello");
}
}
What is the Program class?
What is the Program class?
A Java class from the 'program.jar'
Yes, but can you send its source code, too?
Yes, but can you send its source code, too?
Yeah, there are other files in the jar archive https://paste.artemix.org/-/6vphwS
I see... at the end of main()
, there is a call to ((Program)instance).enableKeyTypedInConsole(false);
, which invokes ntime.getRuntime().exec(new String[] { "/bin/sh", "-c", "stty sane </dev/tty" }).waitFor();
. But in order to configure the terminal via stty
, your process has to be the controlling process of your terminal. Sharing terminal control between a sandboxed program and the outside world is inherently insecure. The --tty-hack
option of Isolate could help you, but please read the warnings in the man page.
I see... at the end of
main()
, there is a call to((Program)instance).enableKeyTypedInConsole(false);
, which invokesntime.getRuntime().exec(new String[] { "/bin/sh", "-c", "stty sane </dev/tty" }).waitFor();
. But in order to configure the terminal viastty
, your process has to be the controlling process of your terminal. Sharing terminal control between a sandboxed program and the outside world is inherently insecure. The--tty-hack
option of Isolate could help you, but please read the warnings in the man page.
Okay, it seems more clear 👍
Hi, I tried to run a Java program with a jar file. For this I firstly did:
and I moved the
HelloWorld.class
file and theprogram.jar
file in the box (/var/local/lib/isolate/0/box
)And I did this to run the program:
but I got this error: