Commit Graph

12 Commits

Author SHA1 Message Date
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