Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_exec.c
Show First 20 Lines • Show All 384 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
struct proc *p = td->td_proc; | struct proc *p = td->td_proc; | ||||
struct nameidata nd; | struct nameidata nd; | ||||
struct ucred *oldcred; | struct ucred *oldcred; | ||||
struct uidinfo *euip = NULL; | struct uidinfo *euip = NULL; | ||||
uintptr_t stack_base; | uintptr_t stack_base; | ||||
struct image_params image_params, *imgp; | struct image_params image_params, *imgp; | ||||
struct vattr attr; | struct vattr attr; | ||||
int (*img_first)(struct image_params *); | |||||
struct pargs *oldargs = NULL, *newargs = NULL; | struct pargs *oldargs = NULL, *newargs = NULL; | ||||
struct sigacts *oldsigacts = NULL, *newsigacts = NULL; | struct sigacts *oldsigacts = NULL, *newsigacts = NULL; | ||||
#ifdef KTRACE | #ifdef KTRACE | ||||
struct ktr_io_params *kiop; | struct ktr_io_params *kiop; | ||||
#endif | #endif | ||||
struct vnode *oldtextvp, *newtextvp; | struct vnode *oldtextvp, *newtextvp; | ||||
struct vnode *oldtextdvp, *newtextdvp; | struct vnode *oldtextdvp, *newtextdvp; | ||||
char *oldbinname, *newbinname; | char *oldbinname, *newbinname; | ||||
▲ Show 20 Lines • Show All 238 Lines • ▼ Show 20 Lines | if (oldcred->cr_svuid != oldcred->cr_uid || | ||||
vn_lock(imgp->vp, LK_SHARED | LK_RETRY); | vn_lock(imgp->vp, LK_SHARED | LK_RETRY); | ||||
change_svuid(imgp->newcred, imgp->newcred->cr_uid); | change_svuid(imgp->newcred, imgp->newcred->cr_uid); | ||||
change_svgid(imgp->newcred, imgp->newcred->cr_gid); | change_svgid(imgp->newcred, imgp->newcred->cr_gid); | ||||
} | } | ||||
} | } | ||||
/* The new credentials are installed into the process later. */ | /* The new credentials are installed into the process later. */ | ||||
/* | /* | ||||
* If the current process has a special image activator it | |||||
* wants to try first, call it. For example, emulating shell | |||||
* scripts differently. | |||||
*/ | |||||
error = -1; | |||||
if ((img_first = imgp->proc->p_sysent->sv_imgact_try) != NULL) | |||||
error = img_first(imgp); | |||||
/* | |||||
* Loop through the list of image activators, calling each one. | * Loop through the list of image activators, calling each one. | ||||
* An activator returns -1 if there is no match, 0 on success, | * An activator returns -1 if there is no match, 0 on success, | ||||
* and an error otherwise. | * and an error otherwise. | ||||
*/ | */ | ||||
error = -1; | |||||
for (i = 0; error == -1 && execsw[i]; ++i) { | for (i = 0; error == -1 && execsw[i]; ++i) { | ||||
if (execsw[i]->ex_imgact == NULL || | if (execsw[i]->ex_imgact == NULL) | ||||
execsw[i]->ex_imgact == img_first) { | |||||
continue; | continue; | ||||
} | |||||
error = (*execsw[i]->ex_imgact)(imgp); | error = (*execsw[i]->ex_imgact)(imgp); | ||||
} | } | ||||
if (error) { | if (error) { | ||||
if (error == -1) | if (error == -1) | ||||
error = ENOEXEC; | error = ENOEXEC; | ||||
goto exec_fail_dealloc; | goto exec_fail_dealloc; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,429 Lines • Show Last 20 Lines |