From c005e011564de33a0c13fbe51f8e40e7c75aea96 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 8 Jun 2026 00:42:13 +0000 Subject: [PATCH] filebrowser.sh: fix DOCKER_DIR pointing to /root when run with sudo DOCKER_DIR was computed before ACTUAL_HOME, so $HOME resolved to /root (the root user's home) instead of the invoking user's home. Files were created under /root/docker/ rather than ~/docker/. Fix: compute ACTUAL_USER and ACTUAL_HOME first, then DOCKER_DIR. https://claude.ai/code/session_01UZus2Q9gNTfUdqSMrhuX29 --- services/filebrowser.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/services/filebrowser.sh b/services/filebrowser.sh index bbb2ad0..c8725ac 100644 --- a/services/filebrowser.sh +++ b/services/filebrowser.sh @@ -75,10 +75,11 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then } fi - # Globals — use existing site config values if present, otherwise sensible defaults - DOCKER_DIR="${DOCKER_DIR:-$HOME/docker}" + # Globals — ACTUAL_USER/ACTUAL_HOME must come before DOCKER_DIR + # ($HOME under sudo is /root, not the real user's home) ACTUAL_USER="${ACTUAL_USER:-${SUDO_USER:-$USER}}" - ACTUAL_HOME="$(getent passwd "$ACTUAL_USER" 2>/dev/null | cut -d: -f6 || echo "$HOME")" + ACTUAL_HOME="$(getent passwd "$ACTUAL_USER" 2>/dev/null | cut -d: -f6 || echo "${HOME:-/root}")" + DOCKER_DIR="${DOCKER_DIR:-$ACTUAL_HOME/docker}" DRY_RUN="${DRY_RUN:-false}" UNATTENDED="${UNATTENDED:-false}" SITE_TZ="${SITE_TZ:-$(cat /etc/timezone 2>/dev/null || echo UTC)}"