mirror of
https://github.com/kairos-io/kairos-sdk.git
synced 2025-05-11 17:46:26 +00:00
Bring kcrypt libs into sdk (#592)
This commit is contained in:
parent
790c454322
commit
7ef466cd9d
14
go.mod
14
go.mod
@ -3,6 +3,7 @@ module github.com/kairos-io/kairos-sdk
|
||||
go 1.24.2
|
||||
|
||||
require (
|
||||
github.com/anatol/luks.go v0.0.0-20250316021219-8cd744c3576f
|
||||
github.com/avast/retry-go v3.0.0+incompatible
|
||||
github.com/containerd/containerd v1.7.27
|
||||
github.com/denisbrodbeck/machineid v1.0.1
|
||||
@ -10,6 +11,7 @@ require (
|
||||
github.com/docker/docker v27.5.1+incompatible
|
||||
github.com/edsrzf/mmap-go v1.2.0
|
||||
github.com/foxboron/go-uefi v0.0.0-20250207204325-69fb7dba244f
|
||||
github.com/gofrs/uuid v4.4.0+incompatible
|
||||
github.com/google/go-containerregistry v0.20.3
|
||||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
|
||||
github.com/hashicorp/go-multierror v1.1.1
|
||||
@ -40,6 +42,7 @@ require (
|
||||
github.com/Microsoft/go-winio v0.6.2 // indirect
|
||||
github.com/Microsoft/hcsshim v0.12.9 // indirect
|
||||
github.com/StackExchange/wmi v1.2.1 // indirect
|
||||
github.com/anatol/devmapper.go v0.0.0-20230829043248-59ac2b9706ba // indirect
|
||||
github.com/aybabtme/rgbterm v0.0.0-20170906152045-cc83f3b3ce59 // indirect
|
||||
github.com/chuckpreslar/emission v0.0.0-20170206194824-a7ddd980baf9 // indirect
|
||||
github.com/containerd/cgroups/v3 v3.0.5 // indirect
|
||||
@ -53,6 +56,7 @@ require (
|
||||
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.6 // indirect
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
||||
github.com/dgryski/go-camellia v0.0.0-20191119043421-69a8a13fb23d // indirect
|
||||
github.com/distribution/reference v0.6.0 // indirect
|
||||
github.com/djherbis/times v1.6.0 // indirect
|
||||
github.com/docker/cli v27.5.0+incompatible // indirect
|
||||
@ -69,13 +73,14 @@ require (
|
||||
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
|
||||
github.com/google/go-cmp v0.6.0 // indirect
|
||||
github.com/google/pprof v0.0.0-20250208200701-d0013a598941 // indirect
|
||||
github.com/google/go-cmp v0.7.0 // indirect
|
||||
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/gookit/color v1.5.4 // indirect
|
||||
github.com/hashicorp/errwrap v1.1.0 // indirect
|
||||
github.com/itchyny/timefmt-go v0.1.6 // indirect
|
||||
github.com/jaypipes/pcidb v1.0.1 // indirect
|
||||
github.com/jzelinskie/whirlpool v0.0.0-20201016144138-0675e54bb004 // indirect
|
||||
github.com/klauspost/compress v1.17.11 // indirect
|
||||
github.com/lithammer/fuzzysearch v1.1.8 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
@ -114,14 +119,15 @@ require (
|
||||
go.opentelemetry.io/otel/metric v1.34.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.34.0 // indirect
|
||||
go.opentelemetry.io/proto/otlp v1.4.0 // indirect
|
||||
go.uber.org/automaxprocs v1.6.0 // indirect
|
||||
golang.org/x/crypto v0.36.0 // indirect
|
||||
golang.org/x/net v0.38.0 // indirect
|
||||
golang.org/x/sync v0.12.0 // indirect
|
||||
golang.org/x/sys v0.31.0 // indirect
|
||||
golang.org/x/sys v0.32.0 // indirect
|
||||
golang.org/x/term v0.30.0 // indirect
|
||||
golang.org/x/text v0.23.0 // indirect
|
||||
golang.org/x/time v0.3.0 // indirect
|
||||
golang.org/x/tools v0.30.0 // indirect
|
||||
golang.org/x/tools v0.31.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250212204824-5a70512c5d8b // indirect
|
||||
google.golang.org/grpc v1.70.0 // indirect
|
||||
google.golang.org/protobuf v1.36.5 // indirect
|
||||
|
44
go.sum
44
go.sum
@ -67,6 +67,12 @@ github.com/alecthomas/assert/v2 v2.3.0 h1:mAsH2wmvjsuvyBvAmCtm7zFsBlb8mIHx5ySLVd
|
||||
github.com/alecthomas/assert/v2 v2.3.0/go.mod h1:pXcQ2Asjp247dahGEmsZ6ru0UVwnkhktn7S0bBDLxvQ=
|
||||
github.com/alecthomas/repr v0.2.0 h1:HAzS41CIzNW5syS8Mf9UwXhNH1J9aix/BvDRf1Ml2Yk=
|
||||
github.com/alecthomas/repr v0.2.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
|
||||
github.com/anatol/devmapper.go v0.0.0-20230829043248-59ac2b9706ba h1:LJ/tQNki21ep58+YZElkXQVpswENcK66NMNv4JGZf7w=
|
||||
github.com/anatol/devmapper.go v0.0.0-20230829043248-59ac2b9706ba/go.mod h1:yZpXZj/k3rAZDY43DteaEzbnnxiz9OYijJqRcqWMKSw=
|
||||
github.com/anatol/luks.go v0.0.0-20250316021219-8cd744c3576f h1:4tLJrnm3h3biCFsXHQ9w6DVGwuZXW4KMfiKV/atSYXg=
|
||||
github.com/anatol/luks.go v0.0.0-20250316021219-8cd744c3576f/go.mod h1:kEOnWwULAKOORfFvE4dEkdRZJS7+NMJKxRb/vWvmARk=
|
||||
github.com/anatol/vmtest v0.0.0-20230711210602-87511df0d4bc h1:xMQuzBhj6hXQZufedPQM2OiGX2UcQHSptXtG3+28S8Q=
|
||||
github.com/anatol/vmtest v0.0.0-20230711210602-87511df0d4bc/go.mod h1:NC+g66bgkUjV1unIJXhHO35RHxVViWUzNeeKAkkO7DU=
|
||||
github.com/atomicgo/cursor v0.0.1/go.mod h1:cBON2QmmrysudxNBFthvMtN32r3jxVRIvzkUiF/RuIk=
|
||||
github.com/avast/retry-go v3.0.0+incompatible h1:4SOWQ7Qs+oroOTQOYnAHqelpCO0biHSxpiH9JdtuBj0=
|
||||
github.com/avast/retry-go v3.0.0+incompatible/go.mod h1:XtSnn+n/sHqQIpZ10K1qAevBhOOCWBLXXy3hyiqqBrY=
|
||||
@ -117,6 +123,8 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/denisbrodbeck/machineid v1.0.1 h1:geKr9qtkB876mXguW2X6TU4ZynleN6ezuMSRhl4D7AQ=
|
||||
github.com/denisbrodbeck/machineid v1.0.1/go.mod h1:dJUwb7PTidGDeYyUBmXZ2GphQBbjJCrnectwCyxcUSI=
|
||||
github.com/dgryski/go-camellia v0.0.0-20191119043421-69a8a13fb23d h1:CPqTNIigGweVPT4CYb+OO2E6XyRKFOmvTHwWRLgCAlE=
|
||||
github.com/dgryski/go-camellia v0.0.0-20191119043421-69a8a13fb23d/go.mod h1:QX5ZVULjAfZJux/W62Y91HvCh9hyW6enAwcrrv/sLj0=
|
||||
github.com/diskfs/go-diskfs v1.5.1 h1:Mnzgx3ERI+lzGzDAV+ejFLj/Uz9Cs/7wDkaAXwH1RMk=
|
||||
github.com/diskfs/go-diskfs v1.5.1/go.mod h1:bRFumZeGFCO8C2KNswrQeuj2m1WCVr4Ms5IjWMczMDk=
|
||||
github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk=
|
||||
@ -170,6 +178,8 @@ github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZ
|
||||
github.com/go-test/deep v1.0.8 h1:TDsG77qcSprGbC6vTN8OuXp5g+J+b5Pcguhf7Zt61VM=
|
||||
github.com/go-test/deep v1.0.8/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
|
||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1YrTJupqA=
|
||||
github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
||||
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
||||
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
@ -213,8 +223,8 @@ github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
|
||||
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||
github.com/google/go-containerregistry v0.20.3 h1:oNx7IdTI936V8CQRveCjaxOiegWwvM7kqkbXTpyiovI=
|
||||
github.com/google/go-containerregistry v0.20.3/go.mod h1:w00pIgBRDVUDFM6bq+Qx8lwNWK+cxgCuX1vd3PIBDNI=
|
||||
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
||||
@ -230,8 +240,8 @@ github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hf
|
||||
github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/google/pprof v0.0.0-20250208200701-d0013a598941 h1:43XjGa6toxLpeksjcxs1jIoIyr+vUfOqY2c6HB4bpoc=
|
||||
github.com/google/pprof v0.0.0-20250208200701-d0013a598941/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144=
|
||||
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 h1:BHT72Gu3keYf3ZEu2J0b1vyeLSOYI8bm5wbJM/8yDe8=
|
||||
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=
|
||||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
|
||||
@ -274,6 +284,10 @@ github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
||||
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
|
||||
github.com/jzelinskie/whirlpool v0.0.0-20201016144138-0675e54bb004 h1:G+9t9cEtnC9jFiTxyptEKuNIAbiN5ZCQzX2a74lj3xg=
|
||||
github.com/jzelinskie/whirlpool v0.0.0-20201016144138-0675e54bb004/go.mod h1:KmHnJWQrgEvbuy0vcvj00gtMqbvNn1L+3YUZLK/B92c=
|
||||
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
|
||||
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
|
||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=
|
||||
@ -330,13 +344,13 @@ github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108
|
||||
github.com/onsi/ginkgo v1.14.2/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY=
|
||||
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
|
||||
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
|
||||
github.com/onsi/ginkgo/v2 v2.23.0 h1:FA1xjp8ieYDzlgS5ABTpdUDB7wtngggONc8a7ku2NqQ=
|
||||
github.com/onsi/ginkgo/v2 v2.23.0/go.mod h1:zXTP6xIp3U8aVuXN8ENK9IXRaTjFnpVB9mGmaSRvxnM=
|
||||
github.com/onsi/ginkgo/v2 v2.23.4 h1:ktYTpKJAVZnDT4VjxSbiBenUjmlL/5QkBEocaWXiQus=
|
||||
github.com/onsi/ginkgo/v2 v2.23.4/go.mod h1:Bt66ApGPBFzHyR+JO10Zbt0Gsp4uWxu5mIOTusL46e8=
|
||||
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
||||
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
||||
github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc=
|
||||
github.com/onsi/gomega v1.36.2 h1:koNYke6TVk6ZmnyHrCXba/T/MoLBXFjeC1PtvYgw0A8=
|
||||
github.com/onsi/gomega v1.36.2/go.mod h1:DdwyADRjrc825LhMEkD76cHR5+pUnjhUN8GlHlRPHzY=
|
||||
github.com/onsi/gomega v1.37.0 h1:CdEG8g0S133B4OswTDC/5XPSzE1OeP29QOioj2PID2Y=
|
||||
github.com/onsi/gomega v1.37.0/go.mod h1:8D9+Txp43QWKhM24yyOBEdpkzN8FvJyAwecBgsU4KU0=
|
||||
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
|
||||
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
|
||||
github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug=
|
||||
@ -351,6 +365,8 @@ github.com/pkg/xattr v0.4.9/go.mod h1:di8WF84zAKk8jzR1UBTEWh9AUlIZZ7M/JNt8e9B6kt
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g=
|
||||
github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U=
|
||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/pterm/pterm v0.12.27/go.mod h1:PhQ89w4i95rhgE+xedAoqous6K9X+r6aSOI2eFF7DZI=
|
||||
github.com/pterm/pterm v0.12.29/go.mod h1:WI3qxgvoQFFGKGjGnJR849gU0TsEOvKn5Q8LlY1U7lg=
|
||||
@ -409,6 +425,8 @@ github.com/swaggest/jsonschema-go v0.3.62 h1:eIE0aRklWa2eLJg2L/zqyWpKvgUPbq2oKOt
|
||||
github.com/swaggest/jsonschema-go v0.3.62/go.mod h1:DYuKqdpms/edvywsX6p1zHXCZkdwB28wRaBdFCe3Duw=
|
||||
github.com/swaggest/refl v1.3.0 h1:PEUWIku+ZznYfsoyheF97ypSduvMApYyGkYF3nabS0I=
|
||||
github.com/swaggest/refl v1.3.0/go.mod h1:3Ujvbmh1pfSbDYjC6JGG7nMgPvpG0ehQL4iNonnLNbg=
|
||||
github.com/tmc/scp v0.0.0-20170824174625-f7b48647feef h1:7D6Nm4D6f0ci9yttWaKjM1TMAXrH5Su72dojqYGntFY=
|
||||
github.com/tmc/scp v0.0.0-20170824174625-f7b48647feef/go.mod h1:WLFStEdnJXpjK8kd4qKLwQKX/1vrDzp5BcDyiZJBHJM=
|
||||
github.com/twpayne/go-vfs/v4 v4.3.0 h1:rTqFzzOQ/6ESKTSiwVubHlCBedJDOhQyVSnw8rQNZhU=
|
||||
github.com/twpayne/go-vfs/v4 v4.3.0/go.mod h1:tq2UVhnUepesc0lSnPJH/jQ8HruGhzwZe2r5kDFpEIw=
|
||||
github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8=
|
||||
@ -463,6 +481,8 @@ go.opentelemetry.io/otel/trace v1.34.0 h1:+ouXS2V8Rd4hp4580a8q23bg0azF2nI8cqLYnC
|
||||
go.opentelemetry.io/otel/trace v1.34.0/go.mod h1:Svm7lSjQD7kG7KJ/MUHPVXSDGz2OX4h0M2jHBhmSfRE=
|
||||
go.opentelemetry.io/proto/otlp v1.4.0 h1:TA9WRvW6zMwP+Ssb6fLoUIuirti1gGbP28GcKG1jgeg=
|
||||
go.opentelemetry.io/proto/otlp v1.4.0/go.mod h1:PPBWZIP98o2ElSqI35IHfu7hIhSwvc5N38Jw8pXuGFY=
|
||||
go.uber.org/automaxprocs v1.6.0 h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs=
|
||||
go.uber.org/automaxprocs v1.6.0/go.mod h1:ifeIMSnPZuznNm6jmdzmU3/bfk01Fe2fotchwEFJ8r8=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
@ -629,8 +649,8 @@ golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
|
||||
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20=
|
||||
golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
@ -705,8 +725,8 @@ golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4f
|
||||
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||
golang.org/x/tools v0.30.0 h1:BgcpHewrV5AUp2G9MebG4XPFI1E2W41zU1SaqVA9vJY=
|
||||
golang.org/x/tools v0.30.0/go.mod h1:c347cR/OJfw5TI+GfX7RUPNMdDRRbjvYTS0jPyvsVtY=
|
||||
golang.org/x/tools v0.31.0 h1:0EedkvKDbh+qistFTd0Bcwe/YLh4vHwWEkiI0toFIBU=
|
||||
golang.org/x/tools v0.31.0/go.mod h1:naFTU+Cev749tSJRXJlna0T3WxKvb1kWEx15xA4SdmQ=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
|
74
kcrypt/bus/bus.go
Normal file
74
kcrypt/bus/bus.go
Normal file
@ -0,0 +1,74 @@
|
||||
package bus
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/kairos-io/kairos-sdk/types"
|
||||
"github.com/mudler/go-pluggable"
|
||||
)
|
||||
|
||||
const EventDiscoveryPassword pluggable.EventType = "discovery.password"
|
||||
|
||||
const prefix = "kcrypt-discovery"
|
||||
|
||||
// extensionPaths is a list of paths where the bus will look for plugins.
|
||||
var extensionPaths = []string{
|
||||
"/sysroot/system/discovery",
|
||||
"/system/discovery",
|
||||
"/oem/kcrypt",
|
||||
"/oem/system/discovery",
|
||||
}
|
||||
|
||||
// Manager is the bus instance manager, which subscribes plugins to events emitted.
|
||||
var Manager = NewBus()
|
||||
|
||||
func NewBus() *Bus {
|
||||
return &Bus{
|
||||
Manager: pluggable.NewManager([]pluggable.EventType{EventDiscoveryPassword}),
|
||||
}
|
||||
}
|
||||
|
||||
func Reload() {
|
||||
Manager = NewBus()
|
||||
Manager.Initialize()
|
||||
}
|
||||
|
||||
type Bus struct {
|
||||
*pluggable.Manager
|
||||
registered bool
|
||||
}
|
||||
|
||||
func (b *Bus) LoadProviders() {
|
||||
wd, _ := os.Getwd()
|
||||
b.Autoload(prefix, append(extensionPaths, wd)...).Register()
|
||||
}
|
||||
|
||||
func (b *Bus) Initialize() {
|
||||
if b.registered {
|
||||
return
|
||||
}
|
||||
|
||||
level := "info"
|
||||
if os.Getenv("BUS_DEBUG") == "true" {
|
||||
level = "debug"
|
||||
}
|
||||
|
||||
log := types.NewKairosLogger("kcrypt", level, false)
|
||||
|
||||
b.LoadProviders()
|
||||
for i := range b.Events {
|
||||
e := b.Events[i]
|
||||
b.Response(e, func(p *pluggable.Plugin, r *pluggable.EventResponse) {
|
||||
log.Logger.Debug().Str("from", p.Name).Str("at", p.Executable).Str("type", string(e)).Msg("Received event from provider")
|
||||
if r.Errored() {
|
||||
log.Logger.Error().Err(fmt.Errorf("%s", r.Error)).Str("from", p.Name).Str("at", p.Executable).Str("type", string(e)).Msg("Error in provider")
|
||||
os.Exit(1)
|
||||
}
|
||||
if r.State != "" {
|
||||
log.Logger.Debug().Str("state", r.State).Str("from", p.Name).Str("at", p.Executable).Str("type", string(e)).Msg("Received event from provider")
|
||||
}
|
||||
})
|
||||
}
|
||||
b.registered = true
|
||||
}
|
273
kcrypt/lock.go
Normal file
273
kcrypt/lock.go
Normal file
@ -0,0 +1,273 @@
|
||||
package kcrypt
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/gofrs/uuid"
|
||||
"github.com/jaypipes/ghw"
|
||||
"github.com/jaypipes/ghw/pkg/block"
|
||||
"github.com/kairos-io/kairos-sdk/types"
|
||||
"github.com/kairos-io/kairos-sdk/utils"
|
||||
)
|
||||
|
||||
// Encrypt is the entrypoint to encrypt a partition with LUKS.
|
||||
func Encrypt(label string, logger types.KairosLogger, argsCreate ...string) (string, error) {
|
||||
return luksify(label, logger, argsCreate...)
|
||||
}
|
||||
|
||||
// EncryptWithPcrs is the entrypoint to encrypt a partition with LUKS and bind it to PCRs.
|
||||
func EncryptWithPcrs(label string, publicKeyPcrs []string, pcrs []string, logger types.KairosLogger, argsCreate ...string) error {
|
||||
return luksifyMeasurements(label, publicKeyPcrs, pcrs, logger, argsCreate...)
|
||||
}
|
||||
|
||||
func createLuks(dev, password string, cryptsetupArgs ...string) error {
|
||||
args := []string{"luksFormat", "--type", "luks2", "--iter-time", "5", "-q", dev}
|
||||
args = append(args, cryptsetupArgs...)
|
||||
cmd := exec.Command("cryptsetup", args...)
|
||||
cmd.Stdin = strings.NewReader(password)
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
var seededRand = rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||
|
||||
func getRandomString(length int) string {
|
||||
const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
||||
b := make([]byte, length)
|
||||
for i := range b {
|
||||
b[i] = charset[seededRand.Intn(len(charset))]
|
||||
}
|
||||
return string(b)
|
||||
}
|
||||
|
||||
// luksify Take a part label, and recreates it with LUKS. IT OVERWRITES DATA!.
|
||||
// On success, it returns a machine parseable string with the partition information
|
||||
// (label:name:uuid) so that it can be stored by the caller for later use.
|
||||
// This is because the label of the encrypted partition is not accessible unless
|
||||
// the partition is decrypted first and the uuid changed after encryption so
|
||||
// any stored information needs to be updated (by the caller).
|
||||
func luksify(label string, logger types.KairosLogger, argsCreate ...string) (string, error) {
|
||||
var pass string
|
||||
|
||||
// Make sure ghw will see all partitions correctly.
|
||||
// older versions don't have --type=all. Try the simpler version then.
|
||||
out, err := utils.SH("udevadm trigger --type=all || udevadm trigger")
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("udevadm trigger failed: %w, out: %s", err, out)
|
||||
}
|
||||
syscall.Sync()
|
||||
|
||||
part, b, err := findPartition(label)
|
||||
if err != nil {
|
||||
logger.Err(err).Msg("find partition")
|
||||
return "", err
|
||||
}
|
||||
|
||||
pass, err = getPassword(b)
|
||||
if err != nil {
|
||||
logger.Err(err).Msg("get password")
|
||||
return "", err
|
||||
}
|
||||
|
||||
mapper := fmt.Sprintf("/dev/mapper/%s", b.Name)
|
||||
device := fmt.Sprintf("/dev/%s", part)
|
||||
|
||||
extraArgs := []string{"--uuid", uuid.NewV5(uuid.NamespaceURL, label).String()}
|
||||
extraArgs = append(extraArgs, "--label", label)
|
||||
extraArgs = append(extraArgs, argsCreate...)
|
||||
|
||||
if err := createLuks(device, pass, extraArgs...); err != nil {
|
||||
logger.Err(err).Msg("create luks")
|
||||
return "", err
|
||||
}
|
||||
|
||||
err = formatLuks(device, b.Name, mapper, label, pass, logger)
|
||||
if err != nil {
|
||||
logger.Err(err).Msg("format luks")
|
||||
return "", err
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s:%s:%s", b.FilesystemLabel, b.Name, b.UUID), nil
|
||||
}
|
||||
|
||||
// luksifyMeasurements takes a label and a list if public-keys and pcrs to bind and uses the measurements.
|
||||
// in the current node to encrypt the partition with those and bind those to the given pcrs
|
||||
// this expects systemd 255 as it needs the SRK public key that systemd extracts
|
||||
// Sets a random password, enrolls the policy, unlocks and formats the partition, closes it and tfinally removes the random password from it
|
||||
// Note that there is a diff between the publicKeyPcrs and normal Pcrs
|
||||
// The former links to a policy type that allows anything signed by that policy to unlcok the partitions so its
|
||||
// really useful for binding to PCR11 which is the UKI measurements in order to be able to upgrade the system and still be able
|
||||
// to unlock the partitions.
|
||||
// The later binds to a SINGLE measurement, so if that changes, it will not unlock anything.
|
||||
// This is useful for things like PCR7 which measures the secureboot state and certificates if you dont expect those to change during
|
||||
// the whole lifetime of a machine
|
||||
// It can also be used to bind to things like the firmware code or efi drivers that we dont expect to change
|
||||
// default for publicKeyPcrs is 11
|
||||
// default for pcrs is nothing, so it doesn't bind as we want to expand things like DBX and be able to blacklist certs and such.
|
||||
func luksifyMeasurements(label string, publicKeyPcrs []string, pcrs []string, logger types.KairosLogger, argsCreate ...string) error {
|
||||
// Make sure ghw will see all partitions correctly.
|
||||
// older versions don't have --type=all. Try the simpler version then.
|
||||
out, err := utils.SH("udevadm trigger --type=all || udevadm trigger")
|
||||
if err != nil {
|
||||
return fmt.Errorf("udevadm trigger failed: %w, out: %s", err, out)
|
||||
}
|
||||
syscall.Sync()
|
||||
|
||||
part, b, err := findPartition(label)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// On TPM locking we generate a random password that will only be used here then discarded.
|
||||
// only unlocking method will be PCR values
|
||||
pass := getRandomString(32)
|
||||
mapper := fmt.Sprintf("/dev/mapper/%s", b.Name)
|
||||
device := fmt.Sprintf("/dev/%s", part)
|
||||
|
||||
extraArgs := []string{"--uuid", uuid.NewV5(uuid.NamespaceURL, label).String()}
|
||||
extraArgs = append(extraArgs, "--label", label)
|
||||
extraArgs = append(extraArgs, argsCreate...)
|
||||
|
||||
if err := createLuks(device, pass, extraArgs...); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(publicKeyPcrs) == 0 {
|
||||
publicKeyPcrs = []string{"11"}
|
||||
}
|
||||
|
||||
syscall.Sync()
|
||||
|
||||
// Enroll PCR policy as a keyslot
|
||||
// We pass the current signature of the booted system to confirm that we would be able to unlock with the current booted system
|
||||
// That checks the policy against the signatures and fails if a UKI with those signatures wont be able to unlock the device
|
||||
// Files are generated by systemd automatically and are extracted from the UKI binary directly
|
||||
// public pem cert -> .pcrpkey section fo the elf file
|
||||
// signatures -> .pcrsig section of the elf file
|
||||
args := []string{
|
||||
"--tpm2-public-key=/run/systemd/tpm2-pcr-public-key.pem",
|
||||
fmt.Sprintf("--tpm2-public-key-pcrs=%s", strings.Join(publicKeyPcrs, "+")),
|
||||
fmt.Sprintf("--tpm2-pcrs=%s", strings.Join(pcrs, "+")),
|
||||
"--tpm2-signature=/run/systemd/tpm2-pcr-signature.json",
|
||||
"--tpm2-device-key=/run/systemd/tpm2-srk-public-key.tpm2b_public",
|
||||
device}
|
||||
logger.Logger.Debug().Str("args", strings.Join(args, " ")).Msg("running command")
|
||||
cmd := exec.Command("systemd-cryptenroll", args...)
|
||||
cmd.Env = append(cmd.Env, fmt.Sprintf("PASSWORD=%s", pass), "SYSTEMD_LOG_LEVEL=debug") // cannot pass it via stdin
|
||||
// Store the output into a buffer to log it in case we need it
|
||||
// debug output goes to stderr for some reason?
|
||||
stdOut := bytes.Buffer{}
|
||||
cmd.Stdout = &stdOut
|
||||
cmd.Stderr = &stdOut
|
||||
err = cmd.Run()
|
||||
if err != nil {
|
||||
logger.Logger.Debug().Str("output", stdOut.String()).Msg("debug from cryptenroll")
|
||||
logger.Err(err).Msg("Enrolling measurements")
|
||||
return err
|
||||
}
|
||||
|
||||
logger.Logger.Debug().Str("output", stdOut.String()).Msg("debug from cryptenroll")
|
||||
|
||||
err = formatLuks(device, b.Name, mapper, label, pass, logger)
|
||||
if err != nil {
|
||||
logger.Err(err).Msg("format luks")
|
||||
return err
|
||||
}
|
||||
|
||||
// Delete password slot from luks device
|
||||
out, err = utils.SH(fmt.Sprintf("systemd-cryptenroll --wipe-slot=password %s", device))
|
||||
if err != nil {
|
||||
logger.Err(err).Str("out", out).Msg("Removing password")
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// format luks will unlock the device, wait for it and then format it
|
||||
// device is the actual /dev/X luks device
|
||||
// label is the label we will set to the formatted partition
|
||||
// password is the pass to unlock the device to be able to format the underlying mapper.
|
||||
func formatLuks(device, name, mapper, label, pass string, logger types.KairosLogger) error {
|
||||
l := logger.Logger.With().Str("device", device).Str("name", name).Str("mapper", mapper).Logger()
|
||||
l.Debug().Msg("unlock")
|
||||
if err := luksUnlock(device, name, pass); err != nil {
|
||||
return fmt.Errorf("unlock err: %w", err)
|
||||
}
|
||||
|
||||
l.Debug().Msg("wait device")
|
||||
if err := waitDevice(mapper, 10); err != nil {
|
||||
return fmt.Errorf("waitdevice err: %w", err)
|
||||
}
|
||||
|
||||
l.Debug().Msg("format")
|
||||
cmdFormat := fmt.Sprintf("mkfs.ext4 -L %s %s", label, mapper)
|
||||
out, err := utils.SH(cmdFormat)
|
||||
if err != nil {
|
||||
return fmt.Errorf("mkfs err: %w, out: %s", err, out)
|
||||
}
|
||||
|
||||
// Refresh needs the password as its doing actions on the device directly
|
||||
l.Debug().Msg("discards")
|
||||
cmd := exec.Command("cryptsetup", "refresh", "--persistent", "--allow-discards", mapper)
|
||||
cmd.Stdin = strings.NewReader(pass)
|
||||
output, err := cmd.CombinedOutput()
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("refresh err: %w, out: %s", err, string(output))
|
||||
}
|
||||
|
||||
l.Debug().Msg("close")
|
||||
out, err = utils.SH(fmt.Sprintf("cryptsetup close %s", mapper))
|
||||
if err != nil {
|
||||
return fmt.Errorf("lock err: %w, out: %s", err, out)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func findPartition(label string) (string, *block.Partition, error) {
|
||||
b, err := ghw.Block()
|
||||
if err == nil {
|
||||
for _, disk := range b.Disks {
|
||||
for _, p := range disk.Partitions {
|
||||
if p.FilesystemLabel == label {
|
||||
return p.Name, p, nil
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return "", nil, err
|
||||
}
|
||||
|
||||
return "", nil, fmt.Errorf("not found label %s", label)
|
||||
}
|
||||
|
||||
func waitDevice(device string, attempts int) error {
|
||||
for tries := 0; tries < attempts; tries++ {
|
||||
_, err := utils.SH("udevadm settle")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
syscall.Sync()
|
||||
_, err = os.Lstat(device)
|
||||
if !os.IsNotExist(err) {
|
||||
return nil
|
||||
}
|
||||
time.Sleep(1 * time.Second)
|
||||
}
|
||||
return fmt.Errorf("no device found %s", device)
|
||||
}
|
112
kcrypt/unlock.go
Normal file
112
kcrypt/unlock.go
Normal file
@ -0,0 +1,112 @@
|
||||
package kcrypt
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"path/filepath"
|
||||
|
||||
"github.com/anatol/luks.go"
|
||||
"github.com/jaypipes/ghw"
|
||||
"github.com/jaypipes/ghw/pkg/block"
|
||||
"github.com/kairos-io/kairos-sdk/kcrypt/bus"
|
||||
"github.com/kairos-io/kairos-sdk/types"
|
||||
"github.com/kairos-io/kairos-sdk/utils"
|
||||
"github.com/mudler/go-pluggable"
|
||||
)
|
||||
|
||||
// UnlockAll Unlocks all encrypted devices found in the system.
|
||||
func UnlockAll(tpm bool, log types.KairosLogger) error {
|
||||
bus.Manager.Initialize()
|
||||
logger := log.Logger
|
||||
|
||||
blk, err := ghw.Block()
|
||||
if err != nil {
|
||||
logger.Warn().Msgf("Warning: Error reading partitions '%s \n", err.Error())
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Some versions of udevadm don't support --settle (e.g. alpine)
|
||||
// and older versions don't have --type=all. Try the simpler version then.
|
||||
logger.Info().Msgf("triggering udev to populate disk info")
|
||||
_, err = utils.SH("udevadm trigger --type=all || udevadm trigger")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, disk := range blk.Disks {
|
||||
for _, p := range disk.Partitions {
|
||||
if p.Type == "crypto_LUKS" {
|
||||
// Check if device is already mounted
|
||||
// We mount it under /dev/mapper/DEVICE, so It's pretty easy to check
|
||||
if !utils.Exists(filepath.Join("/dev", "mapper", p.Name)) {
|
||||
logger.Info().Msgf("Unmounted Luks found at '%s'", filepath.Join("/dev", p.Name))
|
||||
if tpm {
|
||||
out, err := utils.SH(fmt.Sprintf("/usr/lib/systemd/systemd-cryptsetup attach %s %s - tpm2-device=auto", p.Name, filepath.Join("/dev", p.Name)))
|
||||
if err != nil {
|
||||
logger.Warn().Msgf("Unlocking failed: '%s'", err.Error())
|
||||
logger.Warn().Msgf("Unlocking failed, command output: '%s'", out)
|
||||
}
|
||||
} else {
|
||||
err = UnlockDisk(p)
|
||||
if err != nil {
|
||||
logger.Warn().Msgf("Unlocking failed: '%s'", err.Error())
|
||||
}
|
||||
logger.Info().Msg("Unlocking succeeded")
|
||||
}
|
||||
} else {
|
||||
logger.Info().Msgf("Device %s seems to be mounted at %s, skipping\n", filepath.Join("/dev", p.Name), filepath.Join("/dev", "mapper", p.Name))
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// UnlockDisk unlocks a single block.Partition.
|
||||
func UnlockDisk(b *block.Partition) error {
|
||||
pass, err := getPassword(b)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error retrieving password remotely: %w", err)
|
||||
}
|
||||
|
||||
return luksUnlock(filepath.Join("/dev", b.Name), b.Name, pass)
|
||||
}
|
||||
|
||||
// GetPassword gets the password for a block.Partition
|
||||
// TODO: Ask to discovery a pass to unlock. keep waiting until we get it and a timeout is exhausted with retrials (exp backoff).
|
||||
func getPassword(b *block.Partition) (password string, err error) {
|
||||
bus.Reload()
|
||||
|
||||
bus.Manager.Response(bus.EventDiscoveryPassword, func(_ *pluggable.Plugin, r *pluggable.EventResponse) {
|
||||
password = r.Data
|
||||
if r.Errored() {
|
||||
err = fmt.Errorf("failed discovery: %s", r.Error)
|
||||
}
|
||||
})
|
||||
_, err = bus.Manager.Publish(bus.EventDiscoveryPassword, b)
|
||||
if err != nil {
|
||||
return password, err
|
||||
}
|
||||
|
||||
if password == "" {
|
||||
return password, fmt.Errorf("received empty password")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func luksUnlock(device, mapper, password string) error {
|
||||
dev, err := luks.Open(device)
|
||||
if err != nil {
|
||||
// handle error
|
||||
return err
|
||||
}
|
||||
defer dev.Close()
|
||||
err = dev.Unlock(0, []byte(password), mapper)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
Loading…
Reference in New Issue
Block a user