Merge branch 'sw/safe-create-leading-dir-race'
* sw/safe-create-leading-dir-race: safe_create_leading_directories: fix race that could give a false negative
This commit is contained in:
@ -124,9 +124,14 @@ int safe_create_leading_directories(char *path)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (mkdir(path, 0777)) {
|
else if (mkdir(path, 0777)) {
|
||||||
|
if (errno == EEXIST &&
|
||||||
|
!stat(path, &st) && S_ISDIR(st.st_mode)) {
|
||||||
|
; /* somebody created it since we checked */
|
||||||
|
} else {
|
||||||
*pos = '/';
|
*pos = '/';
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (adjust_shared_perm(path)) {
|
else if (adjust_shared_perm(path)) {
|
||||||
*pos = '/';
|
*pos = '/';
|
||||||
return -2;
|
return -2;
|
||||||
|
Reference in New Issue
Block a user