lib: refuse to read inaccessible themes

fixes #1
This commit is contained in:
Vaxry 2024-03-10 17:16:32 +00:00
parent 96a015fc20
commit 05db7dfd7f

View file

@ -26,6 +26,20 @@ static std::string themeNameFromEnv() {
return std::string{ENV};
}
static bool themeAccessible(const std::string& path) {
try {
if (!std::filesystem::exists(path + "/manifest.hl"))
return false;
const auto MANIFESTSTATUS = std::filesystem::status(path + "/manifest.hl");
if ((MANIFESTSTATUS.permissions() & std::filesystem::perms::others_read) == std::filesystem::perms::none)
return false;
} catch (std::exception& e) { return false; }
return true;
}
static std::string getFirstTheme() {
// try user directories first
@ -112,6 +126,9 @@ static std::string getFullPathForThemeName(const std::string& name) {
if (!name.empty() && themeDir.path().stem().string() != name)
continue;
if (!themeAccessible(themeDir.path().string()))
continue;
const auto MANIFESTPATH = themeDir.path().string() + "/manifest.hl";
if (std::filesystem::exists(MANIFESTPATH))
@ -497,6 +514,9 @@ General
std::optional<std::string> CHyprcursorImplementation::loadTheme() {
if (!themeAccessible(themeFullDir))
return "Theme inaccessible";
currentTheme = &theme;
// load manifest