hyprpm: clean up root access and properly check input (#10304)

* manifest: reject bad names from parsing

* sys: restructure root functions
This commit is contained in:
Vaxry 2025-05-06 22:43:08 +02:00 committed by GitHub
parent 948277895e
commit f8bbe5124c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 224 additions and 111 deletions

View file

@ -101,8 +101,8 @@ int main(int argc, char** argv, char** envp) {
if (command.size() >= 3)
rev = command[2];
NSys::cacheSudo();
CScopeGuard x([] { NSys::dropSudo(); });
NSys::root::cacheSudo();
CScopeGuard x([] { NSys::root::dropSudo(); });
return g_pPluginManager->addNewPluginRepo(command[1], rev) ? 0 : 1;
} else if (command[0] == "remove") {
@ -111,13 +111,13 @@ int main(int argc, char** argv, char** envp) {
return 1;
}
NSys::cacheSudo();
CScopeGuard x([] { NSys::dropSudo(); });
NSys::root::cacheSudo();
CScopeGuard x([] { NSys::root::dropSudo(); });
return g_pPluginManager->removePluginRepo(command[1]) ? 0 : 1;
} else if (command[0] == "update") {
NSys::cacheSudo();
CScopeGuard x([] { NSys::dropSudo(); });
NSys::root::cacheSudo();
CScopeGuard x([] { NSys::root::dropSudo(); });
bool headersValid = g_pPluginManager->headersValid() == HEADERS_OK;
bool headers = g_pPluginManager->updateHeaders(force);
@ -152,8 +152,8 @@ int main(int argc, char** argv, char** envp) {
return 1;
}
NSys::cacheSudo();
CScopeGuard x([] { NSys::dropSudo(); });
NSys::root::cacheSudo();
CScopeGuard x([] { NSys::root::dropSudo(); });
auto ret = g_pPluginManager->ensurePluginsLoadState();
@ -173,8 +173,8 @@ int main(int argc, char** argv, char** envp) {
return 1;
}
NSys::cacheSudo();
CScopeGuard x([] { NSys::dropSudo(); });
NSys::root::cacheSudo();
CScopeGuard x([] { NSys::root::dropSudo(); });
auto ret = g_pPluginManager->ensurePluginsLoadState();
@ -200,8 +200,8 @@ int main(int argc, char** argv, char** envp) {
g_pPluginManager->notify(ICON_OK, 0, 4000, "[hyprpm] Loaded plugins");
}
} else if (command[0] == "purge-cache") {
NSys::cacheSudo();
CScopeGuard x([] { NSys::dropSudo(); });
NSys::root::cacheSudo();
CScopeGuard x([] { NSys::root::dropSudo(); });
DataState::purgeAllCache();
} else if (command[0] == "list") {
g_pPluginManager->listAllPlugins();