Affected component(s) or functionality
qvm-run -p in dom0
Brief summary
Sometimes, I get “; exit” prepended to the pipe passed to a domU.
To Reproduce
Run this in dom0:
echo hello | qvm-run -p some-linux-qube 'cat
x'
See the output
Expected behavior
Text hello is echoed back (with newline). Then, I expect to get an error message about unknown command x.
Actual behavior
I actually get this:
d; exit
hello
Additional context
I have tried to grep ; exit in Qubes sources. I have found that this text comes from prepare_input_for_vmshell, which mixes command and input that is later passed to qubes.VMShell RPC endpoint. I am not sure if I understand the reason behind adding the ; exit. Maybe all the input (including the command) is passed to sh (through qubes.VMShell) through stdin, so the “; exit” is a hack for ensuring that command ends there. It seems to work well in many cases, but not always.
This one is a wrong behavior for an invalid command, which does not matter so much. The original issue is about a wrong behavior for a valid command, which is worse.
Solutions you've tried
Sometimes, just trimming trailing whitespace solves the problem, even for multi-line command. (It is not the case of the command there.)
Qubes OS version R4.0
Affected component(s) or functionality qvm-run -p in dom0
Brief summary Sometimes, I get “; exit” prepended to the pipe passed to a domU.
To Reproduce
Run this in dom0:
echo hello | qvm-run -p some-linux-qube 'cat x'
See the output
Expected behavior Text
hello
is echoed back (with newline). Then, I expect to get an error message about unknown commandx
.Actual behavior
I actually get this:
Additional context
I have tried to grep
; exit
in Qubes sources. I have found that this text comes fromprepare_input_for_vmshell
, which mixes command and input that is later passed to qubes.VMShell RPC endpoint. I am not sure if I understand the reason behind adding the; exit
. Maybe all the input (including the command) is passed to sh (through qubes.VMShell) through stdin, so the “; exit” is a hack for ensuring that command ends there. It seems to work well in many cases, but not always.BTW, there are also some other rough edges:
This one is a wrong behavior for an invalid command, which does not matter so much. The original issue is about a wrong behavior for a valid command, which is worse.
Solutions you've tried
Sometimes, just trimming trailing whitespace solves the problem, even for multi-line command. (It is not the case of the command there.)
Relevant documentation you've consulted
Related, non-duplicate issues
https://github.com/QubesOS/qubes-issues/issues/4165