'gpg list keys error trustdb is not writable
When I try to list my gpg keys I'm getting an error:
gpg --list-keys
gpg: NOTE: trustdb not writable
gpg: checking the trustdb
gpg: trustdb rec 56: write failed (n=-1): Bad file descriptor
gpg: trustdb: sync failed: Bad file descriptor
I tried doing a recursive chown on my user directory. But that didn't seem to solve the problem.
The volume is not read only:
[web1:~] bluethundr% touch test
[web1:~] bluethundr% echo hi > test
[web1:~] bluethundr% cat test
hi
So I'm wondering why the trustdb is not writable.
How can I solve this?
Solution 1:[1]
That seems to have been reported in bug 771976
I found this when running the command
apt-key liston a machine where the root filesystem is normally mounted read-only.
This results in runninggpgwith "--trustdb-name", "/etc/apt//trustdb.gpg", "--list-keys".gpgin turn attempts to create "/etc/apt//trustdb.gpg.lock" in order to lock thetrustdb, which fails.Seeing how
--list-keysis an operation which shouldn't require writing to anything, having it fail in this situation is bad.
Even though the volume is not read-only, check (with an strace) where gpg --list-key is attempting to create its trustdb.gpg.lock file.
strace gpg --list-key | grep trustdb.gpg.lock
The OP bluethundr adds in the comments:
I changed to the
.gnupgdirectory and did a list.
I saw that the files in there were owned byroot! So I did asudo chown -R myuser:myuser *.
Then I rangpg --list-keysagain and it worked!
The problem was that the files in.gnupgwere owned byrootfor some reason.
Solution 2:[2]
I granted the permissions on the trustdb.gpg file present in the installation directory in C Drive, to the user I had logged on with. It worked thereafter.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Sidharth Patra |
