fix: bind private temp storage for read-only late-slope runs
This commit is contained in:
@@ -5,6 +5,7 @@ import argparse
|
||||
import json
|
||||
from pathlib import Path
|
||||
import re
|
||||
import stat
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
@@ -46,12 +47,24 @@ def verify_local_image(bundle):
|
||||
require(image_identity(bundle["image"], context) == bundle["imageIdentity"], "Wrong cached image identity")
|
||||
|
||||
|
||||
def create_task_output(output, bundle_root):
|
||||
require(not output.is_symlink(), "Run output cannot be a symbolic link")
|
||||
output = output.resolve()
|
||||
require(not output.is_relative_to(bundle_root), "Run output must be outside the immutable bundle")
|
||||
output.mkdir(mode=0o700, parents=True, exist_ok=False)
|
||||
temporary = output / "tmp"
|
||||
temporary.mkdir(mode=0o700, exist_ok=False)
|
||||
for directory in (output, temporary):
|
||||
mode = directory.lstat().st_mode
|
||||
require(stat.S_ISDIR(mode) and stat.S_IMODE(mode) == 0o700, f"Expected private directory mode 0700 for {directory}")
|
||||
return output
|
||||
|
||||
|
||||
def launch(root, bundle, bundle_hash, output):
|
||||
require(Path(__file__).resolve() == root / "tools/launch.py", "Invoke the reviewed bundled launcher")
|
||||
require(not output.is_relative_to(root), "Run output must be outside the immutable bundle")
|
||||
output = create_task_output(output, root)
|
||||
run_id = uuid.uuid4().hex
|
||||
invocation = container_command(root, output, bundle, run_id)
|
||||
output.mkdir(mode=0o700, parents=True, exist_ok=False)
|
||||
provenance = {"kind": "launch", "protocol": PROTOCOL, "acceptance": False, "runId": run_id,
|
||||
"bundleReceiptSha256": bundle_hash, "sourceRevision": bundle["sourceRevision"], "image": bundle["image"],
|
||||
"coreClrSha256": bundle["files"]["app/libcoreclr.so"], "command": invocation,
|
||||
@@ -120,7 +133,7 @@ def main():
|
||||
"receiptSha256": options.receipt_sha256, "verified": True,
|
||||
"acceptance": False, "workloadLaunched": False}, indent=2))
|
||||
return 0
|
||||
return launch(root, bundle, options.receipt_sha256, options.output.resolve())
|
||||
return launch(root, bundle, options.receipt_sha256, options.output)
|
||||
except (OSError, KeyError, TypeError, ValueError, subprocess.SubprocessError) as error:
|
||||
print(f"Late-slope launcher rejected the request: {error}", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
Reference in New Issue
Block a user