From 85cfd080f162456719f560837d797fc70c0308e5 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Wed, 22 Nov 2023 19:00:21 -0500 Subject: [PATCH 1/4] Remove the functionality of /System/MediaEncoder/Path Eliminate this endpoint by having it perform no action, pending total removal in the next major version (10.9.0). Further, adjust the MediaEncoder startup options to completely ignore what is in the XML currently, and respect only the "--ffmpeg" arg, which is set on most of our platforms, falling back to system "ffmpeg" in $PATH if not found. This ensures that, should the "--ffmpeg" arg be changed by an administrator wishing to alter the default FFmpeg binary, this change will be reflected properly on next startup. --- Jellyfin.Api/Controllers/ConfigurationController.cs | 4 +++- MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs | 13 ++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Jellyfin.Api/Controllers/ConfigurationController.cs b/Jellyfin.Api/Controllers/ConfigurationController.cs index 464fadc060..7b3d05c100 100644 --- a/Jellyfin.Api/Controllers/ConfigurationController.cs +++ b/Jellyfin.Api/Controllers/ConfigurationController.cs @@ -130,8 +130,10 @@ namespace Jellyfin.Api.Controllers [ProducesResponseType(StatusCodes.Status204NoContent)] public ActionResult UpdateMediaEncoderPath([FromBody, Required] MediaEncoderPathDto mediaEncoderPath) { - _mediaEncoder.UpdateEncoderPath(mediaEncoderPath.Path, mediaEncoderPath.PathType); + // API ENDPOINT DISABLED (NOOP) FOR SECURITY PURPOSES return NoContent(); + //_mediaEncoder.UpdateEncoderPath(mediaEncoderPath.Path, mediaEncoderPath.PathType); + //return NoContent(); } } } diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs index 539996c3ae..da4920d40b 100644 --- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs @@ -117,17 +117,12 @@ namespace MediaBrowser.MediaEncoding.Encoder /// public void SetFFmpegPath() { - // 1) Custom path stored in config/encoding xml file under tag takes precedence - var ffmpegPath = _configurationManager.GetEncodingOptions().EncoderAppPath; + // 1) Check if the --ffmpeg CLI switch has been given + var ffmpegPath = _startupOptionFFmpegPath; if (string.IsNullOrEmpty(ffmpegPath)) { - // 2) Check if the --ffmpeg CLI switch has been given - ffmpegPath = _startupOptionFFmpegPath; - if (string.IsNullOrEmpty(ffmpegPath)) - { - // 3) Check "ffmpeg" - ffmpegPath = "ffmpeg"; - } + // 2) Check "ffmpeg" + ffmpegPath = "ffmpeg"; } if (!ValidatePath(ffmpegPath)) From 0430ffecb6aa516865c4e7317ade5ce13f2545df Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Thu, 23 Nov 2023 01:44:14 -0500 Subject: [PATCH 2/4] Restore ordering --- Jellyfin.Api/Controllers/ConfigurationController.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Jellyfin.Api/Controllers/ConfigurationController.cs b/Jellyfin.Api/Controllers/ConfigurationController.cs index 7b3d05c100..5db49b69e3 100644 --- a/Jellyfin.Api/Controllers/ConfigurationController.cs +++ b/Jellyfin.Api/Controllers/ConfigurationController.cs @@ -131,9 +131,8 @@ namespace Jellyfin.Api.Controllers public ActionResult UpdateMediaEncoderPath([FromBody, Required] MediaEncoderPathDto mediaEncoderPath) { // API ENDPOINT DISABLED (NOOP) FOR SECURITY PURPOSES - return NoContent(); //_mediaEncoder.UpdateEncoderPath(mediaEncoderPath.Path, mediaEncoderPath.PathType); - //return NoContent(); + return NoContent(); } } } From bf5f00a38315c68e8f12663b6457cf10816e362b Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Thu, 23 Nov 2023 13:24:56 -0500 Subject: [PATCH 3/4] Restore original flag behaviour --- MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs index da4920d40b..539996c3ae 100644 --- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs @@ -117,12 +117,17 @@ namespace MediaBrowser.MediaEncoding.Encoder /// public void SetFFmpegPath() { - // 1) Check if the --ffmpeg CLI switch has been given - var ffmpegPath = _startupOptionFFmpegPath; + // 1) Custom path stored in config/encoding xml file under tag takes precedence + var ffmpegPath = _configurationManager.GetEncodingOptions().EncoderAppPath; if (string.IsNullOrEmpty(ffmpegPath)) { - // 2) Check "ffmpeg" - ffmpegPath = "ffmpeg"; + // 2) Check if the --ffmpeg CLI switch has been given + ffmpegPath = _startupOptionFFmpegPath; + if (string.IsNullOrEmpty(ffmpegPath)) + { + // 3) Check "ffmpeg" + ffmpegPath = "ffmpeg"; + } } if (!ValidatePath(ffmpegPath)) From 1e0bd3235885c8bef27c74d8bbe273398d6510e8 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Sun, 26 Nov 2023 18:33:13 -0500 Subject: [PATCH 4/4] Set Path endpoint obsolete --- Jellyfin.Api/Controllers/ConfigurationController.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Jellyfin.Api/Controllers/ConfigurationController.cs b/Jellyfin.Api/Controllers/ConfigurationController.cs index 5db49b69e3..0e64f725ba 100644 --- a/Jellyfin.Api/Controllers/ConfigurationController.cs +++ b/Jellyfin.Api/Controllers/ConfigurationController.cs @@ -125,6 +125,7 @@ namespace Jellyfin.Api.Controllers /// Media encoder path form body. /// Media encoder path updated. /// Status. + [Obsolete("This endpoint is obsolete.")] [HttpPost("MediaEncoder/Path")] [Authorize(Policy = Policies.FirstTimeSetupOrElevated)] [ProducesResponseType(StatusCodes.Status204NoContent)]