[pacman-dev] [PATCH] pacman-key: Add --import and --import-trustdb
Currently, pacman-key allows users to import their keys using the --add option
but no similar functionality exists for importing ownertrust values.
The --import-trustdb option takes in a list of directories and imports
ownertrust values if the directories have a trustdb.gpg database.
The --import is a combination of --add and --import-trustdb. It takes in a list
of directories and imports keys from pubring.gpg, ownertrust values from
trustdb.gpg if any of these files exist.
Signed-off-by: Pang Yan Han
On 10/06/11 16:38, Pang Yan Han wrote:
Currently, pacman-key allows users to import their keys using the --add option but no similar functionality exists for importing ownertrust values.
The --import-trustdb option takes in a list of directories and imports ownertrust values if the directories have a trustdb.gpg database.
The --import is a combination of --add and --import-trustdb. It takes in a list of directories and imports keys from pubring.gpg, ownertrust values from trustdb.gpg if any of these files exist.
Signed-off-by: Pang Yan Han
--- NOTE: There is this very strange bug such that when new keys are added, previously imported keys will fail for signature verification. This happens with both --add and --import. Eg. Say you want to import trustdb.gpg and pubring.gpg from directories "first", "second" and "third", you'd have to:
# pacman-key --import first second third # pacman-key --import first second third
I have not gone through your patch in detail yet, but I do not see this issue you report when using the --add option: allan@mugen /home/arch/code/pacman (working)
./scripts/pacman-key --verify /home/allan/web/allanbrokeit/i686/allanbrokeit.db.sig gpg: Signature made Tue 05 Jul 2011 15:22:42 EST using RSA key ID EAE999BD gpg: NOTE: trustdb not writable gpg: Good signature from "Allan McRae
" gpg: aka "Allan McRae (Developer) "
allan@mugen /home/arch/code/pacman (working)
sudo ./scripts/pacman-key --add /home/allan/dan.gpg gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model gpg: depth: 0 valid: 1 signed: 0 trust: 0-, 0q, 0n, 0m, 0f, 1u
allan@mugen /home/arch/code/pacman (working)
./scripts/pacman-key --verify /home/allan/web/allanbrokeit/i686/allanbrokeit.db.sig gpg: Signature made Tue 05 Jul 2011 15:22:42 EST using RSA key ID EAE999BD gpg: NOTE: trustdb not writable gpg: Good signature from "Allan McRae
" gpg: aka "Allan McRae (Developer) "
So the signature verification still works after adding a key with --add. There are two possibilities here... 1) this is fixed due to the large number of changes on my working branch, or 2) there is something wrong with the --import stuff... Can you give more details on this issue so I can follow it up and get this patch merged. Cheers, Allan
Hi Allan,
I'll send 2 small patches to be applied on top of your working branch, and
an edited version of the --import patch soon.
The issue I mentioned is with regards to pacman -U and pacman-key --import.
I edited the patch so that it'll work with the new pacman-key code, and the
same
thing happens.
Basically, I tried installing 2 packages signed by 2 different keys. They
are
"ack-1.94-2-any.pkg.tar.xz" and "archlinux-wallpaper-1.3-2-any.pkg.tar.xz"
Their respective .sig files (detached signatures) are in the same
directories.
So I did:
[root@localhost ~] # pacman-key --init
gpg: /usr/local/etc/pacman.d/gnupg/trustdb.gpg: trustdb created
gpg: no ultimately trusted keys found
[root@localhost ~] # pacman -U ack-1.94-2-any.pkg.tar.xz
error: 'ack-1.94-2-any.pkg.tar.xz': Invalid or corrupted package (PGP
signature)
[root@localhost ~] # pacman --import .gnupg/
gpg: inserting ownertrust of 6
gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
gpg: depth: 0 valid: 1 signed: 0 trust: 0-, 0q, 0n, 0m, 0f, 1u
[root@localhost ~] # pacman -U ack-1.94-2-any.pkg.tar.xz
Works now with pacman, but I didn't install anything.
Then, I proceeded to import the trustdb with the key for the archlinux
wallpaper package.
[root@localhost ~] # pacman-key --import /home/yh/.gnupg/
gpg: WARNING: unsafe ownership on homedir `/home/yh/.gnupg/'
gpg: inserting ownertrust of 6
gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
gpg: depth: 0 valid: 1 signed: 0 trust: 0-, 0q, 0n, 0m, 0f, 1u
[root@localhost ~] # pacman -U archlinux-wallpaper-1.3-2-any.pkg.tar.xz
Works now
But then the one for ack fails:
[root@localhost ~] # pacman -U ack-1.94-2-any.pkg.tar.xz
error: 'ack-1.94-2-any.pkg.tar.xz': invalid or corrupted package (PGP
signature)
And the previously successful pacman-key --verify for the ack package spurt
out some warning messages this time:
[root@localhost ~] # pacman-key --verify ack-1.94-2-any.pkg.tar.xz
gpg: Signature made Fri 10 Jun 2011 11:44:28 AM SGT using RSA key ID
CF7AE1C9
gpg: Good signature from "testing123
On 10/06/11 16:38, Pang Yan Han wrote:
Currently, pacman-key allows users to import their keys using the --add option but no similar functionality exists for importing ownertrust values.
The --import-trustdb option takes in a list of directories and imports ownertrust values if the directories have a trustdb.gpg database.
The --import is a combination of --add and --import-trustdb. It takes in a list of directories and imports keys from pubring.gpg, ownertrust values from trustdb.gpg if any of these files exist.
Signed-off-by: Pang Yan Han
--- NOTE: There is this very strange bug such that when new keys are added, previously imported keys will fail for signature verification. This happens with both --add and --import. Eg. Say you want to import trustdb.gpg and pubring.gpg from directories "first", "second" and "third", you'd have to:
# pacman-key --import first second third # pacman-key --import first second third
I have not gone through your patch in detail yet, but I do not see this issue you report when using the --add option:
allan@mugen /home/arch/code/pacman (working)
./scripts/pacman-key --verify /home/allan/web/allanbrokeit/** i686/allanbrokeit.db.sig gpg: Signature made Tue 05 Jul 2011 15:22:42 EST using RSA key ID EAE999BD gpg: NOTE: trustdb not writable gpg: Good signature from "Allan McRae
" gpg: aka "Allan McRae (Developer) " allan@mugen /home/arch/code/pacman (working)
sudo ./scripts/pacman-key --add /home/allan/dan.gpg gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model gpg: depth: 0 valid: 1 signed: 0 trust: 0-, 0q, 0n, 0m, 0f, 1u
allan@mugen /home/arch/code/pacman (working)
./scripts/pacman-key --verify /home/allan/web/allanbrokeit/** i686/allanbrokeit.db.sig gpg: Signature made Tue 05 Jul 2011 15:22:42 EST using RSA key ID EAE999BD gpg: NOTE: trustdb not writable gpg: Good signature from "Allan McRae
" gpg: aka "Allan McRae (Developer) " So the signature verification still works after adding a key with --add. There are two possibilities here... 1) this is fixed due to the large number of changes on my working branch, or 2) there is something wrong with the --import stuff...
Can you give more details on this issue so I can follow it up and get this patch merged.
Cheers, Allan
On 10/07/11 14:10, Pang Yan Han wrote:
The issue I mentioned is with regards to pacman -U and pacman-key --import. I edited the patch so that it'll work with the new pacman-key code, and the same thing happens.
Basically, I tried installing 2 packages signed by 2 different keys. They are "ack-1.94-2-any.pkg.tar.xz" and "archlinux-wallpaper-1.3-2-any.pkg.tar.xz" Their respective .sig files (detached signatures) are in the same directories.
So I did:
[root@localhost ~] # pacman-key --init gpg: /usr/local/etc/pacman.d/gnupg/trustdb.gpg: trustdb created gpg: no ultimately trusted keys found
[root@localhost ~] # pacman -U ack-1.94-2-any.pkg.tar.xz error: 'ack-1.94-2-any.pkg.tar.xz': Invalid or corrupted package (PGP signature)
[root@localhost ~] # pacman --import .gnupg/ gpg: inserting ownertrust of 6 gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model gpg: depth: 0 valid: 1 signed: 0 trust: 0-, 0q, 0n, 0m, 0f, 1u
[root@localhost ~] # pacman -U ack-1.94-2-any.pkg.tar.xz Works now with pacman, but I didn't install anything.
Then, I proceeded to import the trustdb with the key for the archlinux wallpaper package.
[root@localhost ~] # pacman-key --import /home/yh/.gnupg/ gpg: WARNING: unsafe ownership on homedir `/home/yh/.gnupg/' gpg: inserting ownertrust of 6 gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model gpg: depth: 0 valid: 1 signed: 0 trust: 0-, 0q, 0n, 0m, 0f, 1u
[root@localhost ~] # pacman -U archlinux-wallpaper-1.3-2-any.pkg.tar.xz Works now
But then the one for ack fails: [root@localhost ~] # pacman -U ack-1.94-2-any.pkg.tar.xz error: 'ack-1.94-2-any.pkg.tar.xz': invalid or corrupted package (PGP signature)
This is because of how --import-ownertrust works: --import-ownertrust Update the trustdb with the ownertrust values stored in files (or STDIN if not given); existing values will be overwritten. That last bit is the key to the issue! So we need to be smarter in this bit here.... +import_trustdb() { + local importdir + for importdir in "${IMPORT_DIRS[@]}"; do + if [[ -f "${importdir}/trustdb.gpg" ]]; then + gpg --homedir "${importdir}" --export-ownertrust | ${GPG_PACMAN} --import-ownertrust + fi + done +} Only that last trustdb will end up being imported. I think that doing something like this instead: ${GPG_PACMAN} --export-owner-trust > tmp.file for importdir in "${IMPORT_DIRS[@]}"; do if [[ -f "${importdir}/trustdb.gpg" ]]; then gpg --homedir "${importdir}" --export-ownertrust >> tmp.file fi done ${GPG_PACMAN} --import-ownertrust tmp.file should work... but I have not tested. If appending the trustdb's together does not work, then create a temporary folder instead and store them all in individual files and pass --import-ownertrust multiple files. Hopefully that fixes this and we cna merge this patch. Cheers, Allan
participants (2)
-
Allan McRae
-
Pang Yan Han