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
This commit is contained in:
parent
881010f05d
commit
1afd78b34d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=300793
@ -567,6 +567,19 @@ do_execve(td, args, mac_p)
|
||||
}
|
||||
/* 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
|
||||
@ -629,6 +642,9 @@ do_execve(td, args, mac_p)
|
||||
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 @@ do_execve(td, args, mac_p)
|
||||
*/
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user