From 35ae0168bbdae2eb7029262f49d394046a67860f Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Fri, 15 Jan 2016 18:56:25 +0100 Subject: utils/settrans: improve --chroot functionality Add an option '--chroot-chdir' to settrans and make it chdir to this directory before executing the target program. Also, look up the executable in PATH. With these changes we no longer need to use the shell inside the chroot in the convenience scripts, and hence do not require it to be installed inside the chroot. * utils/fakeroot.sh: Simplify using the new option. * utils/remap.sh: Likewise. * utils/settrans.c (OPT_CHROOT_CHDIR): New constant. (options): New option 'chroot-chdir'. (main): Handle new option. Search for target executable in PATH. * utils/fakeauth.c (main): Likewise. --- utils/fakeauth.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'utils/fakeauth.c') diff --git a/utils/fakeauth.c b/utils/fakeauth.c index ba6a3eef..004cc469 100644 --- a/utils/fakeauth.c +++ b/utils/fakeauth.c @@ -402,9 +402,13 @@ believe it has restricted them to different identities or no identity at all.\ { task_t newtask; process_t proc; - file_t execfile = file_name_lookup (argv[argi], O_EXEC, 0); + char *prefixed_name; + file_t execfile = file_name_path_lookup (argv[argi], getenv ("PATH"), + O_EXEC, 0, &prefixed_name); if (execfile == MACH_PORT_NULL) error (3, errno, "%s", argv[argi]); + if (prefixed_name) + argv[0] = prefixed_name; err = task_create (mach_task_self (), #ifdef KERN_INVALID_LEDGER -- cgit v1.2.3