-
-
Notifications
You must be signed in to change notification settings - Fork 36
fix(install): re-run update path trips git dubious-ownership after the taos chown #768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -980,7 +980,20 @@ if [[ ! -d "$INSTALL_DIR/.git" ]]; then | |
| git clone --depth 1 --branch "$BRANCH" "$REPO" "$INSTALL_DIR" | ||
| else | ||
| log "updating existing checkout" | ||
| (cd "$INSTALL_DIR" && git fetch --depth 1 origin "$BRANCH" && git reset --hard "origin/$BRANCH") | ||
| # The repo is chowned to the 'taos' service user at the end of a system | ||
| # install, so a re-run (as root) trips git's dubious-ownership check. | ||
| # That check is guarding a real privilege-escalation path: running git as | ||
| # root inside a tree the unprivileged 'taos' user can write to would let a | ||
| # 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 "")" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SUGGESTION: Explicitly handle symlinks with The |
||
| if [[ "$(id -u)" == "0" && -n "$_repo_owner" && "$_repo_owner" != "root" ]]; then | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WARNING: No validation that the owning user exists before If |
||
| sudo -u "$_repo_owner" git -C "$INSTALL_DIR" fetch --depth 1 origin "$BRANCH" \ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SUGGESTION: Capture and surface sudo/git errors more clearly If |
||
| && sudo -u "$_repo_owner" git -C "$INSTALL_DIR" reset --hard "origin/$BRANCH" | ||
| else | ||
| (cd "$INSTALL_DIR" && git fetch --depth 1 origin "$BRANCH" && git reset --hard "origin/$BRANCH") | ||
| fi | ||
| fi | ||
|
|
||
| cd "$INSTALL_DIR" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WARNING:
_repo_ownervariable leaks to global scopeThe variable
_repo_owneris assigned at the top level withoutlocaldeclaration. 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 withlocal.