mirror of
https://github.com/unslothai/unsloth.git
synced 2026-08-25 08:42:25 +00:00
* Desktop: stop the loopback client following redirects `loopback_http::client` is the client that posts `.desktop_secret` to /api/auth/desktop-login, and it was built without a redirect policy. reqwest follows up to 10 redirects by default, and its cross-host protection strips headers rather than bodies, so a responder answering 307 (which preserves the method and the body) would carry the secret to whatever the Location header names, after the loopback URL had already been checked. Its sibling `streaming_client` already refuses redirects for exactly this reason: "Redirects are refused so a loopback URL cannot be bounced off-host after the check." Give `client` the same policy. No behaviour change for any real backend, which never redirects these routes. * Suppress macOS uv developer tools dialog * Update workspace guard for uv wrapper * Stop the installer raising the macOS command line developer tools dialog On a Mac without the Command Line Tools, /usr/bin/git, lipo, install_name_tool and friends are libxcselect shims. Executing one resolves no developer dir and posts to com.apple.dt.CommandLineTools.installondemand, which draws the 'requires the command line developer tools' dialog naming the tool. Resolving the path does not; only execution does. Two call sites execute a shim on the consumer path: _has_working_git ran 'git --version' to decide whether git works, so on a clean Mac the probe raised the dialog it exists to detect. It now answers from the resolved path when that path is exactly /usr/bin/git and no toolchain is selected. Deliberately narrow: a Homebrew, MacPorts or Xcode.app git earlier on PATH is a real binary and is still probed by executing it, so a Mac with a working git but no CLT selected behaves exactly as before. An earlier version of this gated on 'no CLT implies no working git' and broke that case, which the existing test caught. xcode-select -p only asks which toolchain is selected and never prompts. The venv arch probe called lipo first and fell back to file -L. lipo is a shim; 2>/dev/null hides its stderr but not a GUI dialog. file is base system and always answers, so the order is swapped. Both spellings feed the same case below, against 'Mach-O 64-bit executable arm64' or 'universal binary ... [x86_64] [arm64]' rather than lipo's 'arm64' / 'x86_64 arm64', so the branch taken is unchanged. clean-machine-assert.sh already made this same swap for its own use. The cctools binaries were missing from the clean machine CI tool list, so none of this was visible: trace mode generated no wrapper and the absent list never checked them. install_name_tool, lipo, otool, objdump, vtool, strip and nm are added, which is what makes these fixes regression testable. test_macos_clt_gate.sh gains two cases pinning the contract: with a shim git and no toolchain selected the probe answers no WITHOUT executing it, proven by a stub that records execution into a marker file, and with a real git elsewhere on PATH the stub IS executed. The first assertion passed vacuously when written (wrong temp path meant the marker could never be created) and was fixed by making its pair fail first. 18 to 23 passing. * Preserve working git on Intel macOS * Keep the git shim guard on under Rosetta --------- Co-authored-by: danielhanchen <unslothai@gmail.com> Co-authored-by: danielhanchen <danielhanchen@users.noreply.github.com> Co-authored-by: danielhanchen <danielhanchen@gmail.com>
94 lines
2.6 KiB
Bash
Executable file
94 lines
2.6 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved.
|
|
# Shared install_name_tool trace wrapper and CLT-absent sentinel contract.
|
|
set -euo pipefail
|
|
|
|
usage() {
|
|
echo "usage: $0 write {sentinel|passthrough} TARGET [REAL_TOOL]" >&2
|
|
echo " $0 verify-sentinel TRACE MARKER" >&2
|
|
|
|
echo " $0 decode TRACE_ARG" >&2
|
|
exit 2
|
|
}
|
|
|
|
|
|
decode_trace_arg() {
|
|
encoded=$1
|
|
case "$encoded" in h*) hex=${encoded#h} ;; *) return 1 ;; esac
|
|
case "$hex" in *[!0123456789abcdef]*) return 1 ;; esac
|
|
[ $(( ${#hex} % 2 )) -eq 0 ] || return 1
|
|
decoded=""
|
|
while [ -n "$hex" ]; do
|
|
rest=${hex#??}
|
|
pair=${hex%"$rest"}
|
|
hex=$rest
|
|
printf -v byte '%b' "\\x$pair"
|
|
decoded+=$byte
|
|
done
|
|
printf '%s' "$decoded"
|
|
}
|
|
|
|
case "${1:-}" in
|
|
write)
|
|
kind="${2:-}"
|
|
target="${3:-}"
|
|
[ -n "$target" ] || usage
|
|
case "$kind" in sentinel|passthrough) ;; *) usage ;; esac
|
|
|
|
cat > "$target" <<'WRAPPER'
|
|
#!/bin/sh
|
|
: "${UNSLOTH_TOOL_TRACE:?UNSLOTH_TOOL_TRACE is required}"
|
|
encode_trace_arg() {
|
|
printf '%s' "$1" | od -An -v -tx1 | tr -d ' \n'
|
|
}
|
|
printf 'install_name_tool\t%s' "$#" >> "$UNSLOTH_TOOL_TRACE"
|
|
for arg in "$@"; do printf '\th%s' "$(encode_trace_arg "$arg")" >> "$UNSLOTH_TOOL_TRACE"; done
|
|
printf '\n' >> "$UNSLOTH_TOOL_TRACE"
|
|
WRAPPER
|
|
if [ "$kind" = "sentinel" ]; then
|
|
printf '%s\n' 'exit 97' >> "$target"
|
|
else
|
|
real_tool="${4:-}"
|
|
[ -n "$real_tool" ] || usage
|
|
case "$real_tool" in *'"'*|*$'\n'*) echo "unsupported tool path: $real_tool" >&2; exit 2 ;; esac
|
|
printf 'exec "%s" "$@"\n' "$real_tool" >> "$target"
|
|
fi
|
|
chmod +x "$target"
|
|
;;
|
|
|
|
decode)
|
|
[ "$#" -eq 2 ] || usage
|
|
decode_trace_arg "$2"
|
|
;;
|
|
|
|
|
|
verify-sentinel)
|
|
trace="${2:-}"
|
|
marker="${3:-}"
|
|
[ -n "$trace" ] && [ -n "$marker" ] || usage
|
|
[ -n "${UNSLOTH_TOOL_TRACE:-}" ] && [ "$UNSLOTH_TOOL_TRACE" = "$trace" ] || {
|
|
echo "::error::install_name_tool sentinel trace environment is not active" >&2
|
|
exit 1
|
|
}
|
|
|
|
set +e
|
|
install_name_tool "--${marker}-sentinel-self-test" >/dev/null 2>&1
|
|
sentinel_rc=$?
|
|
set -e
|
|
[ "$sentinel_rc" -eq 97 ] || {
|
|
echo "::error::install_name_tool sentinel returned $sentinel_rc, expected 97" >&2
|
|
exit 1
|
|
}
|
|
marker_hex=$(printf '%s' "--${marker}-sentinel-self-test" | od -An -v -tx1 | tr -d ' \n')
|
|
expected=$(printf 'install_name_tool\t1\th%s' "$marker_hex")
|
|
grep -Fqx "$expected" "$trace" || {
|
|
echo "::error::install_name_tool sentinel did not preserve/record its self-test argv" >&2
|
|
cat "$trace" >&2 || true
|
|
exit 1
|
|
}
|
|
: > "$trace"
|
|
;;
|
|
|
|
*) usage ;;
|
|
esac
|