Loading pkgs/applications/video/kodi/add-KODI_WEBSERVER_EXTRA_WHITELIST.patchdeleted 100644 → 0 +0 −88 Original line number Diff line number Diff line From 620c3eb38f0dbea6e877e37e97508513e87a0732 Mon Sep 17 00:00:00 2001 From: Jeremy Fleischman <jeremyfleischman@gmail.com> Date: Sun, 27 Mar 2022 00:44:52 -0700 Subject: [PATCH] Add new KODI_WEBSERVER_EXTRA_WHITELIST cmake var to allow access to more directories (This is a backport of https://github.com/xbmc/xbmc/commit/a6dedce7ba1f03bdd83b019941d1e369a06f7888 to Kodi 19.4 Matrix) This is useful for NixOS, which often ends up creating a `KODI_HOME` with symlinks to other files (including the chorus2 interface). Kodi's webserver cautiously refuses to follow these symlinks, and you end up getting 404s rather than the web page. See https://forum.kodi.tv/showthread.php?tid=366338&pid=3079493 for a discussion of this on the Kodi forum. --- CMakeLists.txt | 1 + xbmc/CompileInfo.cpp.in | 5 +++++ xbmc/CompileInfo.h | 1 + xbmc/utils/FileUtils.cpp | 6 +++++- 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2d5369798df23..d5ef6d9390ef0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -243,6 +243,7 @@ add_custom_command(OUTPUT ${CORE_BUILD_DIR}/xbmc/CompileInfo.cpp -DAPP_BUILD_DATE=${APP_BUILD_DATE} -DAPP_SHARED_LIBRARY_SUFFIX="${APP_SHARED_LIBRARY_SUFFIX}" -Dprefix=${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR} + -DKODI_WEBSERVER_EXTRA_WHITELIST="${KODI_WEBSERVER_EXTRA_WHITELIST}" -P ${CMAKE_SOURCE_DIR}/cmake/scripts/common/GenerateVersionedFiles.cmake DEPENDS ${CMAKE_SOURCE_DIR}/version.txt export-files diff --git a/xbmc/CompileInfo.cpp.in b/xbmc/CompileInfo.cpp.in index f81fe77902236..4f19203a89cde 100644 --- a/xbmc/CompileInfo.cpp.in +++ b/xbmc/CompileInfo.cpp.in @@ -105,3 +105,8 @@ std::vector<std::string> CCompileInfo::GetAvailableWindowSystems() { return StringUtils::Split("@CORE_PLATFORM_NAME_LC@", ' '); } + +const std::vector<std::string> CCompileInfo::GetWebserverExtraWhitelist() +{ + return StringUtils::Split("@KODI_WEBSERVER_EXTRA_WHITELIST@", ','); +} diff --git a/xbmc/CompileInfo.h b/xbmc/CompileInfo.h index 553a0194ee77f..e2521324e6576 100644 --- a/xbmc/CompileInfo.h +++ b/xbmc/CompileInfo.h @@ -32,4 +32,5 @@ class CCompileInfo static const char* GetVersionCode(); static std::vector<std::string> GetAvailableWindowSystems(); static std::vector<ADDON::RepoInfo> LoadOfficialRepoInfos(); + static const std::vector<std::string> GetWebserverExtraWhitelist(); }; diff --git a/xbmc/utils/FileUtils.cpp b/xbmc/utils/FileUtils.cpp index e51f3d631c256..fc717c9608098 100644 --- a/xbmc/utils/FileUtils.cpp +++ b/xbmc/utils/FileUtils.cpp @@ -6,6 +6,7 @@ * See LICENSES/README.md for more information. */ +#include "CompileInfo.h" #include "FileUtils.h" #include "ServiceBroker.h" #include "guilib/GUIKeyboardFactory.h" @@ -261,12 +262,15 @@ bool CFileUtils::CheckFileAccessAllowed(const std::string &filePath) "/.ssh/", }; // ALLOW kodi paths - const std::vector<std::string> whitelist = { + std::vector<std::string> whitelist = { CSpecialProtocol::TranslatePath("special://home"), CSpecialProtocol::TranslatePath("special://xbmc"), CSpecialProtocol::TranslatePath("special://musicartistsinfo") }; + auto kodiExtraWhitelist = CCompileInfo::GetWebserverExtraWhitelist(); + whitelist.insert(whitelist.end(), kodiExtraWhitelist.begin(), kodiExtraWhitelist.end()); + // image urls come in the form of image://... sometimes with a / appended at the end // and can be embedded in a music or video file image://music@... // strip this off to get the real file path pkgs/applications/video/kodi/addons/addon-update-script/default.nix +1 −1 Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ { attrPath }: let url = "http://mirrors.kodi.tv/addons/matrix/addons.xml.gz"; url = "http://mirrors.kodi.tv/addons/nexus/addons.xml.gz"; updateScript = writeShellScript "update.sh" '' set -ex Loading pkgs/applications/video/kodi/addons/arrow/default.nix +2 −2 Original line number Diff line number Diff line Loading @@ -5,8 +5,8 @@ buildKodiAddon rec { version = "1.0.3.1"; src = fetchzip { url = "https://mirrors.kodi.tv/addons/matrix/${namespace}/${namespace}-${version}.zip"; sha256 = "0xa16sb2hls59l4gsg1xwb1qbkhcvbykq02l05n5rcm0alg80l3l"; url = "https://mirrors.kodi.tv/addons/nexus/script.module.arrow/script.module.arrow-${version}.zip"; sha256 = "sha256-dFCAHlWgslxsAVQAPP3aDM6Fw+I9PP0ITUVTKJY2QXU="; }; propagatedBuildInputs = [ Loading pkgs/applications/video/kodi/addons/arteplussept/default.nix +1 −1 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ buildKodiAddon rec { version = "1.1.8"; src = fetchzip { url = "https://mirrors.kodi.tv/addons/matrix/${namespace}/${namespace}-${version}.zip"; url = "https://mirrors.kodi.tv/addons/nexus/${namespace}/${namespace}-${version}.zip"; hash = "sha256-1f+oEHEhSsDMXH7WssSVjjuDjK3UNyMiNhaw7mh/xjI="; }; Loading pkgs/applications/video/kodi/addons/certifi/default.nix +2 −2 Original line number Diff line number Diff line Loading @@ -5,8 +5,8 @@ buildKodiAddon rec { version = "2022.9.24"; src = fetchzip { url = "https://mirrors.kodi.tv/addons/matrix/${namespace}/${namespace}-${version}.zip"; sha256 = "kIPGEjmnHlgVb11W2RKBlrMy3/+kUOcQZiLCcnHCcno="; url = "https://mirrors.kodi.tv/addons/nexus/${namespace}/${namespace}-${version}.zip"; sha256 = "sha256-kIPGEjmnHlgVb11W2RKBlrMy3/+kUOcQZiLCcnHCcno="; }; passthru = { Loading Loading
pkgs/applications/video/kodi/add-KODI_WEBSERVER_EXTRA_WHITELIST.patchdeleted 100644 → 0 +0 −88 Original line number Diff line number Diff line From 620c3eb38f0dbea6e877e37e97508513e87a0732 Mon Sep 17 00:00:00 2001 From: Jeremy Fleischman <jeremyfleischman@gmail.com> Date: Sun, 27 Mar 2022 00:44:52 -0700 Subject: [PATCH] Add new KODI_WEBSERVER_EXTRA_WHITELIST cmake var to allow access to more directories (This is a backport of https://github.com/xbmc/xbmc/commit/a6dedce7ba1f03bdd83b019941d1e369a06f7888 to Kodi 19.4 Matrix) This is useful for NixOS, which often ends up creating a `KODI_HOME` with symlinks to other files (including the chorus2 interface). Kodi's webserver cautiously refuses to follow these symlinks, and you end up getting 404s rather than the web page. See https://forum.kodi.tv/showthread.php?tid=366338&pid=3079493 for a discussion of this on the Kodi forum. --- CMakeLists.txt | 1 + xbmc/CompileInfo.cpp.in | 5 +++++ xbmc/CompileInfo.h | 1 + xbmc/utils/FileUtils.cpp | 6 +++++- 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2d5369798df23..d5ef6d9390ef0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -243,6 +243,7 @@ add_custom_command(OUTPUT ${CORE_BUILD_DIR}/xbmc/CompileInfo.cpp -DAPP_BUILD_DATE=${APP_BUILD_DATE} -DAPP_SHARED_LIBRARY_SUFFIX="${APP_SHARED_LIBRARY_SUFFIX}" -Dprefix=${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR} + -DKODI_WEBSERVER_EXTRA_WHITELIST="${KODI_WEBSERVER_EXTRA_WHITELIST}" -P ${CMAKE_SOURCE_DIR}/cmake/scripts/common/GenerateVersionedFiles.cmake DEPENDS ${CMAKE_SOURCE_DIR}/version.txt export-files diff --git a/xbmc/CompileInfo.cpp.in b/xbmc/CompileInfo.cpp.in index f81fe77902236..4f19203a89cde 100644 --- a/xbmc/CompileInfo.cpp.in +++ b/xbmc/CompileInfo.cpp.in @@ -105,3 +105,8 @@ std::vector<std::string> CCompileInfo::GetAvailableWindowSystems() { return StringUtils::Split("@CORE_PLATFORM_NAME_LC@", ' '); } + +const std::vector<std::string> CCompileInfo::GetWebserverExtraWhitelist() +{ + return StringUtils::Split("@KODI_WEBSERVER_EXTRA_WHITELIST@", ','); +} diff --git a/xbmc/CompileInfo.h b/xbmc/CompileInfo.h index 553a0194ee77f..e2521324e6576 100644 --- a/xbmc/CompileInfo.h +++ b/xbmc/CompileInfo.h @@ -32,4 +32,5 @@ class CCompileInfo static const char* GetVersionCode(); static std::vector<std::string> GetAvailableWindowSystems(); static std::vector<ADDON::RepoInfo> LoadOfficialRepoInfos(); + static const std::vector<std::string> GetWebserverExtraWhitelist(); }; diff --git a/xbmc/utils/FileUtils.cpp b/xbmc/utils/FileUtils.cpp index e51f3d631c256..fc717c9608098 100644 --- a/xbmc/utils/FileUtils.cpp +++ b/xbmc/utils/FileUtils.cpp @@ -6,6 +6,7 @@ * See LICENSES/README.md for more information. */ +#include "CompileInfo.h" #include "FileUtils.h" #include "ServiceBroker.h" #include "guilib/GUIKeyboardFactory.h" @@ -261,12 +262,15 @@ bool CFileUtils::CheckFileAccessAllowed(const std::string &filePath) "/.ssh/", }; // ALLOW kodi paths - const std::vector<std::string> whitelist = { + std::vector<std::string> whitelist = { CSpecialProtocol::TranslatePath("special://home"), CSpecialProtocol::TranslatePath("special://xbmc"), CSpecialProtocol::TranslatePath("special://musicartistsinfo") }; + auto kodiExtraWhitelist = CCompileInfo::GetWebserverExtraWhitelist(); + whitelist.insert(whitelist.end(), kodiExtraWhitelist.begin(), kodiExtraWhitelist.end()); + // image urls come in the form of image://... sometimes with a / appended at the end // and can be embedded in a music or video file image://music@... // strip this off to get the real file path
pkgs/applications/video/kodi/addons/addon-update-script/default.nix +1 −1 Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ { attrPath }: let url = "http://mirrors.kodi.tv/addons/matrix/addons.xml.gz"; url = "http://mirrors.kodi.tv/addons/nexus/addons.xml.gz"; updateScript = writeShellScript "update.sh" '' set -ex Loading
pkgs/applications/video/kodi/addons/arrow/default.nix +2 −2 Original line number Diff line number Diff line Loading @@ -5,8 +5,8 @@ buildKodiAddon rec { version = "1.0.3.1"; src = fetchzip { url = "https://mirrors.kodi.tv/addons/matrix/${namespace}/${namespace}-${version}.zip"; sha256 = "0xa16sb2hls59l4gsg1xwb1qbkhcvbykq02l05n5rcm0alg80l3l"; url = "https://mirrors.kodi.tv/addons/nexus/script.module.arrow/script.module.arrow-${version}.zip"; sha256 = "sha256-dFCAHlWgslxsAVQAPP3aDM6Fw+I9PP0ITUVTKJY2QXU="; }; propagatedBuildInputs = [ Loading
pkgs/applications/video/kodi/addons/arteplussept/default.nix +1 −1 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ buildKodiAddon rec { version = "1.1.8"; src = fetchzip { url = "https://mirrors.kodi.tv/addons/matrix/${namespace}/${namespace}-${version}.zip"; url = "https://mirrors.kodi.tv/addons/nexus/${namespace}/${namespace}-${version}.zip"; hash = "sha256-1f+oEHEhSsDMXH7WssSVjjuDjK3UNyMiNhaw7mh/xjI="; }; Loading
pkgs/applications/video/kodi/addons/certifi/default.nix +2 −2 Original line number Diff line number Diff line Loading @@ -5,8 +5,8 @@ buildKodiAddon rec { version = "2022.9.24"; src = fetchzip { url = "https://mirrors.kodi.tv/addons/matrix/${namespace}/${namespace}-${version}.zip"; sha256 = "kIPGEjmnHlgVb11W2RKBlrMy3/+kUOcQZiLCcnHCcno="; url = "https://mirrors.kodi.tv/addons/nexus/${namespace}/${namespace}-${version}.zip"; sha256 = "sha256-kIPGEjmnHlgVb11W2RKBlrMy3/+kUOcQZiLCcnHCcno="; }; passthru = { Loading