core: prefer mkdir over create_directory and permissions

This commit is contained in:
Vaxry 2024-04-28 18:58:31 +01:00
parent 28c8561924
commit b164e67d8b
2 changed files with 11 additions and 10 deletions

View file

@ -16,6 +16,9 @@
#include "protocols/FractionalScale.hpp" #include "protocols/FractionalScale.hpp"
#include "protocols/PointerConstraints.hpp" #include "protocols/PointerConstraints.hpp"
#include <sys/stat.h>
#include <sys/types.h>
int handleCritSignal(int signo, void* data) { int handleCritSignal(int signo, void* data) {
Debug::log(LOG, "Hyprland received signal {}", signo); Debug::log(LOG, "Hyprland received signal {}", signo);
@ -63,15 +66,11 @@ CCompositor::CCompositor() {
setenv("HYPRLAND_INSTANCE_SIGNATURE", m_szInstanceSignature.c_str(), true); setenv("HYPRLAND_INSTANCE_SIGNATURE", m_szInstanceSignature.c_str(), true);
if (!std::filesystem::exists("/tmp/hypr")) { if (!std::filesystem::exists("/tmp/hypr"))
std::filesystem::create_directory("/tmp/hypr"); mkdir("/tmp/hypr", S_IRWXU | S_IRWXG | S_IRWXO | S_ISVTX);
std::filesystem::permissions("/tmp/hypr", std::filesystem::perms::all | std::filesystem::perms::sticky_bit, std::filesystem::perm_options::replace);
}
const auto INSTANCEPATH = "/tmp/hypr/" + m_szInstanceSignature; const auto INSTANCEPATH = "/tmp/hypr/" + m_szInstanceSignature;
std::filesystem::create_directory(INSTANCEPATH); mkdir(INSTANCEPATH.c_str(), S_IRWXU | S_IRWXG);
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);
Debug::init(m_szInstanceSignature); Debug::init(m_szInstanceSignature);

View file

@ -10,6 +10,8 @@
#include <unistd.h> #include <unistd.h>
#include <cstring> #include <cstring>
#include <fstream> #include <fstream>
#include <sys/stat.h>
#include <sys/types.h>
CFunctionHook::CFunctionHook(HANDLE owner, void* source, void* destination) { CFunctionHook::CFunctionHook(HANDLE owner, void* source, void* destination) {
m_pSource = source; m_pSource = source;
@ -138,10 +140,10 @@ CFunctionHook::SAssembly CFunctionHook::fixInstructionProbeRIPCalls(const SInstr
const auto RANDOMDIR = "/tmp/hypr/" + g_pTokenManager->getRandomUUID(); const auto RANDOMDIR = "/tmp/hypr/" + g_pTokenManager->getRandomUUID();
if (!std::filesystem::create_directory(RANDOMDIR)) mkdir(RANDOMDIR.c_str(), S_IRWXU);
return {};
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); std::ofstream ofs(RANDOMDIR + "/.hookcode.asm", std::ios::trunc);
ofs << assemblyBuilder; ofs << assemblyBuilder;