Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 449838 - sys-apps/coreutils: multiple invocations of 'cp' may suffer a race condition creating directories
Summary: sys-apps/coreutils: multiple invocations of 'cp' may suffer a race condition ...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo's Team for Core System packages
URL: http://lists.gnu.org/archive/html/bug...
Whiteboard:
Keywords:
Depends on:
Blocks: 449760
  Show dependency tree
 
Reported: 2013-01-02 22:02 UTC by Michał Górny
Modified: 2013-01-11 06:21 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2013-01-02 22:02:09 UTC
Bug 449760 states a semi-random issue of:

  cp: cannot create directory ‘/var/tmp/portage/dev-python/pyxattr-0.5.1/image/usr’: File exists

which most likely means that copying multiple trees into the same location suffers a race condition when creating necessary directories.

AFAICS, make_dir_parents_private() does fail on every mkdir() failure:

  if (mkdir (dir, mkdir_mode) != 0)
    {
      error (0, errno, _("cannot make directory %s"),
             quote (dir));
      return false;
    }

In this case, it'd be probably enough if it checked for EEXIST and restat()-ed the directory instead. Or just ignored the error and tried to copy/mkdir more waiting for ENOTDIR.
Comment 1 SpanKY gentoo-dev 2013-01-04 01:58:19 UTC
pretty sure it's been this way forever.  not sure if it should bother with stating and forcing the mode bits to the expected if someone is doing things in parallel.  make that the user's problem.
Comment 2 SpanKY gentoo-dev 2013-01-11 06:21:30 UTC
should be all set now in the tree; thanks for the report!

Commit message: Fix parallel recursive cp errors w/mkdir
http://sources.gentoo.org/gentoo/src/patchsets/coreutils/8.20/040_all_coreutils-cp-mkdir-eexist.patch?rev=1.1
http://sources.gentoo.org/sys-apps/coreutils/coreutils-8.20-r2.ebuild?rev=1.1