Skip to content

Commit

Permalink
opal/util: fix a race condition in opal_os_dirpath_create()
Browse files Browse the repository at this point in the history
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 <gilles@rist.or.jp>
  • Loading branch information
ggouaillardet committed Jan 19, 2017
1 parent 6da4dbb commit dffaad9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion opal/util/os_dirpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2015-2016 Research Organization for Information Science
* Copyright (c) 2015-2017 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2016-2017 Intel, Inc. All rights reserved.
* $COPYRIGHT$
Expand Down Expand Up @@ -121,6 +121,12 @@ int opal_os_dirpath_create(const char *path, const mode_t mode)
opal_argv_free(parts);
free(tmp);
return OPAL_ERROR;
} else if (i == (len-1) && (mode != (mode & buf.st_mode)) && (0 > chmod(tmp, (buf.st_mode | mode)))) {
opal_show_help("help-opal-util.txt", "dir-mode", true,
tmp, mode, strerror(errno));
opal_argv_free(parts);
free(tmp);
return(OPAL_ERR_PERM); /* can't set correct mode */
}
}

Expand Down

0 comments on commit dffaad9

Please sign in to comment.