mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 12:32:40 +03:00
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:
commit
47b122d9a5
@ -840,20 +840,20 @@ mc_tmpdir (void)
|
|||||||
|
|
||||||
canonicalize_pathname (buffer);
|
canonicalize_pathname (buffer);
|
||||||
|
|
||||||
if (lstat (buffer, &st) == 0)
|
/* Try to create directory */
|
||||||
|
if (mkdir (buffer, S_IRWXU) != 0)
|
||||||
{
|
{
|
||||||
/* Sanity check for existing directory */
|
if (errno == EEXIST && lstat (buffer, &st) == 0)
|
||||||
if (!S_ISDIR (st.st_mode))
|
{
|
||||||
error = _("%s is not a directory\n");
|
/* Sanity check for existing directory */
|
||||||
else if (st.st_uid != getuid ())
|
if (!S_ISDIR (st.st_mode))
|
||||||
error = _("Directory %s is not owned by you\n");
|
error = _("%s is not a directory\n");
|
||||||
else if (((st.st_mode & 0777) != 0700) && (chmod (buffer, 0700) != 0))
|
else if (st.st_uid != getuid ())
|
||||||
error = _("Cannot set correct permissions for directory %s\n");
|
error = _("Directory %s is not owned by you\n");
|
||||||
}
|
else if (((st.st_mode & 0777) != 0700) && (chmod (buffer, 0700) != 0))
|
||||||
else
|
error = _("Cannot set correct permissions for directory %s\n");
|
||||||
{
|
}
|
||||||
/* Need to create directory */
|
else
|
||||||
if (mkdir (buffer, S_IRWXU) != 0)
|
|
||||||
{
|
{
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("Cannot create temporary directory %s: %s\n"),
|
_("Cannot create temporary directory %s: %s\n"),
|
||||||
|
Loading…
Reference in New Issue
Block a user