Harden Docker ownership startup

This commit is contained in:
Codex
2026-08-10 11:15:22 +02:00
parent a41011ae17
commit db8b9f3560
5 changed files with 22 additions and 10 deletions
+11 -8
View File
@@ -1,13 +1,6 @@
#!/bin/sh
set -eu
is_true() {
case "$(printf '%s' "${1:-}" | tr '[:upper:]' '[:lower:]')" in
1 | true | yes | on) return 0 ;;
*) return 1 ;;
esac
}
is_integer() {
case "${1:-}" in
'' | *[!0-9]*) return 1 ;;
@@ -15,6 +8,14 @@ is_integer() {
esac
}
chown_path() {
owner="$1"
path="$2"
if ! chown "$owner" "$path"; then
echo "Warning: could not change ownership of $path to $owner; continuing." >&2
fi
}
run_as_requested_user() {
uid="${USER_UID:-}"
gid="${USER_GID:-}"
@@ -34,7 +35,9 @@ run_as_requested_user() {
fi
mkdir -p /app/.kaizoku/home
chown "$uid:$gid" /downloads /jellyfin/tv /jellyfin/movies /app/.kaizoku /app/.kaizoku/home
for path in /downloads /jellyfin/tv /jellyfin/movies /app/.kaizoku /app/.kaizoku/home; do
chown_path "$uid:$gid" "$path"
done
cd /app
exec setpriv \