From b164e67d8b1f12420ec44a1c837af7923559ccf2 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sun, 28 Apr 2024 18:58:31 +0100 Subject: [PATCH] core: prefer mkdir over create_directory and permissions --- src/Compositor.cpp | 13 ++++++------- src/plugins/HookSystem.cpp | 8 +++++--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 17786cb2..8e333ebe 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -16,6 +16,9 @@ #include "protocols/FractionalScale.hpp" #include "protocols/PointerConstraints.hpp" +#include +#include + int handleCritSignal(int signo, void* data) { Debug::log(LOG, "Hyprland received signal {}", signo); @@ -63,15 +66,11 @@ CCompositor::CCompositor() { setenv("HYPRLAND_INSTANCE_SIGNATURE", m_szInstanceSignature.c_str(), true); - if (!std::filesystem::exists("/tmp/hypr")) { - std::filesystem::create_directory("/tmp/hypr"); - std::filesystem::permissions("/tmp/hypr", std::filesystem::perms::all | std::filesystem::perms::sticky_bit, std::filesystem::perm_options::replace); - } + if (!std::filesystem::exists("/tmp/hypr")) + mkdir("/tmp/hypr", S_IRWXU | S_IRWXG | S_IRWXO | S_ISVTX); const auto INSTANCEPATH = "/tmp/hypr/" + m_szInstanceSignature; - std::filesystem::create_directory(INSTANCEPATH); - std::filesystem::permissions(INSTANCEPATH, std::filesystem::perms::group_all, std::filesystem::perm_options::replace); - std::filesystem::permissions(INSTANCEPATH, std::filesystem::perms::owner_all, std::filesystem::perm_options::add); + mkdir(INSTANCEPATH.c_str(), S_IRWXU | S_IRWXG); Debug::init(m_szInstanceSignature); diff --git a/src/plugins/HookSystem.cpp b/src/plugins/HookSystem.cpp index 5082f54c..7ae71726 100644 --- a/src/plugins/HookSystem.cpp +++ b/src/plugins/HookSystem.cpp @@ -10,6 +10,8 @@ #include #include #include +#include +#include CFunctionHook::CFunctionHook(HANDLE owner, void* source, void* destination) { m_pSource = source; @@ -138,10 +140,10 @@ CFunctionHook::SAssembly CFunctionHook::fixInstructionProbeRIPCalls(const SInstr const auto RANDOMDIR = "/tmp/hypr/" + g_pTokenManager->getRandomUUID(); - if (!std::filesystem::create_directory(RANDOMDIR)) - return {}; + mkdir(RANDOMDIR.c_str(), S_IRWXU); - std::filesystem::permissions(RANDOMDIR, std::filesystem::perms::owner_all, std::filesystem::perm_options::replace); + if (!std::filesystem::exists(RANDOMDIR)) + return {}; std::ofstream ofs(RANDOMDIR + "/.hookcode.asm", std::ios::trunc); ofs << assemblyBuilder;