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)
Fri, Mar 29, 9:25 PM
Unknown Object (File)
Fri, Mar 22, 10:37 PM
Unknown Object (File)
Fri, Mar 22, 10:36 PM
Unknown Object (File)
Fri, Mar 22, 10:36 PM
Unknown Object (File)
Mar 8 2024, 6:14 AM
Unknown Object (File)
Feb 25 2024, 1:44 PM
Unknown Object (File)
Feb 12 2024, 1:15 AM
Unknown Object (File)
Feb 9 2024, 3:04 AM
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.