1
1

Cleanup the passing of MCA params on the orted cmd line in ssh by ensuring that we quote all values since they could be multi-word and/or contain special characters. Thanks to Dirk Schubert for pointing it out.

cmr=v1.8.2:reviewer=jsquyres

This commit was SVN r32280.
Этот коммит содержится в:
Ralph Castain 2014-07-22 18:22:06 +00:00
родитель 408474d2d8
Коммит a94a97bd50

Просмотреть файл

@ -572,18 +572,15 @@ static int setup_launch(int *argcptr, char ***argvptr,
*/ */
cnt = opal_argv_count(orted_cmd_line); cnt = opal_argv_count(orted_cmd_line);
for (i=0; i < cnt; i+=3) { for (i=0; i < cnt; i+=3) {
/* check if the specified option is more than one word - all /* there could be multi-word values here, or
* others have already been passed * values with special characters, so protect
*/ * the value with quotes */
if (NULL != strchr(orted_cmd_line[i+2], ' ')) { (void)asprintf(&param, "\"%s\"", orted_cmd_line[i+2]);
/* must add quotes around it */ /* now pass it along */
(void)asprintf(&param, "\"%s\"", orted_cmd_line[i+2]); opal_argv_append(&argc, &argv, orted_cmd_line[i]);
/* now pass it along */ opal_argv_append(&argc, &argv, orted_cmd_line[i+1]);
opal_argv_append(&argc, &argv, orted_cmd_line[i]); opal_argv_append(&argc, &argv, param);
opal_argv_append(&argc, &argv, orted_cmd_line[i+1]); free(param);
opal_argv_append(&argc, &argv, param);
free(param);
}
} }
/* unless told otherwise... */ /* unless told otherwise... */
@ -612,20 +609,16 @@ static int setup_launch(int *argcptr, char ***argvptr,
} }
} }
if (!found) { if (!found) {
char *p2;
/* add it */ /* add it */
opal_argv_append(&argc, &argv, "-mca"); opal_argv_append(&argc, &argv, "-mca");
opal_argv_append(&argc, &argv, param); opal_argv_append(&argc, &argv, param);
/* if the value has a special character in it, /* there could be multi-word values here, or
* then protect it with quotes * values with special characters, so protect
*/ * the value with quotes */
if (NULL != strchr(value, ';')) { (void)asprintf(&p2, "\"%s\"", value);
char *p2; opal_argv_append(&argc, &argv, p2);
(void)asprintf(&p2, "\"%s\"", value); free(p2);
opal_argv_append(&argc, &argv, p2);
free(p2);
} else {
opal_argv_append(&argc, &argv, value);
}
} }
free(param); free(param);
} }