changed using cp to QFile to copy wireguard config

This commit is contained in:
vladimir.kuznetsov 2023-03-19 17:05:48 +03:00
parent f0c3f1b9ba
commit 9962bac50b
2 changed files with 10 additions and 14 deletions

View file

@ -37,7 +37,6 @@ private:
QSharedPointer<PrivilegedProcess> m_wireguardStartProcess;
QSharedPointer<PrivilegedProcess> m_wireguardStopProcess;
IpcClient *m_ipcClient;
bool m_isConfigLoaded = false;

View file

@ -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(&copyWireguardConfigProcess, &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