diff options
| author | Pjotr <wrk@bosa.lan> | 2026-11-12 15:59:15 +0000 |
|---|---|---|
| committer | Pjotr <wrk@bosa.lan> | 2026-11-12 15:59:15 +0000 |
| commit | ea559e1a7d9bee12c89feddc58a98f36832d59ed (patch) | |
| tree | 69b185b076861c90f846e6f11cf5c2f0f8003f29 /test/run.sh | |
| parent | df684f4481dc4bc9c6331b11ede16b3d7d7a2ed8 (diff) | |
| download | run-guix-container-master.tar.gz | |
/var/log/guix-containers was a #define, and the daemon read no environment
variables at all, so a host whose /var/log is read-only -- or anyone running
the daemon outside a system-wide install -- had no way to keep container boot
output except to edit and rebuild the C. It is now a runtime value: the flag
wins, then $GUIX_CONTAINER_LOG_DIR, then the old default, and all three uses
(the mkdir, the .writable probe, the per-container <name>.log path) go through
it.
The chosen directory is named at startup ("container logs: DIR") before the
privilege check, for two reasons: it is the first thing an operator needs when
a container does not come up, and it makes the switch observable without root,
which is how test/run.sh now checks it -- --log-dir and the env var each have
to appear in that line, and an unknown option still has to print the usage.
README: documents the flag and the variable, says which wins, and points
ProtectSystem=strict users at --log-dir as the alternative to LogsDirectory=.
Also generalises one line that said "uid=1000(wrk)" -- true of the author's
box, misleading on anyone else's -- to "your own uid, e.g. uid=1000".
Diffstat (limited to 'test/run.sh')
| -rwxr-xr-x | test/run.sh | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/run.sh b/test/run.sh index 1316bae..915c728 100755 --- a/test/run.sh +++ b/test/run.sh @@ -16,5 +16,35 @@ if [ -n "$container" ]; then fi cc -O2 -Wall -o "$tmp/test" "$here/test.c" +cc -O2 -Wall -o "$tmp/daemon" "$here/../bin/run-guix-system-container.c" + +# The daemon's own switches: --log-dir must stay advertised (it is how a host +# with a read-only /var keeps container logs), and anything unknown must +# print the usage rather than start a half-configured daemon. +echo "daemon switches:" +if "$tmp/daemon" --help 2>&1 | grep -q -- "--log-dir"; then + echo " ok --log-dir advertised" +else + echo " FAIL --log-dir missing from --help"; exit 1 +fi +# ... and the chosen directory must actually reach the daemon: it names it at +# startup, which is observable without root. +if "$tmp/daemon" --log-dir /tmp/rgsc-test-logs --port 8994 2>&1 \ + | grep -q "container logs: /tmp/rgsc-test-logs"; then + echo " ok --log-dir reaches the daemon" +else + echo " FAIL --log-dir did not reach the daemon"; exit 1 +fi +if GUIX_CONTAINER_LOG_DIR=/tmp/rgsc-env-logs "$tmp/daemon" --port 8994 2>&1 \ + | grep -q "container logs: /tmp/rgsc-env-logs"; then + echo " ok GUIX_CONTAINER_LOG_DIR reaches the daemon" +else + echo " FAIL GUIX_CONTAINER_LOG_DIR did not reach the daemon"; exit 1 +fi +if "$tmp/daemon" --no-such-option >/dev/null 2>&1; then + echo " FAIL unknown option accepted"; exit 1 +else + echo " ok unknown option refused" +fi "$tmp/test" "$container" "$tmp" |
