Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

"iocell exec" only works for commands without arguments #28

Open
kraileth opened this issue Aug 26, 2017 · 2 comments
Open

"iocell exec" only works for commands without arguments #28

kraileth opened this issue Aug 26, 2017 · 2 comments

Comments

@kraileth
Copy link

Issuing "iocell exec [running jail] [command]" works as long as [command] does not contain any spaces (e.g. "ls" works but "ls -l" doesn't". Iocage had this problem as well but obviously was able to fix it in the beginning of the year (see here: iocage/iocage#17).

The problem is most likely that iocell uses jexec without having it run a shell. On a German bsd forum I found a hint on how to use jexec properly (i.e. supplying "sh -c" and then the command and arguments). This seems to work.

Here are the details (except for version info I left out the output from commands that behave normally):

# freebsd-version -ku
11.1-RELEASE-p1
11.1-RELEASE-p1

# iocell version
iocell 2.1.2 (2017-06-17)
# iocell activate zroot
# iocell fetch release=11.1-RELEASE
# iocell create release=11.1-RELEASE tag=testjail
# iocell start testjail

# iocell list
JID  UUID                                  BOOT  STATE  TAG       TYPE      IP4  RELEASE
1    9e4c9ab7-8a74-11e7-878c-001d7284b012  off   up     testjail  basejail  -    11.1-RELEASE

# iocell exec testjail ls
bin             compat          etc             lib             mnt             rescue          sbin            usr
boot            dev             etcupdate       libexec         proc            root            tmp             var

# iocell exec testjail "ls -l"
jexec: execvp: ls -l: No such file or directory

# jexec 1 "ls -l"
jexec: execvp: ls -l: No such file or directory

# jexec 1 sh -c "ls -l"
total 72
drwxr-xr-x   2 root  wheel   47 Aug 26 17:35 bin
drwxr-xr-x   9 root  wheel   52 Aug 26 17:35 boot
drwxr-xr-x   2 root  wheel    2 Aug 26 17:38 compat
dr-xr-xr-x   8 root  wheel  512 Aug 26 17:38 dev
drwxr-xr-x  27 root  wheel  108 Aug 26 17:38 etc
drwxr-xr-x   2 root  wheel    3 Aug 26 17:36 etcupdate
drwxr-xr-x   4 root  wheel   56 Jul 21 04:09 lib
drwxr-xr-x   3 root  wheel    5 Aug 26 17:35 libexec
drwxr-xr-x   2 root  wheel    2 Aug 26 17:38 mnt
drwxr-xr-x   2 root  wheel    2 Aug 26 17:38 proc
drwxr-xr-x   2 root  wheel  148 Jul 21 04:09 rescue
drwxr-xr-x   2 root  wheel    6 Aug 26 17:38 root
drwxr-xr-x   2 root  wheel  137 Jul 21 04:10 sbin
drwxrwxrwt   6 root  wheel  256 Aug 26 17:38 tmp
drwxr-xr-x  13 root  wheel   13 Aug 26 17:38 usr
drwxr-xr-x  25 root  wheel   25 Aug 26 17:38 var
@bartekrutkowski
Copy link
Owner

Thanks for the report! Would you have a patch or PR coming too?

@cryptorick
Copy link

@kraileth Try it without the quotes, e.g. iocell exec testjail ls -l. It's working fine for me this way.

(Sorry for being late to the party, but I'm only now getting into this jail thingy. :)

rostwald added a commit to rostwald/iocell that referenced this issue Feb 19, 2024
The command handed over to jexec is already quoted; this might cause
confusion (see bartekrutkowski#28).
This addition clarifies what goes on behind the scenes and also gives
a hint to escape any quotes that might be needed in the command.
rostwald added a commit to rostwald/iocell that referenced this issue Sep 4, 2024
The command handed over to jexec is already quoted; this might cause
confusion (see bartekrutkowski#28).
This addition clarifies what goes on behind the scenes and also gives
a hint to escape any quotes that might be needed in the command.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants