bots-garden/razorbillpublic Fork
⑂ cce9761
Commits
⬇ Clone ▾
git clone https://git.rickub.com/bots-garden/razorbill.git
git clone ssh://git@rickub.com/bots-garden/razorbill.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Download ZIP

install.sh: choose sudo from every path it touches, not only the prefix

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
k33g committed 2026-11-26T17:21:32+01:00 Browse files
cce9761 parent: fb46abf
modified .memory/history.md +5 -0
@@ -414,3 +414,8 @@ Products/Release/_NumericsShims.o); stopping kDrive did not help; deleting Inter
414414 (the failing files date from then) and left root-owned files. Fix proposed: `sudo chown -R
415415 $(whoami) .build`. install.sh and release.sh now refuse to run as root; troubleshooting row in the
416416 build how-to EN+FR. Earlier suspicion on kDrive and on sandbox reads of .build/xcode not confirmed.
417+Then: user reports install.sh "asks nothing and fails" (output not seen yet). Weakness found:
418+as_owner chose sudo only from `/usr/local` writability; a root-owned /usr/local/lib/razorbill
419+(earlier sudo install) would make the copy fail without sudo. install.sh now checks every target
420+path and ownership inside the installed folder (`writable_as_user`); tested on Linux incl. the
421+sudo branch (read-only bin/).
@@ -414,3 +414,8 @@ Products/Release/_NumericsShims.o); stopping kDrive did not help; deleting Inter
414 (the failing files date from then) and left root-owned files. Fix proposed: `sudo chown -R414 (the failing files date from then) and left root-owned files. Fix proposed: `sudo chown -R
415 $(whoami) .build`. install.sh and release.sh now refuse to run as root; troubleshooting row in the415 $(whoami) .build`. install.sh and release.sh now refuse to run as root; troubleshooting row in the
416 build how-to EN+FR. Earlier suspicion on kDrive and on sandbox reads of .build/xcode not confirmed.416 build how-to EN+FR. Earlier suspicion on kDrive and on sandbox reads of .build/xcode not confirmed.
417+Then: user reports install.sh "asks nothing and fails" (output not seen yet). Weakness found:
418+as_owner chose sudo only from `/usr/local` writability; a root-owned /usr/local/lib/razorbill
419+(earlier sudo install) would make the copy fail without sudo. install.sh now checks every target
420+path and ownership inside the installed folder (`writable_as_user`); tested on Linux incl. the
421+sudo branch (read-only bin/).
modified scripts/install.sh +14 -2
@@ -39,9 +39,21 @@ home="$prefix/lib/razorbill"
3939 launcher="$prefix/bin/rzb"
4040 marker="# razorbill launcher (scripts/install.sh)"
4141
42-# Runs a command with sudo only when the prefix cannot be written as the current user.
42+# True when the current user can create, replace and remove everything the install touches:
43+# each target (or its nearest existing parent) is writable, and nothing inside an installed
44+# razorbill folder belongs to someone else (e.g. root, after an install run with sudo).
45+writable_as_user() {
46+ local path
47+ for path in "$prefix/lib" "$prefix/bin" "$home" "$launcher"; do
48+ while [[ ! -e "$path" ]]; do path=$(dirname "$path"); done
49+ [[ -w "$path" ]] || return 1
50+ done
51+ [[ ! -d "$home" || -z "$(find "$home" ! -user "$(id -u)" -print -quit)" ]]
52+}
53+
54+# Runs a command with sudo only when the current user cannot do it (sudo asks for the password).
4355 as_owner() {
44- if mkdir -p "$prefix" 2>/dev/null && [[ -w "$prefix" ]]; then "$@"; else sudo "$@"; fi
56+ if writable_as_user; then "$@"; else sudo "$@"; fi
4557 }
4658
4759 # Refuses to overwrite or remove an rzb this script did not install.
@@ -39,9 +39,21 @@ home="$prefix/lib/razorbill"
39 launcher="$prefix/bin/rzb"39 launcher="$prefix/bin/rzb"
40 marker="# razorbill launcher (scripts/install.sh)"40 marker="# razorbill launcher (scripts/install.sh)"
41 41
42-# Runs a command with sudo only when the prefix cannot be written as the current user.42+# True when the current user can create, replace and remove everything the install touches:
43+# each target (or its nearest existing parent) is writable, and nothing inside an installed
44+# razorbill folder belongs to someone else (e.g. root, after an install run with sudo).
45+writable_as_user() {
46+ local path
47+ for path in "$prefix/lib" "$prefix/bin" "$home" "$launcher"; do
48+ while [[ ! -e "$path" ]]; do path=$(dirname "$path"); done
49+ [[ -w "$path" ]] || return 1
50+ done
51+ [[ ! -d "$home" || -z "$(find "$home" ! -user "$(id -u)" -print -quit)" ]]
52+}
53+
54+# Runs a command with sudo only when the current user cannot do it (sudo asks for the password).
43 as_owner() {55 as_owner() {
44- if mkdir -p "$prefix" 2>/dev/null && [[ -w "$prefix" ]]; then "$@"; else sudo "$@"; fi56+ if writable_as_user; then "$@"; else sudo "$@"; fi
45 }57 }
46 58
47 # Refuses to overwrite or remove an rzb this script did not install.59 # Refuses to overwrite or remove an rzb this script did not install.