mcexec/execve: fix shebangs handling
There were mainly two problems with shebangs: - Suffix arguments handling e.g. '#!/bin/sh -x' - Recursive handling e.g. script1 fetchs '#!/path/to/script2' and script2 itself has a shebang - (did I say two?) running shebang would replace argv[optind] instead of appending e.g. script with '#!/bin/sh' and running './script -c' would run '/bin/sh -c' instead of '/bin/sh ./script -c' There also are two places where this needs parsing: - starting a fresh program from mcexec - starting a new program from execve in mcexec The first was easy to fix as we already had argv around, but the later required a new way to transfer the 'new argv elements from the script' to mckernel to append before its argv -- it used to be 'desc->shell_path' but that was no longer used at some point and just one keyword is not enough to handle this properly. This commit does: - Refactors the lookup_path + load_elf_desc that was only done at most twice in its own function that loops indefinitely and use that in both situations described above - Transmits the argv addition in the transfer to mckernel after the desc; mckernel allocates 4 pages (hardcoded) for the descs and we will hopefully have room for the script arguments on top of that... (there is no guard!!!) - Change flatten_strings to allow prepending a flattened string instead of a single string. Note that the flatten_string change also brought in a difference in the format, to have the full length embedded within the string, the latest slot that used to be zeroes now contains the position of the end of the buffer (where the last+1 string would be if there had been one) This required a trivial change in mckernel prepare args function that used this property for no real reason. Hopefully things work™, this probably warrants adding a couple of new ostests... - create a couple of scripts with recursive invocation/arguments and check their own argv. - execute "mcexec script args" and "mcexec sh -c 'script args'" Change-Id: I2cf9cde5c07c9293f730de89c9731bd93dbfa789 Refs: #1115
This commit is contained in:
@ -204,7 +204,6 @@ struct program_load_desc {
|
||||
int uti_use_last_cpu; /* Work-around not to share CPU with OpenMP thread */
|
||||
int nr_processes;
|
||||
int process_rank;
|
||||
char shell_path[SHELL_PATH_MAX_LEN];
|
||||
__cpu_set_unit cpu_set[PLD_CPU_SET_SIZE];
|
||||
int profile;
|
||||
struct program_image_section sections[0];
|
||||
|
||||
Reference in New Issue
Block a user