Skip to content

Add deploy - #170

Open
frederic-hoerni wants to merge 2 commits into
mainfrom
add-deploy
Open

frederic-hoerni wants to merge 2 commits into
mainfrom
add-deploy

Conversation

@frederic-hoerni

Copy link
Copy Markdown
Contributor

This PR is part of the merging of encrypt-cloud-image within nullboot and brings the sub-command deploy in.

Main modifications:

  • Add sub-command deploy. The code mostly come from https://github.com/canonical/encrypt-cloud-image, revision a4824d1f836abd3035dd2f9ef81909a96a9f4466
  • nullbootctl install now handles the new JSON format of cloudimg-rootfs.sealed-key, and converts the legacy format to the new format.

Other modifications:

  • exec: Replace custom TeeReader by standard lib io.TeeReader.
  • Add tests for encrypt and deploy
  • Remove unused functions

Limitations:

  • nullboot versions <= 0.6.0 are not compatible with cloud images produced by nullbootctl deploy (because of the new JSON format for cloudimg-rootfs.sealed-key).

This has been tested using the unit tests, ubuntu-boot-test, and manual testing (see README-test-encrypt-deploy.md).

This PR does not deal with: merging documentation and CI jobs, aligning ubuntu-boot-test (other PRs will take care of that)

@frederic-hoerni frederic-hoerni self-assigned this Nov 24, 2026
Comment thread cmd/nullbootctl/deploy_test.go Resolved
Comment thread cmd/nullbootctl/deploy_test.go Resolved
Comment thread cmd/nullbootctl/encrypt_test.go Resolved
Comment thread cmd/nullbootctl/encrypt_test.go Resolved
Comment thread cmd/nullbootctl/main.go Resolved
Comment thread internal/exec/exec.go Resolved
Comment thread README-test-encrypt-deploy.md Resolved
Comment thread README-test-encrypt-deploy.md Resolved
Comment thread cmd/nullbootctl/deploy.go Resolved
Detailed modifications:

- Add subcommand deploy
- exec: Replace custom TeeReader by standard lib io.TeeReader.
  This also fixes a bug where garbage bytes could be written to the stdout or
  stderr buffers used by the caller. For the record and clarification, Here is a
  summary of what should have been fixed if all the code had not been replaced:
  -	if n, err := t.w.Write(p); err != nil {
  +	if n, err := t.w.Write(p[:n]); err != nil {

- Add tests for encrypt and deploy
- Remove unused functions

The code for deploy mostly comes from encrypt-cloud-image:
  https://github.com/canonical/encrypt-cloud-image
  revision a4824d1f836abd3035dd2f9ef81909a96a9f4466

Note: images made with nullbootctl deploy cannot be used with
nullbootctl <= 0.6.0, as the new format of cloudimg-rootfs.sealed-key
is not compatible.
The sealed key file (/boot/efi/device/fde/cloudimg-rootfs.sealed-key) can have
2 formats:
- legacy (binary starting with a magic 'UKS$')
- JSON

'nullbootctl install' only handled the legacy format.

This change makes it handle both formats. When a reseal is done from a sealed
key file in the legacy format, it is converted to the new JSON format.

We need to handle both, as:
- Existing guest instances which apt-upgrade nullboot need nullbootctl to be
  compatible with the legacy format (which was produced by encrypt-cloud-image
  v25.12.0).
- 'nullbootctl deploy' creates the sealed key file in the new JSON format.

Test made in a guest with legacy format:
  $ sudo nullbootctl install
  ...
  ReasealKey: read key data in legacy format
  ...
  ReasealKey: key data not in legacy format. Assuming JSON format...

(it reseals twice)

@dimakuv dimakuv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All my comments were fixed, approving

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants