containers/libkrun

Args with '--' don't parse correctly

robxu9 opened this issue · 1 comments

robxu9 commented

Given a test program, /test-args, with the following content:

#!/bin/sh

echo $@

When I use chroot_vm.c to call /test-args with the arguments 1 2 3 4 5 6, I get back 1 2 3 4 5 6 respectively.

However, when I use chroot_vm.c to call /test-args with the arguments -- 1 2 3 4 5 6, I get back no arguments.

It seems that libkrun is stripping out arguments entirely if they contain --. I ran into this when I was trying to get tini to cooperate and realized that it wasn't seeing any parameters if the args contained a --.

Note that this doesn't happen if I don't use krun_set_exec at all and instead pivot to using /.krun_config.json to set my command, which works fine.

slp commented

The krun_set_exec method has, indeed, many shortcomings coming from the fact that it relies on the kernel command line to pass the arguments to init.c. Many of those shortcoming can't be fixed without a significant amount of hackery, and since nowadays the preferred way of passing arguments is through /.krun_config.json, I don't think it's worth investing time it was it will likely be a suboptimal solution.