Allow multiple image activators to run on the same execution by changing

imgp->interpreted to a bitmask instead of, functionally, a bool. Each
imgactivator now requires its own flag in interpreted to indicate whether
or not it has already examined argv[0].

Change imgp->interpreted to an unsigned char to add one extra bit for
future use.

With this change, one can execute a shell script from a 64bit host native
make and still get the binmisc image activator to fire for the script
interpreter.  Prior to this, execution would fail.

Phabric:	https://reviews.freebsd.org/D696
Reviewed by:	jhb@
MFC after:	4 weeks
This commit is contained in:
Sean Bruno 2014-09-04 21:31:25 +00:00
parent f96b34b611
commit 65f20a89f1
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=271141
3 changed files with 7 additions and 5 deletions

View File

@ -600,12 +600,12 @@ imgact_binmisc_exec(struct image_params *imgp)
}
/* No interpreter nesting allowed. */
if (imgp->interpreted) {
if (imgp->interpreted & IMGACT_BINMISC) {
mtx_unlock(&interp_list_mtx);
return (ENOEXEC);
}
imgp->interpreted = 1;
imgp->interpreted |= IMGACT_BINMISC;
if (imgp->args->fname != NULL) {
fname = imgp->args->fname;

View File

@ -115,10 +115,10 @@ exec_shell_imgact(imgp)
* Don't allow a shell script to be the shell for a shell
* script. :-)
*/
if (imgp->interpreted)
if (imgp->interpreted & IMGACT_SHELL)
return (ENOEXEC);
imgp->interpreted = 1;
imgp->interpreted |= IMGACT_SHELL;
/*
* At this point we have the first page of the file mapped.

View File

@ -61,7 +61,9 @@ struct image_params {
unsigned long entry_addr; /* entry address of target executable */
unsigned long reloc_base; /* load address of image */
char vmspace_destroyed; /* flag - we've blown away original vm space */
char interpreted; /* flag - this executable is interpreted */
#define IMGACT_SHELL 0x1
#define IMGACT_BINMISC 0x2
unsigned char interpreted; /* mask of interpreters that have run */
char opened; /* flag - we have opened executable vnode */
char *interpreter_name; /* name of the interpreter */
void *auxargs; /* ELF Auxinfo structure pointer */