glacier-ng 4.0.0

This commit is contained in:
lw-everestlinux committed 2026-10-29 09:15:34 -04:00
commit 0cf4829fa5
159 files changed
+33717

No files matched your search

+79
View File
@@ -0,0 +1,79 @@
# Root variant of Dockerfile.alpine, for exercising syspkg.
#
# syspkg refuses to run as root unless every directory up to / and every
# .lua/.so it loads is root-owned and not group/world-writable, so /app is
# root-owned, go-w, and the default user is root.
#
# The .so's checked into lib/glacier/ are host (glibc) builds and won't
# load on musl, so libglacier-ng is built from source in a first stage.
# Its source comes from a named build context:
#
# ./run_docker.sh Dockerfile.alpine_root
#
# (which passes --build-context libglacier=../libglacier-ng; override the
# path with LIBGLACIER_SRC).
FROM alpine:latest AS libglacier-build
# linux-headers: <linux/limits.h>, which Dockerfile.alpine is missing.
RUN apk add --no-cache build-base luajit-dev libarchive-dev libconfig-dev linux-headers
COPY --from=libglacier . /build
WORKDIR /build
RUN make clean && make
FROM alpine:latest
# curl: https repositories and build sources.
RUN apk update && apk add build-base curl git tar lua-dev luajit-dev libarchive-static libarchive-dev libconfig-dev linux-headers valgrind gdb doas
WORKDIR /app
COPY . .
COPY --from=libglacier-build /build/build/lib/shared/libglacier_*.so /app/lib/glacier/
COPY --from=libglacier-build /build/build/bin/gsandbox /app/lib/glacier/
RUN chown -R root:root /app && chmod -R go-w /app
RUN install -Dm644 /app/etc/glacier/glacier.conf /etc/glacier/glacier.conf
# A TEST signing key, so base packages can be installed here: syspkg
# requires their sidecar signed by a key listed for base in
# /etc/glacier/repos.conf (REPO_DESIGN.txt section 7). Its secret half is
# in the image, so never trust it anywhere else. Sign with
# `tests/mkpkg -k /root/glacier-test.sec ... base` (or gbuild -k; gbuild
# finds gsha256sum and gsign on PATH). grepo is there too.
COPY --from=libglacier-build /build/build/bin/gsign /build/build/bin/gsha256sum /build/build/bin/grepo /usr/local/bin/
RUN mkdir -p /etc/glacier/keys && \
gsign -G -p /etc/glacier/keys/glacier-test.pub -s /root/glacier-test.sec -c glacier-test >/dev/null && \
printf 'repos = (\n\t{ name = "base"; keys = [ "glacier-test" ]; }\n);\n' > /etc/glacier/repos.conf && \
chmod 644 /etc/glacier/repos.conf
# /glacier is deliberately not pre-created: `syspkg -n` builds the whole
# system tree, and `gstore -n` a user's /glacier/usr/<uid>, parents
# included.
# An unprivileged user to exercise per-user scope (`su glacier`). The
# wheel rule pins gstore's arguments to exactly `-n`, so a user can create
# their OWN /glacier/usr/<uid> but can't name anyone else's UID. glacier
# itself may run anything as root, for interactive use (`doas syspkg`);
# user_layout_alpine.sh drops that rule to test the pinned one.
RUN adduser -D -u 1000 glacier && addgroup glacier wheel && \
printf '%s\n' 'permit nopass glacier as root' \
'permit nopass :wheel as root cmd /app/gstore args -n' > /etc/doas.conf && \
chmod 0400 /etc/doas.conf
# /app (gpkg, syspkg, gstore, ...) on PATH: here for `docker exec` and
# `su`, and in profile.d because Alpine's /etc/profile resets PATH.
ENV PATH="$PATH:/app"
RUN printf '%s\n' \
'# Per-user links first, then system-scope (non-base) links. Not' \
'# conditional on the dirs existing: /glacier is only created later,' \
'# by syspkg -n / gstore -n, and a missing PATH entry is harmless.' \
'# /app (the glacier-ng tree) last.' \
'GLACIER_LINKS="/glacier/usr/$(id -u)/links"' \
'GLACIER_SYS_LINKS="/glacier/sys/links"' \
'export PATH="$GLACIER_LINKS/bin:$GLACIER_SYS_LINKS/bin:$PATH:/app"' \
'export LD_LIBRARY_PATH="$GLACIER_LINKS/lib:$GLACIER_SYS_LINKS/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"' \
> /etc/profile.d/glacier.sh
USER root
CMD ["/bin/sh", "-l"]