-
Notifications
You must be signed in to change notification settings - Fork 900
orte/nidmap: correctly handle '-' as a valid hostname character #4627
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -270,22 +270,15 @@ int orte_util_nidmap_create(opal_pointer_array_t *pool, char **regex) | |
} | ||
} | ||
node = nptr->name; | ||
/* determine this node's prefix by looking for first non-alpha char */ | ||
/* determine this node's prefix by looking for first digit char */ | ||
fullname = false; | ||
len = strlen(node); | ||
startnum = -1; | ||
memset(prefix, 0, ORTE_MAX_NODE_PREFIX); | ||
numdigits = 0; | ||
for (i=0, j=0; i < len; i++) { | ||
if (!isalpha(node[i])) { | ||
/* found a non-alpha char */ | ||
if (!isdigit(node[i])) { | ||
/* if it is anything but a digit, we just use | ||
* the entire name | ||
*/ | ||
fullname = true; | ||
break; | ||
} | ||
/* valid hostname characters are ascii letters, digits and the '-' character. */ | ||
if (isdigit(node[i])) { | ||
/* count the size of the numeric field - but don't | ||
* add the digits to the prefix | ||
*/ | ||
|
@@ -296,6 +289,13 @@ int orte_util_nidmap_create(opal_pointer_array_t *pool, char **regex) | |
} | ||
continue; | ||
} | ||
if ('.' == node[i]) { | ||
/* just use the entire name */ | ||
fullname = true; | ||
break; | ||
} | ||
/* this is either an alpha or '-' */ | ||
assert(isalpha(node[i]) || '-' == node[i]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Something doesn't look right here - why would you want to assert if the character is illegal? I should think we wouldn't want the daemon to simply crash. Let's instead do a show_help reporting the unsupported name and return an error code. |
||
if (startnum < 0) { | ||
prefix[j++] = node[i]; | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I understand why a dot character mandates use of the entire name - could you add a comment to explain that option?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, i did not fully understand the initial logic, so i just preserved it.
the initial test was
because
node
is a valid hostname,node[i]
is eitheralpha
digit
-
character.
characteri honestly do not see any reason why
.
should not be treated as a digit, so that meansfullname
is alwaysfalse
and hence i can remove some dead code. do you remember the rationale for thefullname
test ?at that stage,
node
should always be a valid hostname, so i did not feel the need to validate it (and hence theassert()
). that being said, this is not a strong opinion, and i am finenode
is a valid hostname and error otherwiseThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC, the rationale was that I didn't want to assume validity. The user can input a hostname in either a hostfile or a -host option, and we never check it for validity. Thus, the characters could be anything.
I suppose a better option would be to add a validity check in the hostfile and -host parsers, and then have a show_help and error out if a name fails. We could cite https://en.wikipedia.org/wiki/Hostname to explain the error.
Then I'd be comfortable just taking out the assert and assuming validity here, and the need for fullname goes away. Make sense?