Page MenuHomeFreeBSD

etcupdate: Always extract to a temporary tree.
ClosedPublic

Authored by jhb on Apr 19 2021, 9:20 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Nov 4, 7:51 PM
Unknown Object (File)
Sat, Nov 2, 8:54 PM
Unknown Object (File)
Wed, Oct 16, 6:58 PM
Unknown Object (File)
Oct 6 2024, 9:38 PM
Unknown Object (File)
Oct 6 2024, 3:43 PM
Unknown Object (File)
Oct 3 2024, 9:04 PM
Unknown Object (File)
Sep 24 2024, 1:16 AM
Unknown Object (File)
Sep 23 2024, 12:15 PM
Subscribers

Details

Summary

etcupdate has had a somewhat nasty race condition since its creation
in that its state machine can get very confused if it is interrupted
while building the tree to compare against. This is exacerbated by
the fact that etcupdate doesn't emit any output while building the
tree which can take several seconds (especially in recent years with
the addition of the tree-wide buildconfig/installconfig passes).

To mitigate this, always install a new tree into a temporary directory
created via mktemp as was previously done only for dry-runs via -n.
The existing trees are only rotated and the new tree installed as
/var/db/etcupdate/current after the update command has completed.

MFC after: 2 weeks

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

jhb requested review of this revision.Apr 19 2021, 9:20 PM

I think this looks good...
However, one thought did occur to me: do we need a t"rap X rm -rf $newdir" for some value of X so the tree is removed when etcupdate is interrupted?

This revision is now accepted and ready to land.Apr 19 2021, 9:29 PM

Ah yes, please! This has been a pet peeve for a while...

In D29843#669799, @imp wrote:

I think this looks good...
However, one thought did occur to me: do we need a t"rap X rm -rf $newdir" for some value of X so the tree is removed when etcupdate is interrupted?

The callers of the various routines cleanup explicitly when it fails. There is a followup change to trap for SIGINT which fixes Ctrl-C to trigger the cleanups.

This revision was automatically updated to reflect the committed changes.