iocell icon indicating copy to clipboard operation
iocell copied to clipboard

"iocell exec" only works for commands without arguments

Open kraileth opened this issue 7 years ago • 2 comments

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: https://github.com/iocage/iocage/issues/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

kraileth avatar Aug 26 '17 15:08 kraileth

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

bartekrutkowski avatar Aug 26 '17 18:08 bartekrutkowski

@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. :)

cryptorick avatar Nov 24 '17 20:11 cryptorick