-
Notifications
You must be signed in to change notification settings - Fork 68
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
prte.c: a prefix of "/" is ok #1848
prte.c: a prefix of "/" is ok #1848
Conversation
I'm not entirely sure that is correct. I'll need to think about it and play with it a bit. I'm sure we did it for a reason, but I also cannot recall why. As for the referenced issue, that is the wrong code path - it is the "else" condition since no cmd line For that issue, it is this code that is the concern: if (0 == strcmp("bin", tmp_basename)) {
char *tmp = tpath;
tpath = pmix_dirname(tmp);
free(tmp); In other words, it is the "bin" in |
Here is why we probably excluded a /* Check if called with fully-qualified path to prte.
(Note: Put this second so can override with --prefix (above). */
tpath = NULL;
if ('/' == argv[0][0]) {
char *tmp_basename = NULL;
tpath = pmix_dirname(argv[0]);
if (NULL != tpath) {
/* Quick sanity check to ensure we got
something/bin/<exec_name> and that the installation
tree is at least more or less what we expect it to
be */
tmp_basename = pmix_basename(tpath);
pmix_output(0, "BASENAME %s", tmp_basename);
if (0 == strcmp("foo", tmp_basename)) {
char *tmp = tpath;
tpath = pmix_dirname(tmp);
pmix_output(0, "TMP %s TPATH %s", tmp, tpath);
free(tmp);
} else {
free(tpath);
tpath = NULL;
}
free(tmp_basename);
}
if (NULL != tpath) {
prte_set_attribute(&dapp->attributes, PRTE_APP_PREFIX_DIR, PRTE_ATTR_GLOBAL,
tpath, PMIX_STRING);
} and here is what happens: $ /foo/prterun -n 1 hostname
[rhc-node01:56680] BASENAME foo
[rhc-node01:56680] TMP /foo TPATH /
bash: //bin/prted: No such file or directory Ignore the error - we know that PRRTE wasn't installed in Anyway, what that means is - minus the In terms of what you are addressing here, it will result in the same So I'm thinking that your change is likely okay, but maybe incomplete. We need to also go into the There is a small change in the above code path - I've added it to your branch. Make sense? |
Think I fixed the |
It's not an error if the prefix ends up being a plain "/". More specifically, if we strip off all trailing "/" characters from the prefix and end up with an empty string, then the prefix is just "/". Protect against a NULL prefix being added to the app's attributes. Protect against a double-/ in the prted cmd path in the ssh launch component. Signed-off-by: Jeff Squyres <[email protected]> Signed-off-by: Ralph Castain <[email protected]>
d4f8a23
to
324a9c6
Compare
Okay, I cleaned this up, squashed it, and pushed. We actually don't need to do @jsquyres Take a final look? |
Looks good to me! |
This is a backport of openpmix/prrte#1848 to ORTE. A prefix of "/" is not an error; there's no need to emit a message and fail. We want to ensure to not pass a double slash in the ssh module to the remote host (i.e., the prefix of "/" followed by "/<bindir>"), so make sure to handle that properly. Signed-off-by: Jeff Squyres <[email protected]>
It's not an error if the prefix ends up being a plain "/". More specifically, if we strip off all trailing "/" characters from the prefix and end up with an empty string, then the prefix is just "/".
Refs open-mpi/ompi#12071
@rhc54 Does this PR look right to you? I can't remember a reason why we thought that a prefix of
/
is actually an error. Specifically: the original code (rightfully) strips off all trailing/
characters. If we end up with an empty string, we declare that to be an error (this is not new -- this scheme goes all the way back to ORTE).But I can't think of a reason why a prefix of
/
is an error. Can you? If we can't think of any reasons why a prefix of/
is an error, this PR adjusts the string handling so that if we end up with an empty string, that means that the prefix is really just/
, so put that back.