Since we've run into the situation where someone puts a script wrapper around a launcher such as srun, we need to always protect MCA cmd line params with quotes. This means we also need to protect the backend from quotes coming into the system as part of a value, or else the parser gets confused.
So add a new function for wrapping MCA arguments, and tell the backend parser to ignore/remove leading/trailing quotes. cmr=v1.8.3:reviewer=jsquyres This commit was SVN r32686.
Этот коммит содержится в:
родитель
5649841e26
Коммит
4df1aa63f7
@ -131,6 +131,7 @@ OPAL_DECLSPEC int mca_base_cmd_line_setup(opal_cmd_line_t *cmd);
|
||||
OPAL_DECLSPEC int mca_base_cmd_line_process_args(opal_cmd_line_t *cmd,
|
||||
char ***app_env,
|
||||
char ***global_env);
|
||||
OPAL_DECLSPEC void mca_base_cmd_line_wrap_args(char **args);
|
||||
|
||||
/* mca_base_component_compare.c */
|
||||
|
||||
|
@ -136,17 +136,25 @@ static int process_arg(const char *param, const char *value,
|
||||
char ***params, char ***values)
|
||||
{
|
||||
int i;
|
||||
char *new_str;
|
||||
char *p1;
|
||||
|
||||
/* check for quoted value */
|
||||
if ('\"' == value[0] && '\"' == value[strlen(value)-1]) {
|
||||
p1 = strdup(&value[1]);
|
||||
p1[strlen(p1)-1] = '\0';
|
||||
} else {
|
||||
p1 = strdup(value);
|
||||
}
|
||||
|
||||
/* Look to see if we've already got an -mca argument for the same
|
||||
param. Check against the list of MCA param's that we've
|
||||
already saved arguments for. */
|
||||
already saved arguments for - if found, REPLACE the old
|
||||
argument with the new value. */
|
||||
|
||||
for (i = 0; NULL != *params && NULL != (*params)[i]; ++i) {
|
||||
if (0 == strcmp(param, (*params)[i])) {
|
||||
asprintf(&new_str, "%s,%s", (*values)[i], value);
|
||||
free((*values)[i]);
|
||||
(*values)[i] = new_str;
|
||||
(*values)[i] = p1;
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
@ -156,7 +164,8 @@ static int process_arg(const char *param, const char *value,
|
||||
this one away */
|
||||
|
||||
opal_argv_append_nosize(params, param);
|
||||
opal_argv_append_nosize(values, value);
|
||||
opal_argv_append_nosize(values, p1);
|
||||
free(p1);
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
@ -176,3 +185,19 @@ static void add_to_env(char **params, char **values, char ***env)
|
||||
free(name);
|
||||
}
|
||||
}
|
||||
|
||||
void mca_base_cmd_line_wrap_args(char **args)
|
||||
{
|
||||
int i;
|
||||
char *tstr;
|
||||
|
||||
for (i=0; NULL != args && NULL != args[i]; i++) {
|
||||
if (0 == strcmp(args[i], "-mca") ||
|
||||
0 == strcmp(args[i], "--mca")) {
|
||||
i += 2;
|
||||
asprintf(&tstr, "\"%s\"", args[i]);
|
||||
free(args[i]);
|
||||
args[i] = tstr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -55,6 +55,7 @@
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#include "opal/mca/base/base.h"
|
||||
#include "opal/mca/installdirs/installdirs.h"
|
||||
#include "opal/util/argv.h"
|
||||
#include "opal/util/output.h"
|
||||
@ -402,6 +403,9 @@ static void launch_daemons(int fd, short args, void *cbdata)
|
||||
}
|
||||
}
|
||||
|
||||
/* protect the args in case someone has a script wrapper around aprun */
|
||||
mca_base_cmd_line_wrap_args(argv);
|
||||
|
||||
/* setup environment */
|
||||
env = opal_argv_copy(orte_launch_environ);
|
||||
|
||||
|
@ -56,6 +56,7 @@
|
||||
#define SR1_PJOBS
|
||||
#include <lsf/lsbatch.h>
|
||||
|
||||
#include "opal/mca/base/base.h"
|
||||
#include "opal/mca/installdirs/installdirs.h"
|
||||
#include "opal/util/argv.h"
|
||||
#include "opal/util/output.h"
|
||||
@ -278,6 +279,9 @@ static void launch_daemons(int fd, short args, void *cbdata)
|
||||
argv[proc_vpid_index] = strdup(vpid_string);
|
||||
free(vpid_string);
|
||||
|
||||
/* protect the args in case someone has a script wrapper */
|
||||
mca_base_cmd_line_wrap_args(argv);
|
||||
|
||||
if (0 < opal_output_get_verbosity(orte_plm_base_framework.framework_output)) {
|
||||
param = opal_argv_join(argv, ' ');
|
||||
if (NULL != param) {
|
||||
|
@ -66,6 +66,7 @@
|
||||
|
||||
#include "opal/mca/installdirs/installdirs.h"
|
||||
#include "opal/util/output.h"
|
||||
#include "opal/mca/base/base.h"
|
||||
#include "opal/mca/event/event.h"
|
||||
#include "opal/util/argv.h"
|
||||
#include "opal/util/opal_environ.h"
|
||||
@ -602,21 +603,8 @@ static int setup_launch(int *argcptr, char ***argvptr,
|
||||
}
|
||||
}
|
||||
|
||||
/* in the rsh environment, we need to protect args in quotes
|
||||
* as they can contain spaces or special characters */
|
||||
for (i=0; NULL != argv[i]; i++) {
|
||||
if (0 != strcmp(argv[i], "-mca")) {
|
||||
continue;
|
||||
}
|
||||
/* protect the value with quotes if not already
|
||||
* quoted */
|
||||
if ('\"' == argv[i+2][0]) {
|
||||
continue;
|
||||
}
|
||||
(void)asprintf(¶m, "\"%s\"", argv[i+2]);
|
||||
free(argv[i+2]);
|
||||
argv[i+2] = param;
|
||||
}
|
||||
/* protect the params */
|
||||
mca_base_cmd_line_wrap_args(argv);
|
||||
|
||||
value = opal_argv_join(argv, ' ');
|
||||
if (sysconf(_SC_ARG_MAX) < (int)strlen(value)) {
|
||||
@ -634,10 +622,9 @@ static int setup_launch(int *argcptr, char ***argvptr,
|
||||
|
||||
if (0 < opal_output_get_verbosity(orte_plm_base_framework.framework_output)) {
|
||||
param = opal_argv_join(argv, ' ');
|
||||
OPAL_OUTPUT_VERBOSE((1, orte_plm_base_framework.framework_output,
|
||||
"%s plm:rsh: final template argv:\n\t%s",
|
||||
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
|
||||
(NULL == param) ? "NULL" : param));
|
||||
opal_output(0, "%s plm:rsh: final template argv:\n\t%s",
|
||||
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
|
||||
(NULL == param) ? "NULL" : param);
|
||||
if (NULL != param) free(param);
|
||||
}
|
||||
|
||||
|
@ -52,6 +52,7 @@
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#include "opal/mca/base/base.h"
|
||||
#include "opal/mca/installdirs/installdirs.h"
|
||||
#include "opal/util/argv.h"
|
||||
#include "opal/util/output.h"
|
||||
@ -401,6 +402,9 @@ static void launch_daemons(int fd, short args, void *cbdata)
|
||||
}
|
||||
}
|
||||
|
||||
/* protect the args in case someone has a script wrapper around srun */
|
||||
mca_base_cmd_line_wrap_args(argv);
|
||||
|
||||
/* setup environment */
|
||||
env = opal_argv_copy(orte_launch_environ);
|
||||
|
||||
|
@ -1715,12 +1715,6 @@ static int create_app(int argc, char* argv[],
|
||||
opal_setenv("OMPI_MCA_pubsub_orte_server", ompi_server, true, &app->env);
|
||||
}
|
||||
|
||||
/* when launching this way, ensure the app doesn't
|
||||
* pickup the pmi datastore component unless specifically
|
||||
* directed otherwise
|
||||
*/
|
||||
opal_setenv("OMPI_MCA_dstore", "^pmi", false, &app->env);
|
||||
|
||||
/* Did the user request to export any environment variables on the cmd line? */
|
||||
if (opal_cmd_line_is_taken(&cmd_line, "x")) {
|
||||
char* env_set_flag = getenv("OMPI_MCA_mca_base_env_list");
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user