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

+80
View File
@@ -0,0 +1,80 @@
# Alpine test image, default user `glacier` (uid 1000, in wheel).
#
# Build/run with: ./run_docker.sh (Dockerfile.alpine is the default)
#
# Layout rules this image has to respect (see PACKAGE_SCOPES.txt §1):
# * /app is root-owned and not group/world-writable. gstore -n and
# syspkg run as root and refuse to load code from anything a user
# could edit — so the source tree can't be handed to `glacier`.
# * /glacier is NOT pre-created or chown'd. `doas /app/gstore -n`
# creates /glacier/usr/1000 (owned by glacier); `doas /app/syspkg -n`
# creates /glacier/sys. A user-owned /glacier/usr is refused.
# * The .so's checked into lib/glacier/ are host (glibc) builds and
# won't load on musl, so libglacier-ng is built from source here,
# from the named build context `libglacier` (run_docker.sh passes it).
FROM alpine:latest AS libglacier-build
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
RUN apk update && apk add build-base git lua-dev luajit-dev doas libarchive-static libarchive-dev libconfig-dev linux-headers valgrind gdb
RUN apk add --no-cache shadow
RUN adduser -D -u 1000 glacier && \
echo "glacier:password" | chpasswd && \
addgroup glacier wheel
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
RUN chmod 4755 /bin/su
RUN chmod 4755 /usr/bin/doas
RUN passwd -d root
# doas uses the LAST rule that matches.
# 1. glacier may run anything as root (this image's dev convenience,
# same as before) — needed for `doas /app/syspkg ...`.
# 2. The rule Everest itself would ship: any wheel user may run
# exactly `gstore -n` as root (no other arguments), so they can
# create their OWN /glacier/usr/<uid> but can't name another UID.
# With rule 1 present it adds nothing for glacier; delete rule 1 to
# test glacier under the real, restricted setup.
RUN printf '%s\n' \
'permit nopass glacier' \
'permit nopass :wheel as root cmd /app/gstore args -n' \
> /etc/doas.conf && chmod 0400 /etc/doas.conf
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.' \
'GLACIER_LINKS="/glacier/usr/$(id -u)/links"' \
'GLACIER_SYS_LINKS="/glacier/sys/links"' \
'export PATH="$GLACIER_LINKS/bin:$GLACIER_SYS_LINKS/bin:$PATH"' \
'export LD_LIBRARY_PATH="$GLACIER_LINKS/lib:$GLACIER_SYS_LINKS/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"' \
> /etc/profile.d/glacier.sh
USER glacier
CMD ["/bin/sh", "-l"]
+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"]
+67
View File
@@ -0,0 +1,67 @@
# Arch (glibc) test image, default user `glacier` (uid 1000, in wheel).
# Same layout rules as Dockerfile.alpine — read its header:
# * /app root-owned, not group/world-writable (gstore -n and syspkg run
# as root and refuse code a user could edit);
# * /glacier NOT pre-created (`doas /app/gstore -n`, `doas /app/syspkg -n`);
# * libglacier-ng built from source here, from the named build context
# `libglacier` that run_docker.sh passes.
#
# ./run_docker.sh Dockerfile.arch
FROM archlinux:latest AS base
RUN pacman-key --init && pacman-key --populate archlinux && \
pacman -Syu --noconfirm --needed archlinux-keyring && \
pacman -S --noconfirm --needed base-devel libarchive libconfig && \
pacman -Scc --noconfirm
FROM base AS libglacier-build
COPY --from=libglacier . /build
WORKDIR /build
RUN make clean && make
FROM base
RUN pacman -S --noconfirm --needed luajit opendoas git && pacman -Scc --noconfirm
RUN useradd -m -u 1000 -G wheel glacier && \
echo "glacier:password" | chpasswd
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
# doas uses the LAST matching rule. 1: this image's dev convenience
# (glacier may do anything as root). 2: the rule Everest itself ships —
# any wheel user may run exactly `gstore -n`, i.e. create their OWN
# /glacier/usr/<uid>. Delete rule 1 to test under the real setup.
RUN printf '%s\n' \
'permit nopass glacier' \
'permit nopass :wheel as root cmd /app/gstore args -n' \
> /etc/doas.conf && chmod 0400 /etc/doas.conf
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.' \
'GLACIER_LINKS="/glacier/usr/$(id -u)/links"' \
'GLACIER_SYS_LINKS="/glacier/sys/links"' \
'export PATH="$GLACIER_LINKS/bin:$GLACIER_SYS_LINKS/bin:$PATH"' \
'export LD_LIBRARY_PATH="$GLACIER_LINKS/lib:$GLACIER_SYS_LINKS/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"' \
> /etc/profile.d/glacier.sh
USER glacier
CMD ["/bin/sh", "-l"]
+69
View File
@@ -0,0 +1,69 @@
# Debian (glibc) test image, default user `glacier` (uid 1000, in wheel).
# Same layout rules as Dockerfile.alpine — read its header:
# * /app root-owned, not group/world-writable (gstore -n and syspkg run
# as root and refuse code a user could edit);
# * /glacier NOT pre-created (`doas /app/gstore -n`, `doas /app/syspkg -n`);
# * libglacier-ng built from source here, from the named build context
# `libglacier` that run_docker.sh passes.
#
# ./run_docker.sh Dockerfile.debian
FROM debian:stable AS base
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential libarchive-dev libconfig-dev \
&& rm -rf /var/lib/apt/lists/*
FROM base AS libglacier-build
COPY --from=libglacier . /build
WORKDIR /build
RUN make clean && make
FROM base
RUN apt-get update && apt-get install -y --no-install-recommends \
luajit doas git ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Debian has no wheel group; the doas rule below is written against it.
RUN groupadd -f wheel && useradd -m -u 1000 -G wheel glacier && \
echo "glacier:password" | chpasswd
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
# doas uses the LAST matching rule. 1: this image's dev convenience
# (glacier may do anything as root). 2: the rule Everest itself ships —
# any wheel user may run exactly `gstore -n`, i.e. create their OWN
# /glacier/usr/<uid>. Delete rule 1 to test under the real setup.
RUN printf '%s\n' \
'permit nopass glacier' \
'permit nopass :wheel as root cmd /app/gstore args -n' \
> /etc/doas.conf && chmod 0400 /etc/doas.conf
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.' \
'GLACIER_LINKS="/glacier/usr/$(id -u)/links"' \
'GLACIER_SYS_LINKS="/glacier/sys/links"' \
'export PATH="$GLACIER_LINKS/bin:$GLACIER_SYS_LINKS/bin:$PATH"' \
'export LD_LIBRARY_PATH="$GLACIER_LINKS/lib:$GLACIER_SYS_LINKS/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"' \
> /etc/profile.d/glacier.sh
USER glacier
CMD ["/bin/sh", "-l"]