Commit Graph

44 Commits

Author SHA1 Message Date
Itxaka
9ce82c2059
Add label to trusted boot part as well
Signed-off-by: Itxaka <itxaka@kairos.io>
2025-03-21 15:45:07 +01:00
Itxaka
b0b2518e6a
Add label to luks partition and dont gate on label (#471)
* Add label to luks partition and dont gate on label

Instead of gating on labels, lets just add the label to the luks
partition, the same way we do to the underlying unlocked partition, so
they share the fs label. That way, the locking and unlocking refer to
the same label always

---------

Signed-off-by: Itxaka <itxaka@kairos.io>
2025-03-13 10:34:23 +01:00
Itxaka
84b9223b87
Use kairos logger from sdk (#437) 2024-09-18 10:10:39 +02:00
Itxaka
33ce07902b
Add discard flags during format (#424) 2024-07-31 17:58:42 +02:00
Itxaka
5c513aee21
Allow passing extra args to luks device creation (#418) 2024-07-24 15:13:33 +02:00
Itxaka
74eb5903b3
bump yaml from v1 to v3 (#417)
* Fix job to run ginkgo from go.mod

Signed-off-by: Itxaka <itxaka@kairos.io>

* Bump yaml from v1 to v3

Signed-off-by: Itxaka <itxaka@kairos.io>

---------

Signed-off-by: Itxaka <itxaka@kairos.io>
2024-07-15 19:53:00 +02:00
Itxaka
2bc901ed2c
Fix wrong arg used (#408) 2024-06-19 16:45:33 +02:00
Itxaka
9773d5ce7e
Do not settle, just trigger (#382) 2024-05-28 21:08:37 +02:00
Itxaka
ef5ef8e495 Remove -v flag on udev unlock
it can cause locks

Signed-off-by: Itxaka <itxaka@kairos.io>
2024-05-28 19:24:13 +02:00
Itxaka
ad07ced68b
Avoid calling udevadm with -v flag (#380) 2024-05-28 15:24:37 +02:00
Itxaka
418027453d
Rework TPM workflow (#318)
Co-authored-by: Dimitris Karakasilis <dimitris@karakasilis.me>
2024-05-28 11:48:37 +02:00
Dimitris Karakasilis
3655d3d81e
Try a simpler version of "udevadm trigger"
in case the other options are not supported

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
2024-05-27 09:29:52 +03:00
Dimitris Karakasilis
a6ec42e638
Trigger udev events also on lock
Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
2024-05-23 15:11:00 +03:00
Dimitris Karakasilis
dc0a97cab2
Trigger udev to populate disk info
because otherwise, sometimes the encrypted partition doesn't show up as
type: crypto_LUKS but as type: unknown making kcrypt skip it completely

Part of https://github.com/kairos-io/kairos/issues/2511

(an additional seems to be needed in kairos-agent when locking the
partitions to fully fix the issue)

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
2024-05-23 13:38:10 +03:00
Itxaka
1d16082bb3
Update lock.go (#316) 2024-05-21 13:13:50 +02:00
Itxaka
5274499e1a
Drop uneeded lib (#97) 2024-04-24 10:40:39 +02:00
Dimitris Karakasilis
fcf834a5b0
Add wrapper method to pass down a logger to UnlockAll
so that when called from immucore, we can write to the immucore log file

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
2024-02-19 12:27:54 +02:00
Itxaka
ee419393cd
Get label only if needed (#46) 2024-01-24 10:00:17 +01:00
Itxaka
99c1c93d26
Sign uki tpm stuff with a policy (#39) 2023-12-15 16:47:56 +01:00
Itxaka
554e350fb7
Fix issue when closing the device (#34) 2023-11-30 18:10:15 +01:00
Itxaka
94af8c8dd3 Also unlock with TPM
so we can use the same functions everywhere just with a flag

Signed-off-by: Itxaka <itxaka@kairos.io>
2023-11-30 11:39:21 +01:00
Itxaka
e73e33b26d cryptenroll needs the actual password
Also remove password from the luksdevice once we are finished

Signed-off-by: Itxaka <itxaka@kairos.io>
2023-11-30 11:29:20 +01:00
Itxaka
e43da08f2d Allow passing flags to luksify
flags for luks version and use tpm

Signed-off-by: Itxaka <itxaka@kairos.io>
2023-11-30 11:01:39 +01:00
Itxaka
365f16e8f1 Move all functions under pkg
Signed-off-by: Itxaka <itxaka@kairos.io>
2023-11-30 10:24:55 +01:00
Itxaka
166b8802ea Drop kairos lib and use sdk instead
Signed-off-by: Itxaka <itxaka.garcia@spectrocloud.com>
2023-06-14 15:03:31 +02:00
Itxaka
47e7f67e04 Fix label
Signed-off-by: Itxaka <itxaka.garcia@spectrocloud.com>
2023-05-05 09:19:46 +02:00
Itxaka
36f861fd0c Use reproducible UUIDs for partition identification
Signed-off-by: Itxaka <itxaka.garcia@spectrocloud.com>
2023-05-04 12:07:21 +02:00
Itxaka
6d6dfd00a1 🌱 Make some functions public
So they can be imported from different places as lib and re-used

Signed-off-by: Itxaka <itxaka.garcia@spectrocloud.com>
2023-04-19 14:44:33 +02:00
Mauro Morales
a254871c22
Remove something left from the merge conflict
Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
2023-03-30 09:06:11 +02:00
Mauro Morales
0f3eee7851
Add golint
Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
2023-03-29 17:05:51 +02:00
Mauro Morales
36fafa38cf
Add test for header when writing mappings
Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
2023-03-29 17:27:55 +03:00
Mauro Morales
f977f72e8d
Switch to using new collector pkg
Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
2023-03-29 17:27:55 +03:00
mudler
71506ff020 🌱 Remove challenger traces from here
The challenger has no business logic in here, and kcrypt should just
read what it needs. This goes in parallel with https://github.com/kairos-io/kcrypt-challenger/pull/10
Not blocking each other.

Signed-off-by: mudler <mudler@c3os.io>
2023-01-19 12:28:46 +01:00
Dimitris Karakasilis
018322ff00
Move from partition_info to config package
Now the kcrypt configuration will be just a block (`kcrypt`) in the regular
kairos configuration files.

We will use the config mechanism of looking up in multiple directories
becase the old code was only looking at `/oem` but at boot time
(initramfs) the configuration was present in `/sysroot/oem`.

The reason it "worked" was that we had a bug and a sealedvolume was
matching our request simply because we sent an empty UUID/Label/Name
and the sealedvolume had and empty UUID (empty matches empty, right?)

With that fixed on the challenger server side, it became obvious that we
never actually read the partition_info file because we were looking for
it at the wrong place.

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
2023-01-18 14:55:25 +02:00
Ettore Di Giacinto
214ae51333 Bind it to sysroot 2022-11-23 14:01:46 +01:00
Dimitris Karakasilis
bb144f204a
Don't hide there error when it's not about file not existing
Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
2022-11-23 14:53:02 +02:00
Dimitris Karakasilis
0e278a89f0
Don't let the mapping be nil when reading an empty file
e.g. when we first create it

because it throws this error:

```
panic: assignment to entry in nil map

goroutine 1 [running]:
github.com/kairos-io/kcrypt/pkg/partition_info.PartitionInfo.UpdateMapping({{0xa60325?, 0x18?}, 0x0?}, {0xc000302000?, 0x1?})
	/go/pkg/mod/github.com/kairos-io/kcrypt@v0.4.2/pkg/partition_info/partition_info.go:69 +0x99

```

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
2022-11-15 19:45:44 +02:00
Dimitris Karakasilis
a0a7c1269f
Create the partition file if id doesn't exist
so that the caller doesn't have to care if it's the first time the
partition is encrypted or not.

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
2022-11-15 12:17:32 +02:00
Dimitris Karakasilis
29f22e7f92
Update partition label with the store one before asking for a passphrase
Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
2022-11-11 13:14:31 +02:00
Dimitris Karakasilis
4a6c79f6a6
Change to a more object-oriented approach
Now the code can simply initialize a PartitionInfo from a file and then
call LookupUUIDForLabel on it.

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
2022-11-11 13:06:00 +02:00
Dimitris Karakasilis
8ca95e953b
Add functions to produce a string representation of a partition
so that we encapsulate all the logic in the same package

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
2022-11-11 12:11:43 +02:00
Dimitris Karakasilis
82c6e8fcd0
Create parition info parsing library
to be used both here (when trying to find the partition UUID using a
label) and on the kairos side when updating the file after calling
kcrypt to encrypt a partition (which causes the UUID to change).

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
2022-11-11 10:55:46 +02:00
Ettore Di Giacinto
aa620714a5 Add /oem/system/discovery 2022-10-17 19:15:40 +00:00
mudler
b05d3c1e54 Initial import 2022-10-03 11:03:48 +02:00