343 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
Valentin David
8fc5be2ad7 kernel/fde: simplify invocation of fde-reveal-key 2024-02-16 08:56:49 +01:00
Miguel Pires
94976ba769 secboot/luks2: remove unused variable
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2023-10-13 09:29:47 +02:00
Alfonso Sánchez-Beato
1708bc105e secboot: avoid usage of fifos with cryptsetup
Using a fifo pipe and a goroutine with "cryptsetup luksAddKey" is
unnecessary, as both the existing key and the new key can be provided
via stdin to cryptsetup. Additionally, this add the --batch-mode
option when calling cryptsetup so warnings printed by cryptsetup in
23.10 do not mess the parsing of the returned message. Fixes
LP#2036631, being this an alternative solution to [1] (although the
latter would still need to use the --batch-mode option).

[1] https://github.com/snapcore/snapd/pull/12935
2023-10-06 12:08:41 +02: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
Dimitri John Ledkov
d55f3123d4 go: go fix with 1.18
Apply `go fix ./...` to the whole code base using go-1.18 to remove
old build tags.
2023-09-25 13:22:14 +02:00
Michael Vogt
7abfa24798 luks2: use cmdErr in osutil.OutputErr() 2023-07-06 18:02:10 +02:00
Michael Vogt
838b5f868c luks2: fix error reporting when fifoErr is nil 2023-07-06 18:02:10 +02:00
Michael Vogt
4f49d3673e luks2: add test for writeExistingKeyToFifo() failing 2023-07-06 18:02:10 +02:00
Michael Vogt
500d76eba7 luks2: make AddKey() robust against failure on pipe write or cmd 2023-07-06 18:02:10 +02:00
Michael Vogt
27b6c5b025 luks2: refactor/simplify cryptsetupCmd(), make AddKey() slightly more complex 2023-07-06 18:02:10 +02:00
Michael Vogt
2bee427f7a luks2: cleanup pendig readers/writer of a fifo too 2023-07-06 18:02:10 +02:00
Michael Vogt
8b02d31002 luks2: add missing unit tests 2023-07-06 18:02:10 +02:00
Fred Lotter
9a5accce42 secboot: UUID generator error instead of panic
The randutil.RandomKernelUUID() used to generate a panic on failure.

The process of consolidating common code used by Pebble and Snapd
(e.g. randutil) highlighted the fact that an error return, as relied on by
Pebble, is a more flexibie approach and allows application code to decide
the severity, instead of the library function.

- Make secboot unlock code to deal with an error that can now be returned
  from the UUID generator.

- Add unit tests to cover the new error paths in the code.

Signed-off-by: Fred Lotter <fred.lotter@canonical.com>
2023-05-25 09:10:43 +02:00
Michael Vogt
ec484217a2 many: remove all device-setup fde-setup code (#12618)
* many: remove all `device-setup` fde-setup code

When we initially worked on the inline-cryto-engine (ICE) code we
had a design based on the fde-setup hook that would return a
`device-setup` feature as a hint that ICE should be used. It
turned out this design was impractical and we moved to a much
better approach that got merged in
https://github.com/snapcore/snapd/pull/12589
and relies on support for ICE in the kernel and cryptsetup.

With that new approach all the code that was supporting the
`device-setup` approach can be removed now.

* daemon: consider again the fde-setup hook case

* client: consider the ICE encryption type

* osu/disks,kernel: remove device-unlock support as well

---------

Co-authored-by: Samuele Pedroni <pedronis@lucediurna.net>
2023-04-05 18:03:03 +02:00
Michael Vogt
5fa37453b4 secboot: fix unittest after updating an error message 2023-03-06 11:34:43 +00:00
Michael Vogt
0de11daca8 secboot: improve error message (thanks Samuele) 2023-03-06 10:58:38 +01:00
Michael Vogt
9b42bfee0d secboot: pdate secboot branch and enable InlineCryptoEngine support 2023-03-06 10:58:38 +01:00
Michael Vogt
10d2e6b606 tests: also check log file for ICE usage 2023-03-06 10:58:38 +01:00
Michael Vogt
23bef5993d secboot: use helper EncryptionType.IsLUKS 2023-03-06 10:58:38 +01:00
Michael Vogt
dbced6f8e6 secboot: ensure FormatEncryptedDevice checks encryptionType 2023-03-06 10:58:38 +01:00
Michael Vogt
722d410cc9 many: deal with EncryptionTypeLUKSWithICE in more places
This commit updates the if/case statements that check for
secboot.EncryptionTypeLUKS to also deal with EncryptionTypeLUKSWithICE
and add some TODO:ICE: about cleanup we can do later.
2023-03-06 10:58:38 +01:00
Michael Vogt
6bbd6f94c1 secboot: improve string for EncryptionTypeLUKSWithICE (thanks to Samuele) 2023-03-06 10:58:38 +01:00
Michael Vogt
858b14681f many: use device hook for ICE
This rework the ICE support to add a new secboot.EncryptionTypeLUKSWithICE
and the dections is done via a new "use-ice" flag in featues call of
the fde hook.
2023-03-06 10:58:38 +01:00
Ondrej Kubik
3c820959d0 secboot, gadget: fix tests for ICE support
Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>
2023-03-06 10:58:38 +01:00