Skip to content

hotfix(installer): normalise tree ownership before re-run update (urgent, unblocks fresh installs) - #1840

Merged
jaylfc merged 1 commit into
masterfrom
hotfix/installer-rerun-ownership
Jul 16, 2026
Merged

hotfix(installer): normalise tree ownership before re-run update (urgent, unblocks fresh installs)#1840
jaylfc merged 1 commit into
masterfrom
hotfix/installer-rerun-ownership

Conversation

@jaylfc

@jaylfc jaylfc commented Jul 16, 2026

Copy link
Copy Markdown
Owner

Urgent install-blocker. The installer is fetched from master, so this fix must land on master to help anyone installing now.

Cherry-pick of the dev fix (#1839) so only this one-file change reaches master, without pulling unreleased dev work into a release.

Problem

Reported on #2 (fresh Orange Pi 5 Plus). A re-run of install-server.sh over an existing checkout dies with unable to unlink old ...: Permission denied -> Could not reset index file to revision origin/master, bricking every subsequent attempt.

Root cause

The update path drops to the repo-owning user (taos) for the git reset --hard (a real privilege-escalation guard), but reads only the top-level dir owner. A prior interrupted install leaves the tree with mixed ownership, so the owning user cannot unlink the still-root-owned paths and the reset aborts.

Fix

chown -R the tree to the owning user (as root) immediately before the update, so the reset can rewrite the whole tree. git still runs unprivileged.

Validation

bash -n clean. Failure class reproduced locally (unwritable tree path -> identical unlink-EACCES; normalising the tree makes the reset apply cleanly). Identical change already on the dev PR #1839.

Summary by CodeRabbit

  • Bug Fixes
    • Improved installer recovery when a previous installation was interrupted or left files with mixed ownership.
    • Prevented update failures by ensuring the installation directory has the correct ownership before repository updates run.

A re-run of install-server.sh over an existing checkout drops to the
repo-owning user (the 'taos' service user) for the git fetch + reset, to
avoid running git as root inside a user-writable tree. But it only reads
the TOP-LEVEL dir owner. If a prior install was interrupted mid-chown (or
a root step wrote a few paths back), the tree has MIXED ownership: the
owning user then cannot unlink the still-root-owned paths, so the reset
fails with 'unable to unlink old ...: Permission denied' ->
'Could not reset index file to revision origin/master', bricking every
subsequent re-run.

Normalise ownership to the owning user (chown -R, run by root) right
before the update so the reset can rewrite the whole tree. Safe: root
does the chown and git still runs unprivileged.

Reported on #2 (fresh Orange Pi 5 Plus, retry after a partial first run).
Failure class reproduced locally: an unwritable path in the tree yields
the identical unlink-EACCES; normalising the tree makes the reset apply
cleanly.
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@github-actions

Copy link
Copy Markdown

👋 Thanks for the PR! This one targets master, which is our
stable branch (it's what live installs track). Please retarget it to
dev — click Edit next to the PR title and change the base
branch dropdown from master to dev. Your commits and any review
carry over, nothing is lost.

See CONTRIBUTING.md for the branch model.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 2a611c54-8a1b-46eb-86cb-97650791c5b1

📥 Commits

Reviewing files that changed from the base of the PR and between 7e0fee6 and ac90d38.

📒 Files selected for processing (1)
  • scripts/install-server.sh

📝 Walkthrough

Walkthrough

The installer now recursively assigns existing checkout contents to the detected non-root repository owner before running git fetch and git reset during root-initiated updates.

Changes

Installer checkout update

Layer / File(s) Summary
Normalize existing checkout ownership
scripts/install-server.sh
Root runs now recursively chown the entire INSTALL_DIR to the non-root repository owner before Git update commands execute as that user.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

  • jaylfc/taOS#754: Updates ownership and permission handling in the same installer.
  • jaylfc/taOS#768: Updates existing-checkout ownership handling in the same installer path.

Suggested reviewers: hognek

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the installer ownership normalization fix that prevents rerun update failures.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch hotfix/installer-rerun-ownership

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gitar-bot

gitar-bot Bot commented Jul 16, 2026

Copy link
Copy Markdown

Important

You are using the Gitar free plan. Upgrade to unlock code review, CI analysis, auto-apply, custom automations, and more.

Gitar

Comment thread scripts/install-server.sh
# "Could not reset index file"), bricking every re-run. Normalise
# ownership to the owning user first so the reset can rewrite the whole
# tree. Safe: root performs the chown and git still runs unprivileged.
chown -R "$_repo_owner" "$INSTALL_DIR"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Unguarded chown -R aborts the whole install under set -euo pipefail

This script sets set -euo pipefail (line 35), and this chown line has no || fallback. If chown fails for any reason (e.g. _repo_owner resolves to an unusable name, a path chown can't traverse, disk/permission hiccup), the non-zero exit aborts the entire installer — a worse, harder-to-recover failure than the reset failure this PR is meant to fix. The subsequent sudo -u "$_repo_owner" git ... chain is also unguarded, but the reset there is a deliberate intentional failure path; a mid-flight chown abort is not.

Consider guarding it so a chown failure degrades to the previous behaviour instead of bricking the run, e.g.:

Suggested change
chown -R "$_repo_owner" "$INSTALL_DIR"
chown -R "$_repo_owner" "$INSTALL_DIR" || warn "could not normalise tree ownership -- update may fail if ownership is mixed"

(or || true if you'd rather always attempt the update). This mirrors the || warn ...; continue pattern already used elsewhere in the file for best-effort steps.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

@kilo-code-bot

kilo-code-bot Bot commented Jul 16, 2026

Copy link
Copy Markdown

Code Review Summary

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
scripts/install-server.sh 1173 Unguarded chown -R aborts the whole installer under set -euo pipefail (a failed chown now bricks the run worse than the reset failure it replaces)
Files Reviewed (1 files)
  • scripts/install-server.sh - 1 issue

Fix these issues in Kilo Cloud


Reviewed by hy3:free · Input: 34.3K · Output: 2.3K · Cached: 101.5K

@jaylfc
jaylfc merged commit 4825654 into master Jul 16, 2026
12 checks passed
@jaylfc
jaylfc deleted the hotfix/installer-rerun-ownership branch July 16, 2026 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant