diff options
| author | Konstantin Belousov <kib@FreeBSD.org> | 2009-03-17 12:53:28 +0000 |
|---|---|---|
| committer | Konstantin Belousov <kib@FreeBSD.org> | 2009-03-17 12:53:28 +0000 |
| commit | 3ff063577b555c4840b32b8fafaf630a93d46251 (patch) | |
| tree | d8727e59a354ad0a3bffae93cc41c3c6011692c8 /sys/kern/kern_exec.c | |
| parent | a4f2b2b0c66602ea76b74caf09f3229024cea9a9 (diff) | |
Notes
Diffstat (limited to 'sys/kern/kern_exec.c')
| -rw-r--r-- | sys/kern/kern_exec.c | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index af6c9e428c24..f36f8037920e 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -379,6 +379,8 @@ do_execve(td, args, mac_p) imgp->ps_strings = 0; imgp->auxarg_size = 0; imgp->args = args; + imgp->execpath = imgp->freepath = NULL; + imgp->execpathp = 0; #ifdef MAC error = mac_execve_enter(imgp, mac_p); @@ -519,6 +521,15 @@ interpret: * of the sv_copyout_strings/sv_fixup operations require the vnode. */ VOP_UNLOCK(imgp->vp, 0); + + /* + * Do the best to calculate the full path to the image file. + */ + if (imgp->auxargs != NULL && + ((args->fname != NULL && args->fname[0] == '/') || + vn_fullpath(td, imgp->vp, &imgp->execpath, &imgp->freepath) != 0)) + imgp->execpath = args->fname; + /* * Copy out strings (args and env) and initialize stack base */ @@ -859,6 +870,8 @@ exec_fail_dealloc: if (imgp->object != NULL) vm_object_deallocate(imgp->object); + free(imgp->freepath, M_TEMP); + if (error == 0) { /* * Stop the process here if its stop event mask has @@ -1164,18 +1177,24 @@ exec_copyout_strings(imgp) register_t *stack_base; struct ps_strings *arginfo; struct proc *p; + size_t execpath_len; int szsigcode; /* * Calculate string base and vector table pointers. * Also deal with signal trampoline code for this exec type. */ + if (imgp->execpath != NULL && imgp->auxargs != NULL) + execpath_len = strlen(imgp->execpath) + 1; + else + execpath_len = 0; p = imgp->proc; szsigcode = 0; arginfo = (struct ps_strings *)p->p_sysent->sv_psstrings; if (p->p_sysent->sv_szsigcode != NULL) szsigcode = *(p->p_sysent->sv_szsigcode); destp = (caddr_t)arginfo - szsigcode - SPARE_USRSPACE - + roundup(execpath_len, sizeof(char *)) - roundup((ARG_MAX - imgp->args->stringspace), sizeof(char *)); /* @@ -1186,6 +1205,15 @@ exec_copyout_strings(imgp) szsigcode), szsigcode); /* + * Copy the image path for the rtld. + */ + if (execpath_len != 0) { + imgp->execpathp = (uintptr_t)arginfo - szsigcode - execpath_len; + copyout(imgp->execpath, (void *)imgp->execpathp, + execpath_len); + } + + /* * If we have a valid auxargs ptr, prepare some room * on the stack. */ @@ -1202,9 +1230,8 @@ exec_copyout_strings(imgp) * for argument of Runtime loader. */ vectp = (char **)(destp - (imgp->args->argc + - imgp->args->envc + 2 + imgp->auxarg_size) * + imgp->args->envc + 2 + imgp->auxarg_size + execpath_len) * sizeof(char *)); - } else { /* * The '+ 2' is for the null pointers at the end of each of |
