Skip to content

Commit 8197efa

Browse files
committed
opal/mca: check if the user home directory is NULL
This commit fixes an issue in the MCA base variable system. The code was retrieving the user home directory (from HOME) and attempting to use it to build a search path for config files. In this case user-level configuration directories have been enabled so the appropriate thing to do is to print an error message and return. This commit makes that change. It does not ensure that HOME is set correctly. Signed-off-by: Nathan Hjelm <hjelmn@google.com>
1 parent eeb3d7f commit 8197efa

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

opal/mca/base/mca_base_var.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -403,9 +403,6 @@ int mca_base_var_cache_files(bool rel_path_search)
403403
char *tmp;
404404
int ret;
405405

406-
/* We may need this later */
407-
home = (char*)opal_home_directory();
408-
409406
if (NULL == cwd) {
410407
cwd = (char *) malloc(sizeof(char) * MAXPATHLEN);
411408
if( NULL == (cwd = getcwd(cwd, MAXPATHLEN) )) {
@@ -415,6 +412,13 @@ int mca_base_var_cache_files(bool rel_path_search)
415412
}
416413

417414
#if OPAL_WANT_HOME_CONFIG_FILES
415+
/* We may need this later */
416+
home = (char*)opal_home_directory();
417+
if (NULL == home) {
418+
opal_output(0, "Error: Unable to get the user home directory\n");
419+
return OPAL_ERROR;
420+
}
421+
418422
opal_asprintf(&mca_base_var_files, "%s"OPAL_PATH_SEP".openmpi" OPAL_PATH_SEP
419423
"mca-params.conf%c%s" OPAL_PATH_SEP "openmpi-mca-params.conf",
420424
home, ',', opal_install_dirs.sysconfdir);

0 commit comments

Comments
 (0)