Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/mca/schizo/base/help-schizo-base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,11 @@ An incorrect value for the "--stream-buffering" option was given:
Valid values are limited to 0, 1, or 2. Your application will continue, but
please correct your command line in the future.
#
[duplicate-value]
WARNING: an MCA parameter was listed more than once on the command line, or
[missing-envar-param]
Warning: Could not find the environment variable: %s
#
[duplicate-mca-value]
Error: an MCA parameter was listed more than once on the command line, or
multiple times in one or more files, but with conflicting values:

Param: %s
Expand Down
47 changes: 2 additions & 45 deletions src/mca/schizo/ompi/schizo_ompi.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Copyright (c) 2013-2020 Intel, Inc. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2018-2020 IBM Corporation. All rights reserved.
* Copyright (c) 2018-2021 IBM Corporation. All rights reserved.
* Copyright (c) 2021 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
Expand Down Expand Up @@ -452,7 +452,7 @@ static int check_cache_noadd(char ***c1, char ***c2,
if (0 != strcmp(cachevals[k], p2)) {
/* this is an error */
prte_show_help("help-schizo-base.txt",
"duplicate-value", true,
"duplicate-mca-value", true,
p1, p2, cachevals[k]);
return PRTE_ERR_BAD_PARAM;
}
Expand Down Expand Up @@ -1162,40 +1162,6 @@ static int parse_env(prte_cmd_line_t *cmd_line,
}
prte_argv_free(envlist);

/* now look for -x options - not allowed to conflict with a -mca option */
if (0 < (j = prte_cmd_line_get_ninsts(cmd_line, "x"))) {
for (i = 0; i < j; ++i) {
/* the value is the envar */
pval = prte_cmd_line_get_param(cmd_line, "x", i, 0);
p1 = strip_quotes(pval->value.data.string);
/* if there is an '=' in it, then they are setting a value */
if (NULL != (p2 = strchr(p1, '='))) {
*p2 = '\0';
++p2;
} else {
p2 = getenv(p1);
if (NULL == p2) {
free(p1);
continue;
}
}
/* not allowed to duplicate anything from an MCA param on the cmd line */
rc = check_cache_noadd(&cache, &cachevals, p1, p2);
if (PRTE_SUCCESS != rc) {
prte_argv_free(cache);
prte_argv_free(cachevals);
free(p1);
prte_argv_free(xparams);
prte_argv_free(xvals);
return rc;
}
/* cache this for later inclusion */
prte_argv_append_nosize(&xparams, p1);
prte_argv_append_nosize(&xvals, p2);
free(p1);
}
}

/* process the resulting cache into the dstenv */
if (NULL != cache) {
for (i=0; NULL != cache[i]; i++) {
Expand All @@ -1211,15 +1177,6 @@ static int parse_env(prte_cmd_line_t *cmd_line,
prte_argv_free(cache);
prte_argv_free(cachevals);

/* add the -x values */
if (NULL != xparams) {
for (i=0; NULL != xparams[i]; i++) {
prte_setenv(xparams[i], xvals[i], true, dstenv);
}
prte_argv_free(xparams);
prte_argv_free(xvals);
}

return PRTE_SUCCESS;
}

Expand Down
84 changes: 81 additions & 3 deletions src/mca/schizo/prte/schizo_prte.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Copyright (c) 2013-2020 Intel, Inc. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2018 IBM Corporation. All rights reserved.
* Copyright (c) 2018-2021 IBM Corporation. All rights reserved.
* Copyright (c) 2021 Nanook Consulting. All rights reserved.
* $COPYRIGHT$
*
Expand Down Expand Up @@ -545,8 +545,12 @@ static int parse_env(prte_cmd_line_t *cmd_line,
char ***dstenv,
bool cmdline)
{
int i, j;
char *p1;
int i, j, n;
char *p1, *p2;
char **env;
prte_value_t *pval;
char **xparams=NULL, **xvals=NULL;
char *param, *value;

prte_output_verbose(1, prte_schizo_base_framework.framework_output,
"%s schizo:prte: parse_env",
Expand All @@ -567,6 +571,80 @@ static int parse_env(prte_cmd_line_t *cmd_line,
}
}

env = *dstenv;

/* now look for -x options - not allowed to conflict with a -mca option */
if (NULL != cmd_line && 0 < (j = prte_cmd_line_get_ninsts(cmd_line, "x"))) {
for (i = 0; i < j; ++i) {
/* the value is the envar */
pval = prte_cmd_line_get_param(cmd_line, "x", i, 0);
p1 = strip_quotes(pval->value.data.string);
/* if there is an '=' in it, then they are setting a value */
if (NULL != (p2 = strchr(p1, '='))) {
*p2 = '\0';
++p2;
} else {
p2 = getenv(p1);
if (NULL == p2) {
prte_show_help("help-schizo-base.txt",
"missing-envar-param", true,
p1);
free(p1);
continue;
}
}

/* check if it is already present in the environment */
for (n=0; NULL != env && NULL != env[n]; n++) {
param = strdup(env[n]);
value = strchr(param, '=');
*value = '\0';
value++;
/* check if parameter is already present */
if (0 == strcmp(param, p1)) {
/* we do have it - check for same value */
if (0 != strcmp(value, p2)) {
/* this is an error - different values */
prte_show_help("help-schizo-base.txt",
"duplicate-mca-value", true,
p1, p2, value);
free(param);
return PRTE_ERR_BAD_PARAM;
}
}
free(param);
}

/* check if we already processed a conflicting -x version with MCA prefix */
if (NULL != xparams) {
for (i=0; NULL != xparams[i]; i++) {
if (0 == strncmp("PRTE_MCA_", p1, strlen("PRTE_MCA_")) ||
0 == strncmp("OMPI_MCA_", p1, strlen("OMPI_MCA_"))) {
/* this is an error - different values */
prte_show_help("help-schizo-base.txt",
"duplicate-mca-value", true,
p1, p2, xvals[i]);
return PRTE_ERR_BAD_PARAM;
}
}
}

/* cache this for later inclusion - do not modify dstenv in this loop */
prte_argv_append_nosize(&xparams, p1);
prte_argv_append_nosize(&xvals, p2);
free(p1);
}
}

/* add the -x values */
if (NULL != xparams) {
for (i=0; NULL != xparams[i]; i++) {
prte_setenv(xparams[i], xvals[i], true, dstenv);
}
prte_argv_free(xparams);
prte_argv_free(xvals);
}

return PRTE_SUCCESS;
}

Expand Down