From 9534d3dc41737bc1417c45e830cf7bdfe965b4ec Mon Sep 17 00:00:00 2001 From: Robin Davies Date: Thu, 5 Sep 2024 13:29:44 -0400 Subject: [PATCH] Ttolerate inability to permission the Wi-Fi P2P configuration file when debugging. --- NetworkManagerP2P/src/NMP2pSettings.cpp | 28 ++++++++++++-------- PiPedalCommon/src/include/P2pConfigFiles.hpp | 4 +-- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/NetworkManagerP2P/src/NMP2pSettings.cpp b/NetworkManagerP2P/src/NMP2pSettings.cpp index 9caf9a6..e497f45 100644 --- a/NetworkManagerP2P/src/NMP2pSettings.cpp +++ b/NetworkManagerP2P/src/NMP2pSettings.cpp @@ -201,19 +201,25 @@ static void openWithPerms( std::filesystem::perms::group_read | std::filesystem::perms::group_write) { auto directory = path.parent_path(); - std::filesystem::create_directories(directory); - // open and close to make an existing empty file. - // close it. + if (!std::filesystem::exists(directory)) { - std::ofstream f; - f.open(path); - f.close(); + std::filesystem::create_directories(directory); + // open and close to make an existing empty file. + // close it. + { + std::ofstream f; + f.open(path); + f.close(); + } + try { + // set the perms. + std::filesystem::permissions( + path, + perms, + std::filesystem::perm_options::replace); + } catch (const std::exception&) { + } } - // set the perms. - std::filesystem::permissions( - path, - perms, - std::filesystem::perm_options::replace); // open for re3al. f.open(path); diff --git a/PiPedalCommon/src/include/P2pConfigFiles.hpp b/PiPedalCommon/src/include/P2pConfigFiles.hpp index 6a29a4a..76be852 100644 --- a/PiPedalCommon/src/include/P2pConfigFiles.hpp +++ b/PiPedalCommon/src/include/P2pConfigFiles.hpp @@ -25,7 +25,7 @@ #pragma once -#define DEVICE_GUID_FILE "/etc/pipedal/config/device_uuid" +#define DEVICE_GUID_FILE "/var/pipedal/config/device_uuid" -#define PIPEDAL_P2PD_CONF_PATH "/etc/pipedal/config/pipedal_p2pd.conf" +#define PIPEDAL_P2PD_CONF_PATH "/var/pipedal/config/pipedal_p2pd.conf"