Skip to content

Previously-present output not removed before rebuilding multiple-output derivation #122

Closed

Description

@civodul

Suppose you have a multiple-output derivation, and one of its output is already present in the store.

When re-building the derivation, the already-present output is not present.

This leads to an assertion failure at "assert(!S_ISDIR(st.st_mode));" in canonicalisePathMetaData_ because the owner of the already-present output is `root', not the build user.

A possible fix would be to remove any already-present outputs before rebuilding the derivation.

Activity

  1. edolstra commented on May 23, 2013

    @edolstra
    Member

    Already-present outputs cannot be removed in general because they might be live.

    We should simply not canonicalize outputs that were already valid.

  2. vcunat commented on Jun 13, 2013

    @vcunat
    Member

    IMO this fails before computeClosure is even called. The derivation would try to install into a path to which it has no permissions. Either you are able to garbage-collect the obstructing path, or I don't see there could be a good way to fix this problem (except for switching to intensional store, but that would be a really big change).

  3. civodul commented on Jun 13, 2013

    @civodul
    ContributorAuthor

    Vladimír Čunát [email protected] skribis:

    IMO this fails before computeClosure is even called. The derivation would try to install into a path to which it has no permissions. Either you are able to garbage-collect the obstructing path, or I don't see there could be a good way to fix this problem (except for switching to intensional store, but that would be a really big change).

    The patch I posted has been tested and fixes the problem AFAICS.

    Ludo’.

  4. edolstra commented on Jun 13, 2013

    @edolstra
    Member

    @vcunat That's not a problem because Nix either performs the build in a chroot (where the obstructing paths are not present) or performs magic hash rewriting.

  5. edolstra commented on Jun 13, 2013

    @edolstra
    Member

    @civodul I've committed a different fix, namely to let computeClosure() skip paths that were already valid. If I'm not mistaken, your fix has a security hole in that it would allow a build that does "ln /etc/shadow $out" (on systems without hard link restrictions). (There actually is a similar security bug in hash rewriting, see cd49ee0.)

  6. vcunat commented on Jun 13, 2013

    @vcunat
    Member

    @edolstra: Ah, I forgot chroots. Is hash rewriting used somewhere (or some analogue of intensional store from your thesis)?

  7. edolstra commented on Jun 13, 2013

    @edolstra
    Member

    Yes, it's used when chroots are disabled/unsupported. You can see it in action if you build a multiple-output derivation, garbage-collect one of the outputs, and then build the derivation again.

  8. civodul commented on Jun 13, 2013

    @civodul
    ContributorAuthor

    Wonderful, thanks!

  9. added a commit that references this issue on Jan 1, 2024
  10. added a commit that references this issue on Feb 26, 2025
    88626cd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions