From 237c1cfcded6b5a7d54f0080a2ecb26e84517ded Mon Sep 17 00:00:00 2001 From: Jonathan Gimeno Date: Tue, 26 Jan 2021 10:18:10 +0100 Subject: [PATCH 1/4] fix keyring --- client/keys/migrate.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/client/keys/migrate.go b/client/keys/migrate.go index d80bbe163097..fe53e0d4a8af 100644 --- a/client/keys/migrate.go +++ b/client/keys/migrate.go @@ -62,7 +62,7 @@ func runMigrateCmd(cmd *cobra.Command, args []string) error { var ( tmpDir string - migrator keyring.InfoImporter + migrator keyring.Importer ) if dryRun, _ := cmd.Flags().GetBool(flags.FlagDryRun); dryRun { @@ -73,10 +73,10 @@ func runMigrateCmd(cmd *cobra.Command, args []string) error { defer os.RemoveAll(tmpDir) - migrator, err = keyring.NewInfoImporter(keyringServiceName, "test", tmpDir, buf) + migrator, err = keyring.New(keyringServiceName, keyring.BackendTest, tmpDir, buf) } else { backend, _ := cmd.Flags().GetString(flags.FlagKeyringBackend) - migrator, err = keyring.NewInfoImporter(keyringServiceName, backend, rootDir, buf) + migrator, err = keyring.New(keyringServiceName, backend, rootDir, buf) } if err != nil { @@ -107,7 +107,7 @@ func runMigrateCmd(cmd *cobra.Command, args []string) error { } if keyType != keyring.TypeLocal { - if err := migrator.Import(keyName, legKeyInfo); err != nil { + if err := migrator.ImportPubKey(keyName, legKeyInfo); err != nil { return err } @@ -127,7 +127,7 @@ func runMigrateCmd(cmd *cobra.Command, args []string) error { return err } - if err := migrator.Import(keyName, armoredPriv); err != nil { + if err := migrator.ImportPrivKey(keyName, armoredPriv, migratePassphrase); err != nil { return err } } From 2b45b0b615b52f096a0d3c271969229afa322b2e Mon Sep 17 00:00:00 2001 From: Jonathan Gimeno Date: Thu, 28 Jan 2021 13:48:20 +0100 Subject: [PATCH 2/4] temp commit --- client/keys/migrate.go | 12 ++++++------ crypto/keyring/keyring.go | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/client/keys/migrate.go b/client/keys/migrate.go index fe53e0d4a8af..df1056a22eb4 100644 --- a/client/keys/migrate.go +++ b/client/keys/migrate.go @@ -87,11 +87,6 @@ func runMigrateCmd(cmd *cobra.Command, args []string) error { } for _, key := range oldKeys { - legKeyInfo, err := legacyKb.Export(key.GetName()) - if err != nil { - return err - } - keyName := key.GetName() keyType := key.GetType() @@ -107,7 +102,12 @@ func runMigrateCmd(cmd *cobra.Command, args []string) error { } if keyType != keyring.TypeLocal { - if err := migrator.ImportPubKey(keyName, legKeyInfo); err != nil { + pubkeyArmor, err := legacyKb.ExportPubKey(keyName) + if err != nil { + return err + } + + if err := migrator.ImportPubKey(keyName, pubkeyArmor); err != nil { return err } diff --git a/crypto/keyring/keyring.go b/crypto/keyring/keyring.go index f88ffdc37010..164e6bfc19d5 100644 --- a/crypto/keyring/keyring.go +++ b/crypto/keyring/keyring.go @@ -108,6 +108,7 @@ type Signer interface { type Importer interface { // ImportPrivKey imports ASCII armored passphrase-encrypted private keys. ImportPrivKey(uid, armor, passphrase string) error + // ImportPubKey imports ASCII armored public keys. ImportPubKey(uid string, armor string) error } From 34f744c6ab1e374164f679f85ae2e843c5450611 Mon Sep 17 00:00:00 2001 From: sahith-narahari Date: Mon, 1 Feb 2021 18:37:35 +0530 Subject: [PATCH 3/4] update testdata --- client/keys/migrate.go | 18 ++-- client/keys/testdata/keys/keys.db/000002.ldb | Bin 391 -> 0 bytes client/keys/testdata/keys/keys.db/CURRENT | 2 +- client/keys/testdata/keys/keys.db/CURRENT.bak | 2 +- client/keys/testdata/keys/keys.db/LOG | 81 ++++++++++++++---- .../testdata/keys/keys.db/MANIFEST-000004 | Bin 237 -> 0 bytes 6 files changed, 77 insertions(+), 26 deletions(-) delete mode 100644 client/keys/testdata/keys/keys.db/000002.ldb delete mode 100644 client/keys/testdata/keys/keys.db/MANIFEST-000004 diff --git a/client/keys/migrate.go b/client/keys/migrate.go index fe53e0d4a8af..667435ba053b 100644 --- a/client/keys/migrate.go +++ b/client/keys/migrate.go @@ -86,12 +86,12 @@ func runMigrateCmd(cmd *cobra.Command, args []string) error { )) } - for _, key := range oldKeys { - legKeyInfo, err := legacyKb.Export(key.GetName()) - if err != nil { - return err - } + if len(oldKeys) == 0 { + cmd.Print("Migration Aborted: no keys to migrate") + return nil + } + for _, key := range oldKeys { keyName := key.GetName() keyType := key.GetType() @@ -107,7 +107,12 @@ func runMigrateCmd(cmd *cobra.Command, args []string) error { } if keyType != keyring.TypeLocal { - if err := migrator.ImportPubKey(keyName, legKeyInfo); err != nil { + pubKey, err := legacyKb.ExportPubKey(keyName) + if err != nil { + return err + } + + if err := migrator.ImportPubKey(keyName, pubKey); err != nil { return err } @@ -131,6 +136,7 @@ func runMigrateCmd(cmd *cobra.Command, args []string) error { return err } } + cmd.Print("Migration Complete") return err } diff --git a/client/keys/testdata/keys/keys.db/000002.ldb b/client/keys/testdata/keys/keys.db/000002.ldb deleted file mode 100644 index b36586df3626e4a01631c987005dd5b167ff1da2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 391 zcmey$^r4Z#RxCNcI5)r8Fr~Dl+#<2KsJx`KtSZ&C+#n^bq%tF`u)-ugH7~cY)V$I% zr?5&dF(suawYZp(g#iqTO7lVsQW8s2opV#-y;CcV^fL3(^4ZPAathMRi}EtE%8be? z%1q6&N-NC^O3Kqxat-nfiYqI#QcBBG%aVb{ar!ebvHCgrGpHDX^)kqL7g=R6a7wZ; zGIE+rc**mTQf0Uyr1m=MWxFC%+6+;l*L&_w+s))UMK~hzht#w>p1XUJc$A%Z zPwESPNR;9%PE9T_GBwLK6yWnVVl8E1WG;$fU@+p1Im5hYq0HxtQ@kC!+?#3MRPJ a`@iD$YnizAFo}VL@PqK*4c#iG?zaJJVsO>~ diff --git a/client/keys/testdata/keys/keys.db/CURRENT b/client/keys/testdata/keys/keys.db/CURRENT index cacca7574c03..5b5401076357 100644 --- a/client/keys/testdata/keys/keys.db/CURRENT +++ b/client/keys/testdata/keys/keys.db/CURRENT @@ -1 +1 @@ -MANIFEST-000004 +MANIFEST-000011 diff --git a/client/keys/testdata/keys/keys.db/CURRENT.bak b/client/keys/testdata/keys/keys.db/CURRENT.bak index feda7d6b2481..6ba31a31e7d9 100644 --- a/client/keys/testdata/keys/keys.db/CURRENT.bak +++ b/client/keys/testdata/keys/keys.db/CURRENT.bak @@ -1 +1 @@ -MANIFEST-000000 +MANIFEST-000009 diff --git a/client/keys/testdata/keys/keys.db/LOG b/client/keys/testdata/keys/keys.db/LOG index 386101e4fb91..be6db425f461 100644 --- a/client/keys/testdata/keys/keys.db/LOG +++ b/client/keys/testdata/keys/keys.db/LOG @@ -1,18 +1,63 @@ -=============== Mar 30, 2020 (CEST) =============== -02:07:34.137606 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed -02:07:34.144547 db@open opening -02:07:34.144770 version@stat F·[] S·0B[] Sc·[] -02:07:34.145843 db@janitor F·2 G·0 -02:07:34.145875 db@open done T·1.315251ms -02:07:34.335635 db@close closing -02:07:34.335736 db@close done T·98.95µs -=============== Mar 30, 2020 (CEST) =============== -02:08:33.239115 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed -02:08:33.239264 version@stat F·[] S·0B[] Sc·[] -02:08:33.239281 db@open opening -02:08:33.239310 journal@recovery F·1 -02:08:33.239398 journal@recovery recovering @1 -02:08:33.322008 memdb@flush created L0@2 N·4 S·391B "cos..ess,v4":"run..nfo,v3" -02:08:33.323091 version@stat F·[1] S·391B[391B] Sc·[0.25] -02:08:33.421979 db@janitor F·3 G·0 -02:08:33.422153 db@open done T·182.707962ms +=============== Feb 1, 2021 (IST) =============== +16:21:11.241398 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +16:21:11.243153 db@open opening +16:21:11.243424 version@stat F·[] S·0B[] Sc·[] +16:21:11.244292 db@janitor F·2 G·0 +16:21:11.244303 db@open done T·1.142421ms +16:21:11.244375 db@close closing +16:21:11.244408 db@close done T·31.874µs +=============== Feb 1, 2021 (IST) =============== +16:21:17.369959 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +16:21:17.370084 version@stat F·[] S·0B[] Sc·[] +16:21:17.370100 db@open opening +16:21:17.370135 journal@recovery F·1 +16:21:17.370329 journal@recovery recovering @1 +16:21:17.370945 version@stat F·[] S·0B[] Sc·[] +16:21:17.374111 db@janitor F·2 G·0 +16:21:17.374126 db@open done T·4.016021ms +16:21:17.374195 db@close closing +16:21:17.374225 db@close done T·27.227µs +=============== Feb 1, 2021 (IST) =============== +16:21:48.914309 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +16:21:48.914401 version@stat F·[] S·0B[] Sc·[] +16:21:48.914416 db@open opening +16:21:48.914450 journal@recovery F·1 +16:21:48.914706 journal@recovery recovering @2 +16:21:48.915231 version@stat F·[] S·0B[] Sc·[] +16:21:48.918621 db@janitor F·2 G·0 +16:21:48.918633 db@open done T·4.211047ms +16:21:48.918705 db@close closing +16:21:48.918742 db@close done T·34.202µs +=============== Feb 1, 2021 (IST) =============== +16:22:52.655807 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +16:22:52.655895 version@stat F·[] S·0B[] Sc·[] +16:22:52.655910 db@open opening +16:22:52.655941 journal@recovery F·1 +16:22:52.656203 journal@recovery recovering @4 +16:22:52.656729 version@stat F·[] S·0B[] Sc·[] +16:22:52.662351 db@janitor F·2 G·0 +16:22:52.662365 db@open done T·6.448973ms +16:22:52.662441 db@close closing +16:22:52.662481 db@close done T·36.569µs +=============== Feb 1, 2021 (IST) =============== +16:24:37.777292 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +16:24:37.777381 version@stat F·[] S·0B[] Sc·[] +16:24:37.777395 db@open opening +16:24:37.777428 journal@recovery F·1 +16:24:37.777493 journal@recovery recovering @6 +16:24:37.777727 version@stat F·[] S·0B[] Sc·[] +16:24:37.780960 db@janitor F·2 G·0 +16:24:37.780971 db@open done T·3.570978ms +16:24:37.780980 db@close closing +16:24:37.781006 db@close done T·23.906µs +=============== Feb 1, 2021 (IST) =============== +16:24:43.762162 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +16:24:43.762469 version@stat F·[] S·0B[] Sc·[] +16:24:43.762571 db@open opening +16:24:43.762743 journal@recovery F·1 +16:24:43.764835 journal@recovery recovering @8 +16:24:43.765010 version@stat F·[] S·0B[] Sc·[] +16:24:43.769368 db@janitor F·2 G·0 +16:24:43.769396 db@open done T·6.808452ms +16:24:44.024164 db@close closing +16:24:44.024216 db@close done T·50.711µs diff --git a/client/keys/testdata/keys/keys.db/MANIFEST-000004 b/client/keys/testdata/keys/keys.db/MANIFEST-000004 deleted file mode 100644 index 557b4bdbbc93fd41441cfe30d1ca16f08f47f344..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 237 zcmeykNagJ_21Z7yoYb<^oRlOzr^=Gl^338?=ltA)#G=HK{30f1W>ywfb_S+)X4~Za z;@tdV!<5pJa*M>`qVkf`vZ_?ma)Xq#lFE#%!U~i0)V$onQu9j7oWd%-#FUhx)Z$`B l76veoD=N(kEl5c$Np;RmiT6&eG}6n=OUq|uhDg)i1^~DrOBnzF From d1366136340b5c5bd187e56a386153f1cb255a93 Mon Sep 17 00:00:00 2001 From: sahith-narahari Date: Tue, 2 Feb 2021 00:38:43 +0530 Subject: [PATCH 4/4] update key log --- client/keys/testdata/keys/keys.db/CURRENT | 2 +- client/keys/testdata/keys/keys.db/CURRENT.bak | 2 +- client/keys/testdata/keys/keys.db/LOG | 93 ++++++------------ .../testdata/keys/keys.db/MANIFEST-000005 | Bin 0 -> 41 bytes 4 files changed, 32 insertions(+), 65 deletions(-) create mode 100644 client/keys/testdata/keys/keys.db/MANIFEST-000005 diff --git a/client/keys/testdata/keys/keys.db/CURRENT b/client/keys/testdata/keys/keys.db/CURRENT index 5b5401076357..aa5bb8ea5090 100644 --- a/client/keys/testdata/keys/keys.db/CURRENT +++ b/client/keys/testdata/keys/keys.db/CURRENT @@ -1 +1 @@ -MANIFEST-000011 +MANIFEST-000005 diff --git a/client/keys/testdata/keys/keys.db/CURRENT.bak b/client/keys/testdata/keys/keys.db/CURRENT.bak index 6ba31a31e7d9..4fb1dad19e03 100644 --- a/client/keys/testdata/keys/keys.db/CURRENT.bak +++ b/client/keys/testdata/keys/keys.db/CURRENT.bak @@ -1 +1 @@ -MANIFEST-000009 +MANIFEST-000003 diff --git a/client/keys/testdata/keys/keys.db/LOG b/client/keys/testdata/keys/keys.db/LOG index be6db425f461..e37648b855bb 100644 --- a/client/keys/testdata/keys/keys.db/LOG +++ b/client/keys/testdata/keys/keys.db/LOG @@ -1,63 +1,30 @@ -=============== Feb 1, 2021 (IST) =============== -16:21:11.241398 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed -16:21:11.243153 db@open opening -16:21:11.243424 version@stat F·[] S·0B[] Sc·[] -16:21:11.244292 db@janitor F·2 G·0 -16:21:11.244303 db@open done T·1.142421ms -16:21:11.244375 db@close closing -16:21:11.244408 db@close done T·31.874µs -=============== Feb 1, 2021 (IST) =============== -16:21:17.369959 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed -16:21:17.370084 version@stat F·[] S·0B[] Sc·[] -16:21:17.370100 db@open opening -16:21:17.370135 journal@recovery F·1 -16:21:17.370329 journal@recovery recovering @1 -16:21:17.370945 version@stat F·[] S·0B[] Sc·[] -16:21:17.374111 db@janitor F·2 G·0 -16:21:17.374126 db@open done T·4.016021ms -16:21:17.374195 db@close closing -16:21:17.374225 db@close done T·27.227µs -=============== Feb 1, 2021 (IST) =============== -16:21:48.914309 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed -16:21:48.914401 version@stat F·[] S·0B[] Sc·[] -16:21:48.914416 db@open opening -16:21:48.914450 journal@recovery F·1 -16:21:48.914706 journal@recovery recovering @2 -16:21:48.915231 version@stat F·[] S·0B[] Sc·[] -16:21:48.918621 db@janitor F·2 G·0 -16:21:48.918633 db@open done T·4.211047ms -16:21:48.918705 db@close closing -16:21:48.918742 db@close done T·34.202µs -=============== Feb 1, 2021 (IST) =============== -16:22:52.655807 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed -16:22:52.655895 version@stat F·[] S·0B[] Sc·[] -16:22:52.655910 db@open opening -16:22:52.655941 journal@recovery F·1 -16:22:52.656203 journal@recovery recovering @4 -16:22:52.656729 version@stat F·[] S·0B[] Sc·[] -16:22:52.662351 db@janitor F·2 G·0 -16:22:52.662365 db@open done T·6.448973ms -16:22:52.662441 db@close closing -16:22:52.662481 db@close done T·36.569µs -=============== Feb 1, 2021 (IST) =============== -16:24:37.777292 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed -16:24:37.777381 version@stat F·[] S·0B[] Sc·[] -16:24:37.777395 db@open opening -16:24:37.777428 journal@recovery F·1 -16:24:37.777493 journal@recovery recovering @6 -16:24:37.777727 version@stat F·[] S·0B[] Sc·[] -16:24:37.780960 db@janitor F·2 G·0 -16:24:37.780971 db@open done T·3.570978ms -16:24:37.780980 db@close closing -16:24:37.781006 db@close done T·23.906µs -=============== Feb 1, 2021 (IST) =============== -16:24:43.762162 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed -16:24:43.762469 version@stat F·[] S·0B[] Sc·[] -16:24:43.762571 db@open opening -16:24:43.762743 journal@recovery F·1 -16:24:43.764835 journal@recovery recovering @8 -16:24:43.765010 version@stat F·[] S·0B[] Sc·[] -16:24:43.769368 db@janitor F·2 G·0 -16:24:43.769396 db@open done T·6.808452ms -16:24:44.024164 db@close closing -16:24:44.024216 db@close done T·50.711µs +=============== Feb 2, 2021 (IST) =============== +00:03:25.348369 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +00:03:25.350695 db@open opening +00:03:25.350888 version@stat F·[] S·0B[] Sc·[] +00:03:25.351864 db@janitor F·2 G·0 +00:03:25.351881 db@open done T·1.169825ms +00:03:25.351895 db@close closing +00:03:25.351929 db@close done T·33.042µs +=============== Feb 2, 2021 (IST) =============== +00:03:34.450638 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +00:03:34.450722 version@stat F·[] S·0B[] Sc·[] +00:03:34.450737 db@open opening +00:03:34.450765 journal@recovery F·1 +00:03:34.450851 journal@recovery recovering @1 +00:03:34.451173 version@stat F·[] S·0B[] Sc·[] +00:03:34.454278 db@janitor F·2 G·0 +00:03:34.454298 db@open done T·3.548046ms +00:03:34.454307 db@close closing +00:03:34.454327 db@close done T·19.017µs +=============== Feb 2, 2021 (IST) =============== +00:03:42.025705 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed +00:03:42.025892 version@stat F·[] S·0B[] Sc·[] +00:03:42.025907 db@open opening +00:03:42.025943 journal@recovery F·1 +00:03:42.026790 journal@recovery recovering @2 +00:03:42.026946 version@stat F·[] S·0B[] Sc·[] +00:03:42.031645 db@janitor F·2 G·0 +00:03:42.031661 db@open done T·5.750008ms +00:03:42.283102 db@close closing +00:03:42.283162 db@close done T·58.775µs diff --git a/client/keys/testdata/keys/keys.db/MANIFEST-000005 b/client/keys/testdata/keys/keys.db/MANIFEST-000005 new file mode 100644 index 0000000000000000000000000000000000000000..a9e8a261c7882e802f65360dc49782db7df6fb77 GIT binary patch literal 41 wcmYcef4W17fss)vC$%g!CnZVGsj?)sJhM2}IX|}`u_&=5zle#2nT>@304?eb82|tP literal 0 HcmV?d00001