51 Commits

Author SHA1 Message Date
Miguel Pires
79c5ac14b2 many: remove usages of deprecated io/ioutil package (#13768)
* many: remove usages of deprecated io/ioutil package

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>

* .golangci.yml: remove errcheck ignore rule for io/ioutil

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>

* run-checks: prevent new usages of io/ioutil

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>

---------

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2024-04-03 23:23:24 +02:00
Miguel Pires
e3c52850d5 boot: fix more slices missing types
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2023-12-12 14:09:56 +01:00
Miguel Pires
29c9752d66 many: s/ioutil.WriteFile/os.WriteFile (#13217)
Replace ioutil.WriteFile with os.WriteFile since the former has been
deprecated since go1.16 and simply calls the latter.

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2023-09-26 11:38:46 +01:00
Samuele Pedroni
285eb30391 asserts,boot,secboot: switch to a secboot version measuring classic
to have the information available when we seal capture classic in
modeenv and bootchains as we do for other mode characteristics

as for now we assume we don't want so support classic/core remodels

some things need to be tested but it's best if the tests are added
when we are actually looking at the full picture of installing classic
systems with modes
2022-09-05 15:23:28 +02:00
Alfonso Sánchez-Beato
07bf5b02e7 boot: mount gadget from initramfs
Mount gadget in /run/mnt/gadget directory from initramfs.
2022-06-23 11:41:40 +02:00
Michael Vogt
46ef068423 many: replace use of "sanity" with more inclusive naming
This commit replaces the use of "sanity" with more inclusive
naming. When "sanity" is used in a more general sense either
"validity" or "quick" is used.
2022-03-16 09:10:59 +01:00
Paweł Stołowski
bd3f924d28 Add modeenv test. 2022-02-15 10:52:22 +01:00
Maciej Borzecki
44adf72f50 boot: use secboot interface where possible, turn method into a helper function
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2021-06-15 16:41:29 +02:00
Maciej Borzecki
3293df1ca8 Merge remote-tracking branch 'upstream/master' into bboozzoo/uc20-decouple-re-seal-from-model 2021-06-15 11:48:13 +02:00
Maciej Borzecki
a4d2252f33 boot: tweak tests, add an internal interface
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2021-06-15 11:47:29 +02:00
Maciej Borzecki
448061c9f0 boot: extend modeenv unit tests
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2021-06-11 14:41:03 +02:00
Maciej Borzecki
37fc0edcdc boot: decouple model from seal/reseal handling via an auxiliary type
It is desired that the seal/reseal code only operates on the input provided in
modeenv rather than poking other external structures. The change decouples the
lower level code from accessing the model directly.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2021-06-11 13:16:53 +02:00
Maciej Borzecki
09829e9f4e boot: tweak naming, rename SignKeyID to ModelSignKeyID
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2021-06-11 10:08:10 +02:00
Maciej Borzecki
e880aa35c1 boot: introduce properties of the candidate device model to modeenv
Add properties of candidate device model to modeenv

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2021-06-10 17:01:39 +02:00
Maciej Borzecki
610974af5e boot: add sign-key-id into modeenv
Add the model's sign key ID to the modeenv.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2021-06-10 17:01:39 +02:00
Ian Johnson
83db9818fb boot: support read/writing boot-flags from userspace/initramfs
Add a family of functions for reading and writing boot-flags in various
contexts:

* Reading the current effective boot flags from either the modeenv or the
  bootenv from the initramfs depending on the mode.
* Writing the current effective boot flags to a file in /run from the initramfs
* Reading the current effective boot flags from userspace (this is from a file
  in /run)
* Writing the next boot flags to the modeenv from userspace
* Reading the next boot flags from the modeenv from userspace
* Writing the next boot flags to the bootenv during snap 
  prepare-image/ubuntu-image time

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2021-03-31 17:37:59 -05:00
Ian Johnson
f1e5bf72c7 Revert "Merge pull request #10009 from anonymouse64/feature/uc20-install-device-hook-1"
This reverts commit 349548bb99, reversing
changes made to 2e2cff7c18.

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2021-03-09 14:20:18 -06:00
Ian Johnson
e037910636 boot: export bootAssetsMap as AssetsMap
We need this to be exported to be able to serialize a trusted asset observer
across multiple tasks during UC20 install mode. The only state that is not
currently observable from filesystem state are the keys and the boot asset maps
for tracked assets here. The keys can easily be saved in state.json to
serialize, but the boot asset map needs to be exported to be able to serialize
it in the state.json across tasks.

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2021-03-08 16:00:10 -06:00
Maciej Borzecki
aa3b8bd1e8 boot: add modeenv entry for good recovery systems
Add a new modeenv entry to tracking recovery systems that have been verified to
work.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2021-02-18 13:13:17 +01:00
Maciej Borzecki
330fd14586 boot: tweak naming
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2020-11-24 16:15:45 +01:00
Maciej Borzecki
8dc3a828d5 boot: add kernel command lines to the modeenv file
Add the list of kernel command lines to the modeenv.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2020-11-24 10:06:38 +01:00
Samuele Pedroni
a57e543250 boot: track modeenv known fields with tags, not a on-the-side map
using reflect from a init func
2020-09-16 13:07:27 +02:00
Ian Johnson
ba1f728dd5 boot/modeenv_test.go: test modeenv w/ unknown keys equals same memory version
Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2020-09-15 17:26:43 -05:00
Ian Johnson
26943a5ca2 boot/modeenv: track unknown keys in Read and put back into modeenv during Write
This ensures that if we need to add new keys to the modeenv later on, and also
need to modify the modeenv with an old snapd/snap-bootstrap, such as in recovery
or the initramfs, we will not lose those keys in the modeenv.

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2020-09-15 17:19:57 -05:00
Maciej Borzecki
89b3a1c3b5 boot: tweak naming in modeenv, indicate boot assets are trusted
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2020-08-10 14:37:30 +02:00