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

Add support for Arch Linux Dockerfiles #15

Merged
merged 1 commit into from Oct 25, 2022

Conversation

kpcyrd
Copy link
Contributor

@kpcyrd kpcyrd commented Oct 21, 2022

It's half-working, it currently fails with this error:

#15 21.96 (231/236) xz-5.2.7-1-x86_64.pkg.tar.zst Already installed
#15 21.96 (232/236) xz-5.2.7-1-x86_64.pkg.tar.zst.sig Cached
#15 21.96 (233/236) zlib-1:1.2.13-1-x86_64.pkg.tar.zst Already installed
#15 21.96 (234/236) zlib-1:1.2.13-1-x86_64.pkg.tar.zst.sig Cached
#15 21.96 (235/236) zstd-1.5.2-7-x86_64.pkg.tar.zst Already installed
#15 21.96 (236/236) zstd-1.5.2-7-x86_64.pkg.tar.zst.sig Cached
#15 21.96 time="2022-10-21T20:51:59Z" level=info msg="Running '/usr/sbin/pacman-key --verify ...' with 118 signatures"
#15 21.98 ==> Checking /tmp/repro-get-pacman-3422555567.tmp/acl-2.3.1-2-x86_64.pkg.tar.zst.sig... (detached)
#15 21.99 gpg: Signature made Tue Feb  1 15:50:49 2022 UTC
#15 21.99 gpg:                using EDDSA key 0429897DE5F3BDAC537A30696D42BDD116E0068F
#15 21.99 gpg: BAD signature from "Christian Hesse (Arch Linux Package Signing) <arch@eworm.de>" [full]
#15 22.00 ==> ERROR: The signature identified by /tmp/repro-get-pacman-3422555567.tmp/acl-2.3.1-2-x86_64.pkg.tar.zst.sig could not be verified.
#15 22.01 time="2022-10-21T20:51:59Z" level=fatal msg="exit status 1"

I'm not sure why, adding pacman-key -l 0429897DE5F3BDAC537A30696D42BDD116E0068F to the Dockerfile shows that the key is present, yet pacman-key --verify is failing.

@kpcyrd kpcyrd force-pushed the archlinux-docker branch 4 times, most recently from 007aa9b to 00325ea Compare October 21, 2022 21:34
@kpcyrd
Copy link
Contributor Author

kpcyrd commented Oct 21, 2022

I fixed the signature error, pacman-key --verify is a very thin wrapper around gnupg and passing multiple signatures at once doesn't work, it would try to read the 2nd signature as the package for the 1st signature. I've fixed this now but the way the Dockerfile works it still uses repro-get 0.2.0 which doesn't contain my fix.

@kpcyrd kpcyrd changed the title Add half-working support for Arch Linux Dockerfiles Add support for Arch Linux Dockerfiles Oct 21, 2022
@kpcyrd kpcyrd force-pushed the archlinux-docker branch 2 times, most recently from 24d69c1 to cc301d1 Compare October 22, 2022 09:13
set -eux -o pipefail; \
export SOURCE_DATE_EPOCH="$(stat --format=%Y /etc/pacman.conf)" && \
mkdir -p /out && \
pacman -Sy && \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has to be executed with https://archive.archlinux.org/repos/yyyy/MM/dd that corresponds to the SOURCE_DATE_EPOCH .

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, but in practice I would most likely want to override this to get the latest security patches when updating my SHA256SUMS file. :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default mode should maximize reproducibility/non-determinism, but having an ARG option to get the latest updates sounds good as well

pacman-key --init && \
/usr/local/bin/repro-get --provider="${REPRO_GET_PROVIDER}" --cache=/dev/.cache/repro-get install "/mnt/SHA256SUMS-${TARGETARCH}${TARGETVARIANT:+-${TARGETVARIANT}}" && \
: Remove unneeded files for reproducibility && \
rm -rf /etc/pacman.d/gnupg && \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pacman-key is a thin wrapper around gnupg, and instead of "trust every key in our keyring package" it evaluates the pgp web-of-trust client side during an upgrade to ensure every packager key is trusted by multiple Arch Linux master keys (as a defense in depth mechanism, Debian and Alpine are more pragmatic in that regard).

To process this graph, gnupg needs to use lsign and to do that it needs access to a private key (that's what pacman-key --init does, among other things). This key should not remain in the final image tho, leaking the private key while the public key is also still trusted in the final image would be very bad, for that reason it's best to just nuke the whole folder that contains the pgp web-of-trust stuff after we're done with it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, could you add that explanation to the comment lines in Dockerfile.tmpl ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Signed-off-by: kpcyrd <git@rxv.cc>
Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@AkihiroSuda AkihiroSuda merged commit dd0b611 into reproducible-containers:master Oct 25, 2022
3 checks passed
@AkihiroSuda AkihiroSuda added the distro/arch Arch Linux label Oct 25, 2022
@kpcyrd kpcyrd deleted the archlinux-docker branch November 8, 2022 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
distro/arch Arch Linux
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants