resolve the full ffmpeg path under granular root

This commit is contained in:
Josh Hawkins
2026-11-07 12:46:04 -06:00
parent e04035dfa2
commit 06c23ab51b
2 changed files with 9 additions and 2 deletions
@@ -216,6 +216,13 @@ class TestConfigFfmpegRootGuardSymlinks(unittest.TestCase):
os.symlink(evil, self.link)
self.assertEqual(self._resolve({"FRIGATE_ROOT_SERVICES": "frigate"}), BUNDLED)
def test_bin_linked_into_a_writable_tree_is_refused(self) -> None:
evil = os.path.join(self.writable, "evil")
os.makedirs(evil)
os.symlink(evil, os.path.join(self.root_owned, "bin"))
os.symlink(self.root_owned, self.link)
self.assertEqual(self._resolve({"FRIGATE_ROOT_SERVICES": "frigate"}), BUNDLED)
def test_unprivileged_service_keeps_the_path_as_written(self) -> None:
os.symlink(self.root_owned, self.link)
self.assertEqual(self._resolve({}), f"{self.link}/bin/ffmpeg")
+2 -2
View File
@@ -125,9 +125,9 @@ def resolve_ffmpeg_path(
else:
# return the resolved form so a link in the path cannot be retargeted
# after the check
real = os.path.realpath(path)
real = os.path.realpath(f"{path}/bin/{binary}")
if is_valid_ffmpeg_path(real) and not is_runtime_user_writable(real):
return f"{real}/bin/{binary}"
return real
_warn_ignored_ffmpeg_path(path, service)
version = DEFAULT_FFMPEG_VERSION