summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_exec.c
diff options
context:
space:
mode:
authorbdrewery <bdrewery@FreeBSD.org>2016-05-26 23:19:39 +0000
committerbdrewery <bdrewery@FreeBSD.org>2016-05-26 23:19:39 +0000
commit01a0751bcd36d3f0da76b1a44cfb617e4b15be69 (patch)
tree6be914a38ad95eeb767ba5f0f88596d95a8d85d0 /sys/kern/kern_exec.c
parentecf7a0caee23c11e92ee375940ea5f0d88e4c81f (diff)
downloadFreeBSD-src-01a0751bcd36d3f0da76b1a44cfb617e4b15be69.zip
FreeBSD-src-01a0751bcd36d3f0da76b1a44cfb617e4b15be69.tar.gz
exec: Provide execpath in imgp for the process_exec hook.
This was previously set after the hook and only if auxargs were present. Now always provide it if possible. MFC after: 2 weeks Reviewed by: kib Sponsored by: EMC / Isilon Storage Division Differential Revision: https://reviews.freebsd.org/D6546
Diffstat (limited to 'sys/kern/kern_exec.c')
-rw-r--r--sys/kern/kern_exec.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index 326b0ce..664b78c 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -568,6 +568,19 @@ interpret:
/* The new credentials are installed into the process later. */
/*
+ * Do the best to calculate the full path to the image file.
+ */
+ if (args->fname != NULL && args->fname[0] == '/')
+ imgp->execpath = args->fname;
+ else {
+ VOP_UNLOCK(imgp->vp, 0);
+ if (vn_fullpath(td, imgp->vp, &imgp->execpath,
+ &imgp->freepath) != 0)
+ imgp->execpath = args->fname;
+ vn_lock(imgp->vp, LK_EXCLUSIVE | LK_RETRY);
+ }
+
+ /*
* If the current process has a special image activator it
* wants to try first, call it. For example, emulating shell
* scripts differently.
@@ -629,6 +642,9 @@ interpret:
crfree(imgp->newcred);
imgp->newcred = NULL;
}
+ imgp->execpath = NULL;
+ free(imgp->freepath, M_TEMP);
+ imgp->freepath = NULL;
/* set new name to that of the interpreter */
NDINIT(&nd, LOOKUP, LOCKLEAF | FOLLOW | SAVENAME,
UIO_SYSSPACE, imgp->interpreter_name, td);
@@ -642,14 +658,6 @@ interpret:
*/
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;
-
if (disallow_high_osrel &&
P_OSREL_MAJOR(p->p_osrel) > P_OSREL_MAJOR(__FreeBSD_version)) {
error = ENOEXEC;
OpenPOWER on IntegriCloud