From 9962bac50bba714e9f37591edeb2756efd7708c8 Mon Sep 17 00:00:00 2001 From: "vladimir.kuznetsov" Date: Sun, 19 Mar 2023 17:05:48 +0300 Subject: [PATCH] changed using cp to QFile to copy wireguard config --- client/protocols/wireguardprotocol.h | 1 - ipc/ipcserver.cpp | 23 ++++++++++------------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/client/protocols/wireguardprotocol.h b/client/protocols/wireguardprotocol.h index 59fa39fa..880417b4 100644 --- a/client/protocols/wireguardprotocol.h +++ b/client/protocols/wireguardprotocol.h @@ -37,7 +37,6 @@ private: QSharedPointer m_wireguardStartProcess; QSharedPointer m_wireguardStopProcess; - IpcClient *m_ipcClient; bool m_isConfigLoaded = false; diff --git a/ipc/ipcserver.cpp b/ipc/ipcserver.cpp index c872e6ab..ddbc646c 100644 --- a/ipc/ipcserver.cpp +++ b/ipc/ipcserver.cpp @@ -129,20 +129,17 @@ void IpcServer::setLogsEnabled(bool enabled) bool IpcServer::copyWireguardConfig(const QString &sourcePath) { #ifdef Q_OS_LINUX - QProcess copyWireguardConfigProcess; + const QString wireguardConfigPath = "/etc/wireguard/wg99.conf"; + if (QFile::exists(wireguardConfigPath)) + { + QFile::remove(wireguardConfigPath); + } - bool errorOccurred = false; - - connect(©WireguardConfigProcess, &QProcess::errorOccurred, this, [&errorOccurred](QProcess::ProcessError error) { - qDebug() << "WireguardProtocol::WireguardProtocol error occured while copying wireguard config: " << error; - errorOccurred = true; - }); - - copyWireguardConfigProcess.setProgram("/bin/cp"); - copyWireguardConfigProcess.setArguments(QStringList{sourcePath, "/etc/wireguard/wg99.conf"}); - copyWireguardConfigProcess.start(); - copyWireguardConfigProcess.waitForFinished(10000); - return errorOccurred; + if (!QFile::copy(sourcePath, wireguardConfigPath)) { + qDebug() << "WireguardProtocol::WireguardProtocol error occured while copying wireguard config:"; + return false; + } + return true; #else return false; #endif