IpcServerProcess permit list
This commit is contained in:
parent
9236be7fbd
commit
3bff653bbb
12 changed files with 84 additions and 46 deletions
22
ipc/ipc.h
22
ipc/ipc.h
|
@ -4,10 +4,32 @@
|
|||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
#include "../client/utils.h"
|
||||
|
||||
#define IPC_SERVICE_URL "local:AmneziaVpnIpcInterface"
|
||||
|
||||
namespace amnezia {
|
||||
|
||||
enum PermittedProcess {
|
||||
OpenVPN,
|
||||
Wireguard,
|
||||
CertUtil
|
||||
};
|
||||
|
||||
inline QString permittedProcessPath(PermittedProcess pid)
|
||||
{
|
||||
if (pid == PermittedProcess::OpenVPN) {
|
||||
return Utils::openVpnExecPath();
|
||||
}
|
||||
if (pid == PermittedProcess::Wireguard) {
|
||||
return Utils::wireguardExecPath();
|
||||
}
|
||||
else if (pid == PermittedProcess::CertUtil) {
|
||||
return Utils::certUtilPath();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline QString getIpcServiceUrl() {
|
||||
#ifdef Q_OS_WIN
|
||||
return IPC_SERVICE_URL;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
class IpcProcessInterface
|
||||
{
|
||||
SLOT( start(const QString &program, const QStringList &args) );
|
||||
//SLOT( start(const QString &program, const QStringList &args) );
|
||||
SLOT( start() );
|
||||
SLOT( close() );
|
||||
|
||||
|
@ -11,7 +11,7 @@ class IpcProcessInterface
|
|||
SLOT( setInputChannelMode(QProcess::InputChannelMode mode) );
|
||||
SLOT( setNativeArguments(const QString &arguments) );
|
||||
SLOT( setProcessChannelMode(QProcess::ProcessChannelMode mode) );
|
||||
SLOT( setProgram(const QString &program) );
|
||||
SLOT( setProgram(int programId) );
|
||||
SLOT( setWorkingDirectory(const QString &dir) );
|
||||
|
||||
SLOT( QByteArray readAll() );
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "ipcserverprocess.h"
|
||||
#include "ipc.h"
|
||||
#include <QProcess>
|
||||
|
||||
#ifndef Q_OS_IOS
|
||||
|
@ -38,16 +39,19 @@ IpcServerProcess::~IpcServerProcess()
|
|||
qDebug() << "IpcServerProcess::~IpcServerProcess";
|
||||
}
|
||||
|
||||
void IpcServerProcess::start(const QString &program, const QStringList &arguments)
|
||||
{
|
||||
m_process->start(program, arguments);
|
||||
qDebug() << "IpcServerProcess started, " << arguments;
|
||||
//void IpcServerProcess::start(const QString &program, const QStringList &arguments)
|
||||
//{
|
||||
// m_process->start(program, arguments);
|
||||
// qDebug() << "IpcServerProcess started, " << arguments;
|
||||
|
||||
m_process->waitForStarted();
|
||||
}
|
||||
// m_process->waitForStarted();
|
||||
//}
|
||||
|
||||
void IpcServerProcess::start()
|
||||
{
|
||||
if (m_process->program().isEmpty()) {
|
||||
qDebug() << "IpcServerProcess failed to start, program is empty";
|
||||
}
|
||||
m_process->start();
|
||||
qDebug() << "IpcServerProcess started, " << m_process->program() << m_process->arguments();
|
||||
|
||||
|
@ -81,9 +85,9 @@ void IpcServerProcess::setProcessChannelMode(QProcess::ProcessChannelMode mode)
|
|||
m_process->setProcessChannelMode(mode);
|
||||
}
|
||||
|
||||
void IpcServerProcess::setProgram(const QString &program)
|
||||
void IpcServerProcess::setProgram(int programId)
|
||||
{
|
||||
m_process->setProgram(program);
|
||||
m_process->setProgram(amnezia::permittedProcessPath(static_cast<amnezia::PermittedProcess>(programId)));
|
||||
}
|
||||
|
||||
void IpcServerProcess::setWorkingDirectory(const QString &dir)
|
||||
|
|
|
@ -13,7 +13,7 @@ public:
|
|||
explicit IpcServerProcess(QObject *parent = nullptr);
|
||||
virtual ~IpcServerProcess();
|
||||
|
||||
void start(const QString &program, const QStringList &arguments) override;
|
||||
//void start(const QString &program, const QStringList &arguments) override;
|
||||
void start() override;
|
||||
void close() override;
|
||||
|
||||
|
@ -21,7 +21,7 @@ public:
|
|||
void setInputChannelMode(QProcess::InputChannelMode mode) override;
|
||||
void setNativeArguments(const QString &arguments) override;
|
||||
void setProcessChannelMode(QProcess::ProcessChannelMode mode) override;
|
||||
void setProgram(const QString &program) override;
|
||||
void setProgram(int programId) override;
|
||||
void setWorkingDirectory(const QString &dir) override;
|
||||
|
||||
QByteArray readAll() override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue