Skip to content

fix(install): re-run update path trips git dubious-ownership after the taos chown - #768

Merged
jaylfc merged 2 commits into
devfrom
fix/installer-update-dubious-ownership
Jun 11, 2026
Merged

fix(install): re-run update path trips git dubious-ownership after the taos chown#768
jaylfc merged 2 commits into
devfrom
fix/installer-update-dubious-ownership

Conversation

@jaylfc

@jaylfc jaylfc commented Jun 11, 2026

Copy link
Copy Markdown
Owner

Re-running the installer on an existing install fails at 'updating existing checkout' with git's dubious-ownership error: the repo is chowned to the taos service user at the end of every install, and the next run executes git fetch/reset as root inside it. Reported in #765, and it blocks exactly the re-run-with-sudo recovery path we point users at.

Fix scopes a safe.directory exception to the two update commands (no global git config changes). The post-install chown re-fixes ownership of anything the update creates.

Fixes #765.

Summary by CodeRabbit

  • Bug Fixes
    • Improved installer reliability when re-running against an existing repository: update steps now run with the repository's owning user when appropriate, preventing Git "dubious ownership" failures and avoiding unintended privileged updates. This reduces installation errors on subsequent runs and makes re-installation safer for non-root-owned install trees.

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 2fab9795-c78a-405e-bdac-60e38c908a51

📥 Commits

Reviewing files that changed from the base of the PR and between 110b651 and e0b166d.

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

📝 Walkthrough

Walkthrough

The installer update step now detects the owner of $INSTALL_DIR and, when run as root against a non-root-owned checkout, performs git fetch and git reset --hard as that owning user; otherwise it uses the original subshell update path.

Changes

Owner-aware repo update

Layer / File(s) Summary
Run git update as repo owner
scripts/install-server.sh
Lines ~983–996 replace the unconditional (cd "$INSTALL_DIR" && git fetch && git reset --hard) with logic that computes _repo_owner via stat and runs git -C "$INSTALL_DIR" fetch and git -C "$INSTALL_DIR" reset --hard under sudo -u "$_repo_owner" when the script is running as root and the tree is not root-owned; otherwise it falls back to the subshell approach.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • jaylfc/taOS#677: Also modifies scripts/install-server.sh to address ownership and install-time ownership handling for repository checkouts.

Poem

🐰 I sniffed the git tree at dawn,
Owner found where files were born.
If root runs the installer song,
I sudo to the rightful throng.
Fetch and reset—no more alarm!

🚥 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 specifically addresses the fix for the Git dubious-ownership error that occurs when re-running the installer, which is the main change in the PR.
Linked Issues check ✅ Passed The PR successfully addresses issue #765 by fixing the dubious-ownership error using per-command git safe.directory exceptions instead of global configuration.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the dubious-ownership error reported in issue #765; no unrelated modifications are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 fix/installer-update-dubious-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 and usage tips.

… overriding git ownership trust

Running git as root inside a taos-owned tree (so a planted .git/config or
hook could execute as root) is the privilege-escalation the dubious-ownership
check guards against. Drop to the owning user for fetch/reset rather than
bypassing the check; run directly when root-owned or not running as root.
@jaylfc

jaylfc commented Jun 11, 2026

Copy link
Copy Markdown
Owner Author

Updated per a security review of the first commit: the original approach overrode git's safe.directory check, which would have left root running git inside a taos-writable tree (a planted .git/config or hook could execute as root). The dubious-ownership check exists to prevent exactly that. The update now drops to the repo's owning user (sudo -u) for fetch/reset, and only runs git directly when the tree is root-owned or the installer is not running as root (user-mode / macOS).

Comment thread scripts/install-server.sh
# planted .git/config or hook execute as root. So drop to the owning user
# for the update instead of overriding the check. When the tree is already
# root-owned, or we are not root (user-mode / macOS install), run directly.
_repo_owner="$(stat -c '%U' "$INSTALL_DIR" 2>/dev/null || stat -f '%Su' "$INSTALL_DIR" 2>/dev/null || echo "")"

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: _repo_owner variable leaks to global scope

The variable _repo_owner is assigned at the top level without local declaration. While this script doesn't use functions for this section, global namespace pollution can cause subtle bugs if this variable name is used elsewhere. Consider using a more unique name (e.g., _taos_repo_owner) or wrapping this logic in a function with local.

Comment thread scripts/install-server.sh
# for the update instead of overriding the check. When the tree is already
# root-owned, or we are not root (user-mode / macOS install), run directly.
_repo_owner="$(stat -c '%U' "$INSTALL_DIR" 2>/dev/null || stat -f '%Su' "$INSTALL_DIR" 2>/dev/null || echo "")"
if [[ "$(id -u)" == "0" && -n "$_repo_owner" && "$_repo_owner" != "root" ]]; then

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: No validation that the owning user exists before sudo -u

If $INSTALL_DIR was manually chowned to a non-existent user (or a user that was deleted), the stat call succeeds but sudo -u "$_repo_owner" will fail with a confusing error like "sudo: unknown user: ...". The script will exit due to set -e, but the error message won't clearly indicate the root cause. Consider adding a check: id -u "$_repo_owner" >/dev/null 2>&1 before attempting the sudo.

Comment thread scripts/install-server.sh
# planted .git/config or hook execute as root. So drop to the owning user
# for the update instead of overriding the check. When the tree is already
# root-owned, or we are not root (user-mode / macOS install), run directly.
_repo_owner="$(stat -c '%U' "$INSTALL_DIR" 2>/dev/null || stat -f '%Su' "$INSTALL_DIR" 2>/dev/null || echo "")"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: Explicitly handle symlinks with stat -L

The stat command follows symlinks by default, but being explicit with -L (GNU) or relying on default behavior makes the intent clearer. Since $INSTALL_DIR could theoretically be a symlink (though unlikely in this script's flow), consider: stat -L -c '%U' ... for GNU stat. Note: BSD stat doesn't support -L flag the same way, so the current fallback chain handles it.

Comment thread scripts/install-server.sh
# root-owned, or we are not root (user-mode / macOS install), run directly.
_repo_owner="$(stat -c '%U' "$INSTALL_DIR" 2>/dev/null || stat -f '%Su' "$INSTALL_DIR" 2>/dev/null || echo "")"
if [[ "$(id -u)" == "0" && -n "$_repo_owner" && "$_repo_owner" != "root" ]]; then
sudo -u "$_repo_owner" git -C "$INSTALL_DIR" fetch --depth 1 origin "$BRANCH" \

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: Capture and surface sudo/git errors more clearly

If sudo -u fails (e.g., user doesn't exist, sudo not configured for passwordless), the script exits via set -e but the error message comes from sudo/git directly. Wrapping in a function or adding explicit error handling would improve debuggability. Example: sudo -u "$_repo_owner" git -C "$INSTALL_DIR" fetch ... || die "git fetch as $_repo_owner failed"

@kilo-code-bot

kilo-code-bot Bot commented Jun 11, 2026

Copy link
Copy Markdown

Code Review Summary

Status: 4 Issues Found | Recommendation: Address before merge

Overview

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

WARNING

File Line Issue
scripts/install-server.sh 990 _repo_owner variable leaks to global scope
scripts/install-server.sh 991 No validation that the owning user exists before sudo -u

SUGGESTION

File Line Issue
scripts/install-server.sh 990 Explicitly handle symlinks with stat -L
scripts/install-server.sh 992 Capture and surface sudo/git errors more clearly
Files Reviewed (1 file)
  • scripts/install-server.sh - 4 issues

Fix these issues in Kilo Cloud


Reviewed by nemotron-3-ultra-550b-a55b-20260604:free · 388,125 tokens

@jaylfc

jaylfc commented Jun 11, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@jaylfc
jaylfc merged commit 3dcdb19 into dev Jun 11, 2026
7 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in TinyAgentOS Roadmap Jun 11, 2026
@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown
✅ Action performed

Full review finished.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

1 participant