Skip to content

Commit de539e0

Browse files
ggouaillardetRalph Castain
authored andcommitted
opal/util: fix a race condition in opal_os_dirpath_create()
always check the permissions of the created directory, in case some one else created the very same directory but with incompatible permissions Signed-off-by: Gilles Gouaillardet <[email protected]> (cherry picked from commit dffaad9)
1 parent 867c841 commit de539e0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

opal/util/os_dirpath.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* University of Stuttgart. All rights reserved.
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
12-
* Copyright (c) 2015 Research Organization for Information Science
12+
* Copyright (c) 2015-2017 Research Organization for Information Science
1313
* and Technology (RIST). All rights reserved.
1414
* Copyright (c) 2016-2017 Intel, Inc. All rights reserved.
1515
* $COPYRIGHT$
@@ -121,6 +121,12 @@ int opal_os_dirpath_create(const char *path, const mode_t mode)
121121
opal_argv_free(parts);
122122
free(tmp);
123123
return OPAL_ERROR;
124+
} else if (i == (len-1) && (mode != (mode & buf.st_mode)) && (0 > chmod(tmp, (buf.st_mode | mode)))) {
125+
opal_show_help("help-opal-util.txt", "dir-mode", true,
126+
tmp, mode, strerror(errno));
127+
opal_argv_free(parts);
128+
free(tmp);
129+
return(OPAL_ERR_PERM); /* can't set correct mode */
124130
}
125131
}
126132

0 commit comments

Comments
 (0)