1
1

Merge pull request #4642 from rhc54/topic/validate

Detect/warn of illegal node names
Этот коммит содержится в:
Ralph Castain 2017-12-20 10:18:43 -08:00 коммит произвёл GitHub
родитель 465842294f 3269f2de66
Коммит ad96fa19d4
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 22 добавлений и 9 удалений

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

@ -12,6 +12,7 @@
# All rights reserved. # All rights reserved.
# Copyright (c) 2014 Research Organization for Information Science # Copyright (c) 2014 Research Organization for Information Science
# and Technology (RIST). All rights reserved. # and Technology (RIST). All rights reserved.
# Copyright (c) 2017 Intel, Inc. All rights reserved.
# $COPYRIGHT$ # $COPYRIGHT$
# #
# Additional copyrights may follow # Additional copyrights may follow
@ -68,3 +69,18 @@ digits in the names:
regexp: %s regexp: %s
Please contact the Open MPI help list for assistance. Please contact the Open MPI help list for assistance.
#
[regex:invalid-name]
While trying to create a regular expression of the node names
used in this application, the regex parser has detected the
presence of an illegal character in the following node name:
node: %s
Node names must be composed of a combination of ascii letters,
digits, dots, and the hyphen ('-') character. See the following
for an explanation:
https://en.wikipedia.org/wiki/Hostname
Please correct the error and try again.

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

@ -209,7 +209,7 @@ int orte_util_nidmap_create(opal_pointer_array_t *pool, char **regex)
char *node; char *node;
char prefix[ORTE_MAX_NODE_PREFIX]; char prefix[ORTE_MAX_NODE_PREFIX];
int i, j, n, len, startnum, nodenum, numdigits; int i, j, n, len, startnum, nodenum, numdigits;
bool found, fullname; bool found;
char *suffix, *sfx, *nodenames; char *suffix, *sfx, *nodenames;
orte_regex_node_t *ndreg; orte_regex_node_t *ndreg;
orte_regex_range_t *range, *rng; orte_regex_range_t *range, *rng;
@ -271,7 +271,6 @@ int orte_util_nidmap_create(opal_pointer_array_t *pool, char **regex)
} }
node = nptr->name; node = nptr->name;
/* determine this node's prefix by looking for first digit char */ /* determine this node's prefix by looking for first digit char */
fullname = false;
len = strlen(node); len = strlen(node);
startnum = -1; startnum = -1;
memset(prefix, 0, ORTE_MAX_NODE_PREFIX); memset(prefix, 0, ORTE_MAX_NODE_PREFIX);
@ -289,18 +288,16 @@ int orte_util_nidmap_create(opal_pointer_array_t *pool, char **regex)
} }
continue; continue;
} }
if ('.' == node[i]) { /* this must be either an alpha, a '.', or '-' */
/* just use the entire name */ if (!isalpha(node[i]) && '-' != node[i] && '.' != node[i]) {
fullname = true; orte_show_help("help-regex.txt", "regex:invalid-name", true, node);
break; return ORTE_ERR_SILENT;
} }
/* this is either an alpha or '-' */
assert(isalpha(node[i]) || '-' == node[i]);
if (startnum < 0) { if (startnum < 0) {
prefix[j++] = node[i]; prefix[j++] = node[i];
} }
} }
if (fullname || startnum < 0) { if (startnum < 0) {
/* can't compress this name - just add it to the list */ /* can't compress this name - just add it to the list */
ndreg = OBJ_NEW(orte_regex_node_t); ndreg = OBJ_NEW(orte_regex_node_t);
ndreg->prefix = strdup(node); ndreg->prefix = strdup(node);