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
7 changed files with 224 additions and 111 deletions

View File

@@ -3,10 +3,21 @@
#include <string>
namespace NSys {
bool isSuperuser();
int getUID();
int getEUID();
std::string runAsSuperuser(const std::string& cmd);
void cacheSudo();
void dropSudo();
bool isSuperuser();
int getUID();
int getEUID();
// NOLINTNEXTLINE
namespace root {
void cacheSudo();
void dropSudo();
//
[[nodiscard("Discarding could lead to vulnerabilities and bugs")]] bool createDirectory(const std::string& path, const std::string& mode);
[[nodiscard("Discarding could lead to vulnerabilities and bugs")]] bool removeRecursive(const std::string& path);
[[nodiscard("Discarding could lead to vulnerabilities and bugs")]] bool install(const std::string& what, const std::string& where, const std::string& mode);
// Do not use this unless absolutely necessary!
std::string runAsSuperuserUnsafe(const std::string& cmd);
};
};