From 2180aabc816aae1fb4bb7c341fee53fe48ffa98e Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Sat, 1 Dec 2018 19:36:23 -0500 Subject: arch-nspawn: don't delete the guest gpg configuration It's important to ensure the guest has up to date data because updating a chroot after quite some time can potentially rely on updated archlinux-keyring, something which the host machine either kept up to date on or manually fixed, but it kills automation to mess around with chroot configs like that. Alternatively, signed packages added with -I need to work, and we assume the host is configured to accept these. That is *not* a good reason to completely nuke whatever is in the guest, though. A guest might have been manually configured to accept keys which aren't accepted by the host; one example of this happening in practice, is archlinux32 when building 32-bit packages from an archlinux host. The right solution is to append to, rather thna overwrite, the chrooted guest's pacman keyring. To do this, we will use gpg's native facility to dump the keyring from one GNUPGHOME and import it into another. We'd use pacman-key's --import option directly, but this doesn't support passing custom options like --import-options import-local-sigs Finally use pacman-key's native facility to import the trust status from the host. While we are at it, fix a bug where we didn't respect the host's pacman.conf settings for the GpgDir. While it isn't wildly likely a user will choose to customize this, it is a valid and supported use case and we must think about this ourselves. Signed-off-by: Eli Schwartz Signed-off-by: Levente Polyak --- arch-nspawn.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'arch-nspawn.in') diff --git a/arch-nspawn.in b/arch-nspawn.in index 42f7779..a0e24dc 100644 --- a/arch-nspawn.in +++ b/arch-nspawn.in @@ -80,7 +80,8 @@ build_mount_args() { } copy_hostconf () { - cp -a /etc/pacman.d/gnupg "$working_dir/etc/pacman.d" + gpg --homedir "$working_dir"/etc/pacman.d/gnupg/ --no-permission-warning --quiet --batch --import --import-options import-local-sigs "$(pacman-conf GpgDir)"/pubring.gpg >/dev/null 2>&1 + pacman-key --gpgdir "$working_dir"/etc/pacman.d/gnupg/ --import-trustdb "$(pacman-conf GpgDir)" >/dev/null 2>&1 printf 'Server = %s\n' "${host_mirrors[@]}" >"$working_dir/etc/pacman.d/mirrorlist" [[ -n $pac_conf ]] && cp "$pac_conf" "$working_dir/etc/pacman.conf" -- cgit v1.2.3-70-g09d2