Watch
0
0
Fork
You've already forked hyperhive
0

let the init container's temp file take its umask

fetch-secrets ran under umask 0227 for the files it writes, which made the
mktemp file of grafana_secret_key mode 0400: the redirect of bao's stderr
into it failed, every bao call in the helper answered 1, and the init
container exited 1 before it stored or read the key. The umask now covers
only the writes of put(), the helper chmods its own file, the script test runs
under that umask, and a pod that does not start prints its init containers'
logs.
This commit is contained in:
atlas 2026-11-28 01:10:08 +01:00
commit f8fb71253e
2 changed files with 19 additions and 3 deletions

View file

@ -31,6 +31,8 @@
shift 3
GRAFANA_KEY=""
err="$(mktemp)"
# A caller's umask can leave the file unwritable to its owner.
chmod u+rw "$err"
if ! GRAFANA_KEY="$(bao kv get -field=value "$leaf" 2>"$err")" || [ -z "$GRAFANA_KEY" ]; then
readerr="$(cat "$err")"

View file

@ -479,13 +479,15 @@ let
fetch = pkgs.writeShellScriptBin "swarm-grafana-fetch" ''
export PATH=${lib.makeBinPath tools}
set -euo pipefail
umask 0227
${login}
${grafanaSecretKey}
d=${lib.escapeShellArg secretDir}
put() {
printf '%s' "$2" > "$d/$1.new"
# Group-readable (0440): the pod's group is how Grafana reads what the init
# container, running as another uid, wrote. Only the writes take the umask:
# a temporary file made under it could not be written to again.
( umask 0227; printf '%s' "$2" > "$d/$1.new" )
mv -f "$d/$1.new" "$d/$1"
}
stored() {