Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New recipients not syncing public keys #1980

Closed
akadaedalus opened this issue Aug 27, 2021 · 9 comments · Fixed by #2152
Closed

New recipients not syncing public keys #1980

akadaedalus opened this issue Aug 27, 2021 · 9 comments · Fixed by #2152
Assignees
Labels
bug Defects
Milestone

Comments

@akadaedalus
Copy link

Summary

Add recipients not adding new keys in .public-keys or importing them

Steps To Reproduce

gopass recipients add
gopass sync

second machine:
gopass sync
gopass recipients

output:

Don't really want to paste my recipients list but I get the last line:
└── XXXXXXXXXXXXXXXXXXXXXXXXXXXXX (missing public key)

Expected behavior

Automatic import of new keys

Environment

Observed on two machines:
OS: Gentoo on WSL

$ uname -a
Linux SurfacePro4 5.10.16.3-microsoft-standard-WSL2 #1 SMP Fri Apr 2 22:23:49 UTC 2021 x86_64 Intel(R) Core(TM) i5-6300U CPU @ 2.40GHz GenuineIntel GNU/Linux

$ gopass version
gopass 1.8.6-git+HEAD go1.12.13 linux amd64
- gpg 2.2.19 - git 2.24.1 - fs 0.1.0
Available Crypto Backends: gpgcli, openpgp, plain, xc
Available RCS Backends: gitcli, noop
Available Storage Backends: fs, inmem

OS: Gentoo on desktop

$ uname -a
Linux tobiko 5.10.52-gentoo #1 SMP Tue Aug 17 15:37:44 MDT 2021 x86_64 Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz GenuineIntel GNU/Linux

$ gopass version
gopass 1.12.7 (2021-08-11 20:05:33) go1.16.7 linux amd64
- gpg 2.2.27 - git 2.31.1
Available Crypto Backends: age, gpgcli, plain
Available Storage Backends: fs, gitfs

Both versions installed from source via Gentoo ebuild

Additional context

I have been seeing this since the beginning of the year. My only resolution was to manually add the keys to .public-keys and importing them on the other machines with gpg. I have 11 keys spread across various devices.

@theryaz
Copy link

theryaz commented Mar 8, 2022

I am having the exact same issue

@dominikschulz dominikschulz added the bug Defects label Mar 8, 2022
@dominikschulz dominikschulz added this to the 1.x.x milestone Mar 8, 2022
@dominikschulz
Copy link
Member

This should work. Might be a regression :/

@akadaedalus
Copy link
Author

I forgot about this issue, really. I have a workaround and I don't add devices that often.

Reproduced it in version 1.13.0 (latest Gentoo version). I can bump it to 1.13.1 if you need me to provide debug data.

@AnomalRoil
Copy link
Member

AnomalRoil commented Mar 9, 2022

What does gopass config say?

Is autoimport set to true?

And are the key properly located in their .public-key folder in your password store after adding them?

@akadaedalus
Copy link
Author

As described before, I had to manually add the key to .public-key to work around the issue. I did not see it in there when I reproduced it yesterday. My config:

apalmer@sake:~$ gopass config
autoclip: false
autoimport: true
cliptimeout: 45
exportkeys: false
nopager: false
notifications: true
parsing: true
path: /home/apalmer/.password-store
safecontent: true

Actually, this cluestick was hidden in the exportkeys config. I changed that to true and synced it. That part worked but it's still not right.

apalmer@sake:~ $ gopass config exportkeys true
exportkeys: true

apalmer@sake:~ $ gopass config                
autoclip: false
autoimport: true
cliptimeout: 45
exportkeys: true
nopager: false
notifications: true
parsing: true
path: /home/apalmer/.password-store
safecontent: true

apalmer@sake:~ $ gopass recipients add        
<snip>
[ 5] 0x9710D274011CA739 - Test Key (Test Key for gopass) <testkey@example.com>
<snip>

Add Recipient - (q to abort) [0]: 5
5
Do you want to add "0x9710D274011CA739 - Test Key (Test Key for gopass) <testkey@example.com>" (key "0x9710D274011CA739") as a recipient to the store ""? [y/N/q]: y
Reencrypting existing secrets. This may take some time ...
Starting reencrypt
] 156 / 156 [Gooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooopass] 100.00% 

Added 1 recipients
You need to run 'gopass sync' to push these changes

apalmer@sake:~ $ ls .password-store/.public-keys/*39
.password-store/.public-keys/0x9710D274011CA739

apalmer@sake:~ $ gopass sync
🚥 Syncing with all remotes ...
[<root>] 
   git pull and push ... OK (no changes)
   importing missing keys ... OK
   exporting missing keys ... nothing to do
   done
✅ All done

But it still didn't import on the other system despite autoimport being set to true. On the other system...

apalmer@tobiko:~ $ gopass sync
🚥 Syncing with all remotes ...
[<root>] 
   git pull and push ... OK (no changes)nothing to do
   done
✅ All done

apalmer@tobiko:~ $ gopass recipients
Hint: run 'gopass sync' to import any missing public keys
gopass
<snip>
├── 0x9710D274011CA739 (missing public key)
<snip>

apalmer@tobiko:~ $ gopass config
autoclip: true
autoimport: true
cliptimeout: 45
exportkeys: false
nopager: false
notifications: true
parsing: true
path: /home/apalmer/.password-store
safecontent: false

apalmer@tobiko:~$ ls .password-store/.public-keys/*39
.password-store/.public-keys/0x9710D274011CA739

@akadaedalus
Copy link
Author

I ran one more test, this time setting exportkeys to true on the second server. This time it worked.

apalmer@tobiko:~ $ gopass config exportkeys true
exportkeys: true

apalmer@tobiko:~ $ gopass sync
🚥 Syncing with all remotes ...
[<root>] 
   git pull and push ... OK (no changes)
   importing missing keys ... ❌ [] Failed to get public key for 0x9710D274011CA739: exit status 2: tru::1:1630087464:0:3:1:5
|gpg: error reading key: No public key

[] Imported public key for 0x9710D274011CA739 into Keyring
OK
   exporting missing keys ... nothing to do
   done
✅ All done

apalmer@tobiko:~ $ gopass recipients
Hint: run 'gopass sync' to import any missing public keys
gopass
<snip>
├── 0x9710D274011CA739 - Test Key (Test Key for gopass) <testkey@example.com>
<snip>

I will still call this a bug for several reasons:

  • Changing the behavior of the software between versions is nonsensical, especially when I can't always have the same version on each machine. This is not the first time I've had this frustration (the flags to gopass show specifically). exportkeys should have been true by default to emulate behavior of the previous versions.
  • I can accept that exportkeys needs to be true for new keys to be placed in .public-keys but I cannot accept that it needs to be set for import on other machines. autoimport needs to control that alone.
  • It should probably suppress this error message on auto import. I suspect this is the exportkeys logic importing the key in a roundabout way:
[] Failed to get public key for 0x9710D274011CA739: exit status 2: tru::1:1630087464:0:3:1:5
|gpg: error reading key: No public key

@AnomalRoil
Copy link
Member

AnomalRoil commented Mar 9, 2022

This is definitively a bug.

We will need to discuss whether it makes sense to really have these two config options and make sure their behaviour is what we expect.

Also, we usually try to have sane default settings and to import the previous config in a compatible way when we add or change the config. It's also a bug that the behaviour changed on your machine by changing the version. Do you know when it changed? With which version?

@akadaedalus
Copy link
Author

I don't recall when the behavior changed, unfortunately. If I had to guess via git history it probably worked in September 2019 and failed in December 2020.. The various changes in copying to a clipboard were much more visible and confusing.

Don't get me wrong, I really like this product. I've been using O.G. zx2c4 password-store since 2013 and replaced it with gopass in January 2019. It syncs over quite a few Linux, Windows, and Android devices. Thanks.

@dominikschulz
Copy link
Member

You did make some good points in #1980 (comment).

  • I'm not sure what behaviour changed how, maybe this was not intentional. But historically we did add features / flags without too much planning and discussion and that led to an overloaded interface w/o clear defintions. We have tried to improve that by documenting the intended CLI behaviour and common use cases that we want to support. But this is probably still incomplete. And the implementation might diverge from the definition. This is a lot of work, any help (like New recipients not syncing public keys #1980 (comment)) is appreciated.
  • exportkeys should not be necessary to import keys if autoimport is set to true. This is a bug.
  • The error message should be suppressed, this is another bug.

Also I wonder if we (still) need both of exportkeys and autoimport.

dominikschulz added a commit to dominikschulz/gopass that referenced this issue Mar 11, 2022
This commit splits key import and export during sync. It will always
attempt to import missing public keys if they are found in the store.
Exporting is still controlled by exportkeys but that shouldn't affect
importing anymore. Also some logging and missing config defaults are
fixed.

Fixes gopasspw#1980

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
@dominikschulz dominikschulz self-assigned this Mar 11, 2022
@dominikschulz dominikschulz modified the milestones: 1.x.x, 1.14.0 Mar 11, 2022
AnomalRoil pushed a commit that referenced this issue Mar 12, 2022
* Fix autoimport / exportkeys

This commit splits key import and export during sync. It will always
attempt to import missing public keys if they are found in the store.
Exporting is still controlled by exportkeys but that shouldn't affect
importing anymore. Also some logging and missing config defaults are
fixed.

Fixes #1980

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>

* Update config tests

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
kpitt pushed a commit to kpitt/gopass that referenced this issue Jul 21, 2022
* Fix autoimport / exportkeys

This commit splits key import and export during sync. It will always
attempt to import missing public keys if they are found in the store.
Exporting is still controlled by exportkeys but that shouldn't affect
importing anymore. Also some logging and missing config defaults are
fixed.

Fixes gopasspw#1980

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>

* Update config tests

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Defects
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants