diff options
Diffstat (limited to 'sys/compat/linux/linux_emul.c')
| -rw-r--r-- | sys/compat/linux/linux_emul.c | 47 |
1 files changed, 11 insertions, 36 deletions
diff --git a/sys/compat/linux/linux_emul.c b/sys/compat/linux/linux_emul.c index ab877116b9fc..6a2ea1f26fe5 100644 --- a/sys/compat/linux/linux_emul.c +++ b/sys/compat/linux/linux_emul.c @@ -211,41 +211,6 @@ linux_on_exit(struct proc *p) free(pem, M_LINUX); } -/* - * If a Linux binary is exec'ing something, try this image activator - * first. We override standard shell script execution in order to - * be able to modify the interpreter path. We only do this if a Linux - * binary is doing the exec, so we do not create an EXEC module for it. - */ -int -linux_exec_imgact_try(struct image_params *imgp) -{ - const char *head = (const char *)imgp->image_header; - char *rpath; - int error = -1; - - /* - * The interpreter for shell scripts run from a Linux binary needs - * to be located in /compat/linux if possible in order to recursively - * maintain Linux path emulation. - */ - if (((const short *)head)[0] == SHELLMAGIC) { - /* - * Run our normal shell image activator. If it succeeds attempt - * to use the alternate path for the interpreter. If an - * alternate path is found, use our stringspace to store it. - */ - if ((error = exec_shell_imgact(imgp)) == 0) { - linux_emul_convpath(imgp->interpreter_name, UIO_SYSSPACE, - &rpath, 0, AT_FDCWD); - if (rpath != NULL) - imgp->args->fname_buf = - imgp->interpreter_name = rpath; - } - } - return (error); -} - int linux_common_execve(struct thread *td, struct image_args *eargs) { @@ -271,6 +236,10 @@ linux_common_execve(struct thread *td, struct image_args *eargs) * FreeBSD binary we destroy Linux emuldata thread & proc entries. */ if (SV_CURPROC_ABI() != SV_ABI_LINUX) { + + /* Clear ABI root directory if set. */ + linux_pwd_onexec_native(td); + PROC_LOCK(p); em = em_find(td); KASSERT(em != NULL, ("proc_exec: thread emuldata not found.\n")); @@ -287,7 +256,7 @@ linux_common_execve(struct thread *td, struct image_args *eargs) return (EJUSTRETURN); } -void +int linux_on_exec(struct proc *p, struct image_params *imgp) { struct thread *td; @@ -295,6 +264,7 @@ linux_on_exec(struct proc *p, struct image_params *imgp) #if defined(__amd64__) struct linux_pemuldata *pem; #endif + int error; td = curthread; MPASS((imgp->sysent->sv_flags & SV_ABI_MASK) == SV_ABI_LINUX); @@ -327,6 +297,10 @@ linux_on_exec(struct proc *p, struct image_params *imgp) continue; linux_proc_init(td, othertd, true); } + + /* Set ABI root directory. */ + if ((error = linux_pwd_onexec(td)) != 0) + return (error); } #if defined(__amd64__) /* @@ -339,6 +313,7 @@ linux_on_exec(struct proc *p, struct image_params *imgp) pem->persona |= LINUX_READ_IMPLIES_EXEC; } #endif + return (0); } void |
