@calltelemetry/fmix 2.7.27 → 2.7.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/fmix +123 -64
- package/package.json +3 -3
package/bin/fmix
CHANGED
|
@@ -28,7 +28,7 @@ set -uo pipefail
|
|
|
28
28
|
# ---------------------------------------------------------------------------
|
|
29
29
|
# Constants & config
|
|
30
30
|
# ---------------------------------------------------------------------------
|
|
31
|
-
FMIX_VERSION="2.7.
|
|
31
|
+
FMIX_VERSION="2.7.28"
|
|
32
32
|
FMIX_HOME="${FMIX_HOME:-${HOME}/.ct-fmix}"
|
|
33
33
|
FMIX_OS="$(uname -s)"
|
|
34
34
|
FMIX_ARCH="$(uname -m)"
|
|
@@ -557,6 +557,126 @@ fmix_readonly_entrypoint() {
|
|
|
557
557
|
return 1
|
|
558
558
|
}
|
|
559
559
|
|
|
560
|
+
fmix_artifact_v2_managed_entrypoint() {
|
|
561
|
+
# Optional arguments judge another launcher: entrypoint, runner, FMIX_HOME.
|
|
562
|
+
local py_bin entrypoint="${1:-$0}" runner="${2:-}" managed_home="${3:-$FMIX_HOME}"
|
|
563
|
+
if [[ "${FMIX_SELF_TEST_MANAGED_REEXEC:-0}" == "1" \
|
|
564
|
+
&& " ${FUNCNAME[*]} " == *" cmd_self_test "* \
|
|
565
|
+
&& -n "${FMIX_SELF_TEST_RUNNER_HOME:-}" ]]; then
|
|
566
|
+
managed_home="$FMIX_SELF_TEST_RUNNER_HOME"
|
|
567
|
+
fi
|
|
568
|
+
py_bin="$(fmix_python_bin)" || return 1
|
|
569
|
+
if [[ -z "$runner" ]]; then
|
|
570
|
+
runner="$(fmix_realpath "${BASH_SOURCE[0]}")" || return 1
|
|
571
|
+
fi
|
|
572
|
+
"$py_bin" -I -B - "$HOME" "$managed_home" "$entrypoint" "$runner" <<'PY'
|
|
573
|
+
import hashlib,os,stat,sys
|
|
574
|
+
user_home,fmix_home,entrypoint,runner=sys.argv[1:]
|
|
575
|
+
uid=os.getuid(); euid=os.geteuid(); user_home=os.path.abspath(user_home); fmix_home=os.path.abspath(fmix_home)
|
|
576
|
+
def reject(reason):
|
|
577
|
+
print(reason,file=sys.stderr)
|
|
578
|
+
raise SystemExit(1)
|
|
579
|
+
if uid==0 or euid!=uid: reject("privileged_cleaner_forbidden")
|
|
580
|
+
entrypoint=os.path.abspath(entrypoint)
|
|
581
|
+
if os.path.realpath(user_home)!=user_home or os.path.realpath(fmix_home)!=fmix_home:
|
|
582
|
+
reject("noncanonical_managed_home")
|
|
583
|
+
known={user_home+"/.local/bin/fmix",user_home+"/.local/share/fmix/bin/fmix"}
|
|
584
|
+
custom=os.environ.get("FMIX_INSTALL_DIR")
|
|
585
|
+
if custom:
|
|
586
|
+
custom=os.path.abspath(custom)
|
|
587
|
+
if os.path.commonpath((user_home,custom))!=user_home: raise SystemExit(1)
|
|
588
|
+
known.add(os.path.join(custom,"fmix"))
|
|
589
|
+
if entrypoint not in known and entrypoint!=runner: reject("unrecognized_managed_entrypoint")
|
|
590
|
+
paths=[]
|
|
591
|
+
for path in sorted(known):
|
|
592
|
+
if not os.path.lexists(path): continue
|
|
593
|
+
parent=os.path.dirname(path)
|
|
594
|
+
if os.path.commonpath((user_home,parent))!=user_home: raise SystemExit(1)
|
|
595
|
+
rel=os.path.relpath(parent,user_home); current=user_home
|
|
596
|
+
for part in (() if rel=="." else rel.split(os.sep)):
|
|
597
|
+
current=os.path.join(current,part); s=os.lstat(current)
|
|
598
|
+
if not stat.S_ISDIR(s.st_mode) or stat.S_ISLNK(s.st_mode) or s.st_uid!=uid or s.st_mode&0o022:
|
|
599
|
+
reject("unsafe_launcher_parent")
|
|
600
|
+
link=os.lstat(path)
|
|
601
|
+
if not stat.S_ISLNK(link.st_mode) or link.st_uid!=uid or link.st_nlink!=1 or os.path.realpath(path)!=runner:
|
|
602
|
+
reject("managed_launcher_mismatch")
|
|
603
|
+
paths.append(path)
|
|
604
|
+
if entrypoint not in paths and (entrypoint!=runner or not paths):
|
|
605
|
+
reject("managed_launcher_missing")
|
|
606
|
+
fd=os.open(runner,os.O_RDONLY|getattr(os,"O_NOFOLLOW",0))
|
|
607
|
+
try:
|
|
608
|
+
s=os.fstat(fd)
|
|
609
|
+
if not stat.S_ISREG(s.st_mode) or s.st_uid!=uid or s.st_nlink!=1 or s.st_mode&0o222 or not s.st_mode&0o111 or s.st_size>4*1024*1024:
|
|
610
|
+
reject("unsafe_runner_identity")
|
|
611
|
+
parent=os.open(fmix_home+"/runtime",os.O_RDONLY|os.O_DIRECTORY|getattr(os,"O_NOFOLLOW",0))
|
|
612
|
+
try:
|
|
613
|
+
runtime=os.fstat(parent)
|
|
614
|
+
if runtime.st_uid!=uid or runtime.st_dev!=s.st_dev or runtime.st_mode&0o022:
|
|
615
|
+
reject("unsafe_runner_runtime")
|
|
616
|
+
finally: os.close(parent)
|
|
617
|
+
h=hashlib.sha256()
|
|
618
|
+
for block in iter(lambda: os.read(fd,65536),b""): h.update(block)
|
|
619
|
+
if runner!=fmix_home+"/runtime/fmix-"+h.hexdigest():
|
|
620
|
+
reject("managed_launcher_runner_mismatch")
|
|
621
|
+
finally: os.close(fd)
|
|
622
|
+
PY
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
# REL-5471: a package-manager copy of this runner (an npm Node prefix, which is
|
|
626
|
+
# what installers maintain and shells resolve) is never a publisher, because the
|
|
627
|
+
# predicate above accepts only the managed launcher. When a managed launcher
|
|
628
|
+
# holds byte-identical runner bytes and passes that same predicate, run through
|
|
629
|
+
# it. This grants the copy nothing: the process that continues is the managed
|
|
630
|
+
# one, and every publication still runs the predicate. A copy with any other
|
|
631
|
+
# bytes stays where it is and stays refused.
|
|
632
|
+
fmix_managed_reexec_target() {
|
|
633
|
+
local self="" runtime_home="" candidate target
|
|
634
|
+
[[ -n "${HOME:-}" ]] || return 1
|
|
635
|
+
for candidate in ${FMIX_INSTALL_DIR:+"$FMIX_INSTALL_DIR/fmix"} \
|
|
636
|
+
"$HOME/.local/bin/fmix" "$HOME/.local/share/fmix/bin/fmix"; do
|
|
637
|
+
[[ -L "$candidate" ]] || continue
|
|
638
|
+
if [[ -z "$self" ]]; then
|
|
639
|
+
self="$(fmix_realpath "${BASH_SOURCE[0]}" 2>/dev/null)" || return 1
|
|
640
|
+
runtime_home="$(fmix_realpath "$FMIX_HOME" 2>/dev/null)" || return 1
|
|
641
|
+
# Already running a runtime snapshot: nothing to hand over.
|
|
642
|
+
[[ "$self" != "$runtime_home"/runtime/fmix-* ]] || return 1
|
|
643
|
+
# fmix_private_env_file still reads a legacy .env beside the invoked
|
|
644
|
+
# script. Handing over would silently drop it.
|
|
645
|
+
[[ -n "${FMIX_ENV_FILE:-}" || -f "$FMIX_CONFIG_HOME/fmix.env" || ! -f "${self%/*}/.env" ]] \
|
|
646
|
+
|| return 1
|
|
647
|
+
fi
|
|
648
|
+
target="$(fmix_realpath "$candidate" 2>/dev/null)" || continue
|
|
649
|
+
[[ "$target" == "$runtime_home"/runtime/fmix-* ]] || continue
|
|
650
|
+
cmp -s "$self" "$target" || continue
|
|
651
|
+
fmix_artifact_v2_managed_entrypoint "$candidate" "$target" "$runtime_home" \
|
|
652
|
+
>/dev/null 2>&1 || continue
|
|
653
|
+
# The snapshot, not the link: a concurrent install may repoint the link,
|
|
654
|
+
# and only the bytes compared above may run.
|
|
655
|
+
printf '%s\n' "$target"
|
|
656
|
+
return 0
|
|
657
|
+
done
|
|
658
|
+
return 1
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
fmix_reexec_through_managed_launcher() {
|
|
662
|
+
# Identity probes, install and self-test describe the invoked copy. hook and
|
|
663
|
+
# runner publish nothing and read files next to the invoked script.
|
|
664
|
+
case "${1:-}" in
|
|
665
|
+
""|help|--help|-h|version|--version|install|self-test|hook|runner|--fmix-observability-worker) return 0 ;;
|
|
666
|
+
esac
|
|
667
|
+
[[ "${FMIX_OBSERVABILITY_WORKER:-0}" != "1" ]] || return 0
|
|
668
|
+
local launcher
|
|
669
|
+
launcher="$(fmix_managed_reexec_target)" || return 0
|
|
670
|
+
# A package copy never auto-upgraded. Keep it so: a detached upgrade would
|
|
671
|
+
# repoint the launcher away from the bytes the package manager installed.
|
|
672
|
+
export FMIX_NO_AUTO_UPGRADE="${FMIX_NO_AUTO_UPGRADE:-1}"
|
|
673
|
+
exec "$launcher" "$@"
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
|
|
677
|
+
fmix_reexec_through_managed_launcher "$@"
|
|
678
|
+
fi
|
|
679
|
+
|
|
560
680
|
if ! fmix_readonly_entrypoint "$@" && [[ "${BASH_SOURCE[0]}" == "$0" \
|
|
561
681
|
&& "${FMIX_OBSERVABILITY_WORKER:-0}" != "1" \
|
|
562
682
|
&& "${1:-}" != "--fmix-observability-worker" \
|
|
@@ -3897,67 +4017,6 @@ fmix_dependency_lane_fingerprint() {
|
|
|
3897
4017
|
return "$rc"
|
|
3898
4018
|
}
|
|
3899
4019
|
|
|
3900
|
-
fmix_artifact_v2_managed_entrypoint() {
|
|
3901
|
-
local py_bin runner managed_home="$FMIX_HOME"
|
|
3902
|
-
if [[ "${FMIX_SELF_TEST_MANAGED_REEXEC:-0}" == "1" \
|
|
3903
|
-
&& " ${FUNCNAME[*]} " == *" cmd_self_test "* \
|
|
3904
|
-
&& -n "${FMIX_SELF_TEST_RUNNER_HOME:-}" ]]; then
|
|
3905
|
-
managed_home="$FMIX_SELF_TEST_RUNNER_HOME"
|
|
3906
|
-
fi
|
|
3907
|
-
py_bin="$(fmix_python_bin)" || return 1
|
|
3908
|
-
runner="$(fmix_realpath "${BASH_SOURCE[0]}")" || return 1
|
|
3909
|
-
"$py_bin" -I -B - "$HOME" "$managed_home" "$0" "$runner" <<'PY'
|
|
3910
|
-
import hashlib,os,stat,sys
|
|
3911
|
-
user_home,fmix_home,entrypoint,runner=sys.argv[1:]
|
|
3912
|
-
uid=os.getuid(); euid=os.geteuid(); user_home=os.path.abspath(user_home); fmix_home=os.path.abspath(fmix_home)
|
|
3913
|
-
def reject(reason):
|
|
3914
|
-
print(reason,file=sys.stderr)
|
|
3915
|
-
raise SystemExit(1)
|
|
3916
|
-
if uid==0 or euid!=uid: reject("privileged_cleaner_forbidden")
|
|
3917
|
-
entrypoint=os.path.abspath(entrypoint)
|
|
3918
|
-
if os.path.realpath(user_home)!=user_home or os.path.realpath(fmix_home)!=fmix_home:
|
|
3919
|
-
reject("noncanonical_managed_home")
|
|
3920
|
-
known={user_home+"/.local/bin/fmix",user_home+"/.local/share/fmix/bin/fmix"}
|
|
3921
|
-
custom=os.environ.get("FMIX_INSTALL_DIR")
|
|
3922
|
-
if custom:
|
|
3923
|
-
custom=os.path.abspath(custom)
|
|
3924
|
-
if os.path.commonpath((user_home,custom))!=user_home: raise SystemExit(1)
|
|
3925
|
-
known.add(os.path.join(custom,"fmix"))
|
|
3926
|
-
if entrypoint not in known and entrypoint!=runner: reject("unrecognized_managed_entrypoint")
|
|
3927
|
-
paths=[]
|
|
3928
|
-
for path in sorted(known):
|
|
3929
|
-
if not os.path.lexists(path): continue
|
|
3930
|
-
parent=os.path.dirname(path)
|
|
3931
|
-
if os.path.commonpath((user_home,parent))!=user_home: raise SystemExit(1)
|
|
3932
|
-
rel=os.path.relpath(parent,user_home); current=user_home
|
|
3933
|
-
for part in (() if rel=="." else rel.split(os.sep)):
|
|
3934
|
-
current=os.path.join(current,part); s=os.lstat(current)
|
|
3935
|
-
if not stat.S_ISDIR(s.st_mode) or stat.S_ISLNK(s.st_mode) or s.st_uid!=uid or s.st_mode&0o022:
|
|
3936
|
-
reject("unsafe_launcher_parent")
|
|
3937
|
-
link=os.lstat(path)
|
|
3938
|
-
if not stat.S_ISLNK(link.st_mode) or link.st_uid!=uid or link.st_nlink!=1 or os.path.realpath(path)!=runner:
|
|
3939
|
-
reject("managed_launcher_mismatch")
|
|
3940
|
-
paths.append(path)
|
|
3941
|
-
if entrypoint not in paths and (entrypoint!=runner or not paths):
|
|
3942
|
-
reject("managed_launcher_missing")
|
|
3943
|
-
fd=os.open(runner,os.O_RDONLY|getattr(os,"O_NOFOLLOW",0))
|
|
3944
|
-
try:
|
|
3945
|
-
s=os.fstat(fd)
|
|
3946
|
-
if not stat.S_ISREG(s.st_mode) or s.st_uid!=uid or s.st_nlink!=1 or s.st_mode&0o222 or not s.st_mode&0o111 or s.st_size>4*1024*1024:
|
|
3947
|
-
reject("unsafe_runner_identity")
|
|
3948
|
-
parent=os.open(fmix_home+"/runtime",os.O_RDONLY|os.O_DIRECTORY|getattr(os,"O_NOFOLLOW",0))
|
|
3949
|
-
try:
|
|
3950
|
-
runtime=os.fstat(parent)
|
|
3951
|
-
if runtime.st_uid!=uid or runtime.st_dev!=s.st_dev or runtime.st_mode&0o022:
|
|
3952
|
-
reject("unsafe_runner_runtime")
|
|
3953
|
-
finally: os.close(parent)
|
|
3954
|
-
h=hashlib.sha256()
|
|
3955
|
-
for block in iter(lambda: os.read(fd,65536),b""): h.update(block)
|
|
3956
|
-
if runner!=fmix_home+"/runtime/fmix-"+h.hexdigest():
|
|
3957
|
-
reject("managed_launcher_runner_mismatch")
|
|
3958
|
-
finally: os.close(fd)
|
|
3959
|
-
PY
|
|
3960
|
-
}
|
|
3961
4020
|
fmix_managed_publication_gate() {
|
|
3962
4021
|
# Shared-cache publication requires the managed install (fmix install).
|
|
3963
4022
|
# An npm/mise-linked runner is refused. Report the validator's reason and
|
|
@@ -3965,7 +4024,7 @@ fmix_managed_publication_gate() {
|
|
|
3965
4024
|
local reason
|
|
3966
4025
|
reason="$(fmix_artifact_v2_managed_entrypoint 2>&1)" && return 0
|
|
3967
4026
|
fmix_warn "Shared ${1:-artifact} publication is held: managed launcher check failed (${reason:-unknown})."
|
|
3968
|
-
fmix_warn "Run 'fmix install'
|
|
4027
|
+
fmix_warn "Run 'fmix install' from this runner so shared templates and dependency artifacts can publish: a byte-identical copy then runs through \$HOME/.local/bin/fmix."
|
|
3969
4028
|
return 1
|
|
3970
4029
|
}
|
|
3971
4030
|
|
|
@@ -16318,7 +16377,7 @@ cmd_setup() {
|
|
|
16318
16377
|
# Surface an unmanaged launcher before a long cold compile, not after it.
|
|
16319
16378
|
# The publication hold itself is non-fatal; this is advisory only.
|
|
16320
16379
|
if ! fmix_artifact_v2_managed_entrypoint >/dev/null 2>&1; then
|
|
16321
|
-
fmix_warn "This fmix launcher is not the managed install. The cold compile will run, but shared template and dependency artifacts will not publish from it (run 'fmix install'
|
|
16380
|
+
fmix_warn "This fmix launcher is not the managed install. The cold compile will run, but shared template and dependency artifacts will not publish from it (run 'fmix install' from this runner; a byte-identical copy then runs through the managed launcher)."
|
|
16322
16381
|
fi
|
|
16323
16382
|
fmix_info "DB name: $db_name"
|
|
16324
16383
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@calltelemetry/fmix",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.28",
|
|
4
4
|
"description": "Verified native FMix runner for CallTelemetry workspaces",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"directory": "packages/npm"
|
|
27
27
|
},
|
|
28
28
|
"fmix": {
|
|
29
|
-
"runnerSha256": "
|
|
30
|
-
"sourceTag": "fmix-v2.7.
|
|
29
|
+
"runnerSha256": "9c7afccba6ee89287fb823ffda399f31d52c208108d2681bb01de043a64a4b46",
|
|
30
|
+
"sourceTag": "fmix-v2.7.28"
|
|
31
31
|
}
|
|
32
32
|
}
|