Upgrade go-cryptsetup to latest version

Signed-off-by: Daniel Weiße <dw@edgeless.systems>
This commit is contained in:
Daniel Weiße 2022-03-23 11:00:07 +01:00 committed by Daniel Weiße
parent 656ad704d2
commit 752571bbf8
5 changed files with 14 additions and 9 deletions

View File

@ -17,6 +17,9 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Install Dependencies
run: sudo apt-get update && sudo apt-get -y install libcryptsetup-dev
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:

2
go.mod
View File

@ -68,7 +68,7 @@ require (
github.com/google/uuid v1.3.0
github.com/googleapis/gax-go/v2 v2.2.0
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
github.com/martinjungblut/go-cryptsetup v0.0.0-20220306213448-685e4930d722
github.com/martinjungblut/go-cryptsetup v0.0.0-20220317181052-e70d6b615049
github.com/schollz/progressbar/v3 v3.8.6
github.com/spf13/afero v1.8.2
github.com/spf13/cobra v1.4.0

2
go.sum
View File

@ -1006,6 +1006,8 @@ github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJ
github.com/marstr/guid v1.1.0/go.mod h1:74gB1z2wpxxInTG6yaqA7KrtM0NZ+RbrcqDvYHefzho=
github.com/martinjungblut/go-cryptsetup v0.0.0-20220306213448-685e4930d722 h1:vfx+2bYxFA1H0g1uTbEjJUFqPPyhzCOZvBCIvM+8aZM=
github.com/martinjungblut/go-cryptsetup v0.0.0-20220306213448-685e4930d722/go.mod h1:gZoZ0+POlM1ge/VUxWpMmZVNPzzMJ7l436CgkQ5+qzU=
github.com/martinjungblut/go-cryptsetup v0.0.0-20220317181052-e70d6b615049 h1:RhjbYE5voarNcN87XH0A4RWEPcW5exQ+w4WYPKgqT1I=
github.com/martinjungblut/go-cryptsetup v0.0.0-20220317181052-e70d6b615049/go.mod h1:gZoZ0+POlM1ge/VUxWpMmZVNPzzMJ7l436CgkQ5+qzU=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=

View File

@ -9,7 +9,7 @@ import (
"path/filepath"
"sync"
"github.com/martinjungblut/go-cryptsetup"
cryptsetup "github.com/martinjungblut/go-cryptsetup"
"k8s.io/klog"
mount "k8s.io/mount-utils"
utilexec "k8s.io/utils/exec"
@ -53,7 +53,7 @@ type KeyCreator interface {
// DeviceMapper is an interface for device mapper methods.
type DeviceMapper interface {
// Init initializes a crypt device backed by 'devicePath'.
// Sets the devieMapper to the newly allocated Device or returns any error encountered.
// Sets the deviceMapper to the newly allocated Device or returns any error encountered.
// C equivalent: crypt_init
Init(devicePath string) error
// ActivateByVolumeKey activates a device by using a volume key.
@ -74,7 +74,7 @@ type DeviceMapper interface {
// Load loads crypt device parameters from the on-disk header.
// Returns nil on success, or an error otherwise.
// C equivalent: crypt_load
Load() error
Load(cryptsetup.DeviceType) error
// Wipe removes existing data and clears the device for use with dm-integrity.
// Returns nil on success, or an error otherwise.
// C equivalent: crypt_wipe
@ -88,7 +88,7 @@ type CryptDevice struct {
// Init initializes a crypt device backed by 'devicePath'.
// Sets the cryptDevice's deviceMapper to the newly allocated Device or returns any error encountered.
// C equivalent: crypt_init
// C equivalent: crypt_init.
func (c *CryptDevice) Init(devicePath string) error {
device, err := cryptsetup.Init(devicePath)
if err != nil {
@ -99,7 +99,7 @@ func (c *CryptDevice) Init(devicePath string) error {
}
// Free releases crypt device context and used memory.
// C equivalent: crypt_free
// C equivalent: crypt_free.
func (c *CryptDevice) Free() bool {
res := c.Device.Free()
c.Device = nil
@ -216,7 +216,7 @@ func openCryptDevice(device DeviceMapper, source, volumeID, dek string, integrit
needWipe := false
// Try to load LUKS headers
// If this fails, the device is either not formatted at all, or already formatted with a different FS
if err := device.Load(); err != nil {
if err := device.Load(nil); err != nil {
klog.V(4).Infof("Device %q is not formatted as LUKS2 partition, checking for existing format...", source)
format, err := diskInfo(source)
if err != nil {

View File

@ -6,7 +6,7 @@ import (
"testing"
"github.com/edgelesssys/constellation/mount/pkg/kms"
"github.com/martinjungblut/go-cryptsetup"
cryptsetup "github.com/martinjungblut/go-cryptsetup"
"github.com/stretchr/testify/assert"
)
@ -50,7 +50,7 @@ func (c *stubCryptDevice) Free() bool {
return true
}
func (c *stubCryptDevice) Load() error {
func (c *stubCryptDevice) Load(cryptsetup.DeviceType) error {
return c.loadErr
}