Merge branch '3025_race_cond_reate_tmp_dir'

* 3025_race_cond_reate_tmp_dir:
  Ticket #3025: race condition when creating temporary directory.
This commit is contained in:
Andrew Borodin 2013-07-05 21:01:54 +04:00
commit 47b122d9a5

View File

@ -840,7 +840,10 @@ mc_tmpdir (void)
canonicalize_pathname (buffer);
if (lstat (buffer, &st) == 0)
/* Try to create directory */
if (mkdir (buffer, S_IRWXU) != 0)
{
if (errno == EEXIST && lstat (buffer, &st) == 0)
{
/* Sanity check for existing directory */
if (!S_ISDIR (st.st_mode))
@ -851,9 +854,6 @@ mc_tmpdir (void)
error = _("Cannot set correct permissions for directory %s\n");
}
else
{
/* Need to create directory */
if (mkdir (buffer, S_IRWXU) != 0)
{
fprintf (stderr,
_("Cannot create temporary directory %s: %s\n"),