Skip to content

Commit dc78d56

Browse files
committed
no-mistakes: apply CI fixes
1 parent 5d022bb commit dc78d56

1 file changed

Lines changed: 19 additions & 13 deletions

File tree

tests/test_build_sealed_bridge_runtimes.py

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,28 @@ def sha(path: Path) -> str:
3030
return hashlib.sha256(path.read_bytes()).hexdigest()
3131

3232

33-
def host_system_tool_paths(fallback: Path) -> dict[str, Path]:
33+
def host_system_tool_paths() -> dict[str, Path]:
3434
def usable(path: Path) -> bool:
3535
try:
36-
builder._require_regular(
37-
path,
38-
"fixture system tool",
39-
executable=True,
40-
allow_root_owner=True,
41-
)
42-
except (OSError, builder.BuildError):
36+
metadata = path.lstat()
37+
except OSError:
4338
return False
44-
return Path(os.path.realpath(path)) == path
39+
return (
40+
stat.S_ISREG(metadata.st_mode)
41+
and metadata.st_uid == 0
42+
and not stat.S_IMODE(metadata.st_mode) & 0o022
43+
and Path(os.path.realpath(path)) == path
44+
and os.access(path, os.X_OK)
45+
)
4546

47+
fallback = next(
48+
path
49+
for path in map(
50+
Path,
51+
("/usr/bin/true", "/bin/true", "/usr/bin/env", "/bin/echo"),
52+
)
53+
if usable(path)
54+
)
4655
return {
4756
name: path if usable(path) else fallback
4857
for name, path in builder.SYSTEM_TOOL_PATHS.items()
@@ -171,11 +180,8 @@ class SealedRuntimeBuilderTests(unittest.TestCase):
171180
def setUp(self) -> None:
172181
self.temporary = tempfile.TemporaryDirectory(prefix="sealed-builder-test-")
173182
self.root = Path(os.path.realpath(self.temporary.name))
174-
fallback = self.root / "system-tool"
175-
fallback.write_text("#!/bin/sh\nexit 0\n", encoding="utf-8")
176-
fallback.chmod(0o700)
177183
self.system_tools_patch = mock.patch.object(
178-
builder, "SYSTEM_TOOL_PATHS", host_system_tool_paths(fallback)
184+
builder, "SYSTEM_TOOL_PATHS", host_system_tool_paths()
179185
)
180186
self.system_tools_patch.start()
181187
self.fixture = ManifestFixture(self.root)

0 commit comments

Comments
 (0)