Mercurial > hg > toybox
comparison toys/other/chroot.c @ 955:144d5ba7d410
Replace users of xexec(toys.optargs) with xexec_optargs(0) to avoid free/reuse bug during argument parsing.
author | Rob Landley <rob@landley.net> |
---|---|
date | Thu, 18 Jul 2013 18:20:03 -0500 |
parents | 786841fdb1e0 |
children | cbb1aca81eca |
comparison
equal
deleted
inserted
replaced
954:1cf9c28012a7 | 955:144d5ba7d410 |
---|---|
16 #include "toys.h" | 16 #include "toys.h" |
17 | 17 |
18 void chroot_main(void) | 18 void chroot_main(void) |
19 { | 19 { |
20 char *binsh[] = {"/bin/sh", "-i", 0}; | 20 char *binsh[] = {"/bin/sh", "-i", 0}; |
21 | |
21 if (chdir(*toys.optargs) || chroot(".")) perror_exit("%s", *toys.optargs); | 22 if (chdir(*toys.optargs) || chroot(".")) perror_exit("%s", *toys.optargs); |
22 xexec(toys.optargs[1] ? toys.optargs+1 : binsh); | 23 if (toys.optargs[1]) xexec_optargs(1); |
24 else xexec(binsh); | |
23 } | 25 } |