mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-11-08 22:53:01 +03:00
resolve the full ffmpeg path under granular root
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user