From 439886624e0a9bc45de4437b6f0b6b7abe7915c6 Mon Sep 17 00:00:00 2001 From: Dmitrii Iurco Date: Mon, 11 May 2026 06:46:12 -0400 Subject: [PATCH] =?UTF-8?q?Fix=20config/data=20ownership=20=E2=80=94=20cho?= =?UTF-8?q?wn=20to=20invoking=20user=20after=20make=20install?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit make install runs as root so all generated files (config/, data/) land as root:root. Added a chown pass in install.sh after make install completes, re-applying REPO_OWNER ownership. Also fixed the make setup chown to use SUDO_USER when invoked via sudo rather than always id -u (which is 0 when running as root). Co-Authored-By: Claude Sonnet 4.6 --- Makefile | 2 +- install.sh | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 46fbcea..e345c76 100644 --- a/Makefile +++ b/Makefile @@ -79,7 +79,7 @@ check-deps: setup: check-deps @echo "Setting up Personal Internet Cell..." - @sudo chown -R $$(id -u):$$(id -g) config/ data/ 2>/dev/null || true + @sudo chown -R $${SUDO_USER:-$$(id -un)}:$${SUDO_USER:-$$(id -un)} config/ data/ 2>/dev/null || true CELL_NAME=$(or $(CELL_NAME),mycell) \ CELL_DOMAIN=$(or $(CELL_DOMAIN),cell) \ VPN_ADDRESS=$(or $(VPN_ADDRESS),10.0.0.1/24) \ diff --git a/install.sh b/install.sh index 9a59ff3..b0beed1 100755 --- a/install.sh +++ b/install.sh @@ -257,15 +257,16 @@ git config --system --add safe.directory "$PIC_DIR" 2>/dev/null || true # --------------------------------------------------------------------------- log_step 5 "Running 'make install'..." -# make install generates config, writes the systemd unit, and touches .installed. -# We run it as the pic user (via sudo -u) so files get correct ownership, but -# make install itself calls sudo internally where root is needed. cd "$PIC_DIR" if ! make install 2>&1 | sed 's/^/ /'; then die "'make install' failed. Check the output above." fi +# make install runs as root so config/ and data/ get created root-owned. +# Re-apply ownership to the invoking user so they can manage files without sudo. +chown -R "${REPO_OWNER}:${REPO_OWNER}" "$PIC_DIR" + log_ok "'make install' complete" # ---------------------------------------------------------------------------