From 50d2ba940471068d65e0894fee1f07a014d9c01e Mon Sep 17 00:00:00 2001 From: Keith Smith Date: Sat, 31 Oct 2026 08:49:37 -0600 Subject: [PATCH] Mark the app checkout as a safe.directory for root's git commands MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit install.sh chowns $APP_DIR to the service user, but its own (and upgrade.sh's) git fetch/checkout steps run as root per the previous fix — git refuses that combination by default ("detected dubious ownership"), which is exactly what happens re-running install.sh after an earlier run got far enough to chown the checkout. Add the directory to root's safe.directory list before touching it with git. Co-Authored-By: Claude Sonnet 5 --- scripts/install.sh | 7 +++++++ scripts/upgrade.sh | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/scripts/install.sh b/scripts/install.sh index fd48b03..17c6d0e 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -26,6 +26,13 @@ VENV_DIR="$EVECTION_HOME/venv" EVECTION_USER="${EVECTION_USER:-evection}" PYTHON_BIN="${PYTHON_BIN:-python3}" +# $APP_DIR ends up owned by $EVECTION_USER (see below), but the git steps +# in this script run as root — without this, git refuses to touch a repo +# it doesn't own ("detected dubious ownership"), which is exactly what +# happens re-running this script after a previous run got far enough to +# chown the checkout. +git config --global --add safe.directory "$APP_DIR" + echo "==> Installing Evection" echo " App directory: $APP_DIR" echo " Service user: $EVECTION_USER" diff --git a/scripts/upgrade.sh b/scripts/upgrade.sh index cf31dc7..020e7a9 100755 --- a/scripts/upgrade.sh +++ b/scripts/upgrade.sh @@ -28,6 +28,11 @@ VENV_DIR="$EVECTION_HOME/venv" EVECTION_USER="${EVECTION_USER:-evection}" SOCKET="/run/evection/gunicorn.sock" +# $APP_DIR is owned by $EVECTION_USER, but the git steps below run as +# root — without this, git refuses to touch a repo it doesn't own +# ("detected dubious ownership"). +git config --global --add safe.directory "$APP_DIR" + if ! id -u "$EVECTION_USER" >/dev/null 2>&1; then echo "System user '$EVECTION_USER' doesn't exist — is Evection installed?" \ "Run scripts/install.sh first." >&2