anatol / booster

Fast and secure initramfs generator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Implement events synchronization mechanism (pubsub?)

anatol opened this issue · comments

Booster has a few points that depend on results of other operations, e.g.

  • yubikey unlocking can be started only after a Yubikey inserted/detected
  • Clevis/tang requires network interface to be initialized
  • password needs to be entered by user before unlocking some slot

Currently booster uses either hacky delays or single-thread processing to make sure the events are ordered.

Replace it with better synchronization mechanism. It will help to avoid race conditions in the code.

One option is to use events pub-sub. Operations can be launched with multiple goroutines. If a thread needs a subsystem ready (e.g. network is initialized; a new Yubikey appeared; ...) then it subscribes to a specific pub-sub channel and waits for event.

I think I could rework the code I PR'd to fix the TPM race condition into something that could be used for the other things listed too. Just need to find some time for it.

Each of these need to wait for some condition that may or may not ever be satisfied, just like unlocking the TPM.
A simple channel might work for this.