mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-07-07 11:05:45 +00:00
add helper proto
This commit is contained in:
21
sources/3rdparty/task/taskadds.cpp
vendored
21
sources/3rdparty/task/taskadds.cpp
vendored
@ -19,15 +19,24 @@
|
||||
#include "taskadds.h"
|
||||
|
||||
|
||||
TaskResult runTask(const QString cmd)
|
||||
TaskResult runTask(const QString cmd, const bool sudo)
|
||||
{
|
||||
return Task::await<TaskResult>( [ & ]() {
|
||||
SandboxProcess command;
|
||||
command.start(cmd);
|
||||
command.waitForFinished(-1);
|
||||
TaskResult r;
|
||||
r.exitCode = command.exitCode();
|
||||
r.output = command.readAllStandardOutput();
|
||||
if (sudo) {
|
||||
QProcess command;
|
||||
command.start(cmd);
|
||||
command.waitForFinished(-1);
|
||||
r.exitCode = command.exitCode();
|
||||
r.output = command.readAllStandardOutput();
|
||||
}
|
||||
else {
|
||||
RootProcess command;
|
||||
command.start(cmd);
|
||||
command.waitForFinished(-1);
|
||||
r.exitCode = command.exitCode();
|
||||
r.output = command.readAllStandardOutput();
|
||||
}
|
||||
|
||||
return r;
|
||||
});
|
||||
|
6
sources/3rdparty/task/taskadds.h
vendored
6
sources/3rdparty/task/taskadds.h
vendored
@ -25,9 +25,9 @@
|
||||
#include "task.h"
|
||||
|
||||
|
||||
class SandboxProcess : public QProcess
|
||||
class RootProcess : public QProcess
|
||||
{
|
||||
protected:
|
||||
protected:
|
||||
void setupChildProcess()
|
||||
{
|
||||
::setuid(0);
|
||||
@ -40,7 +40,7 @@ struct TaskResult
|
||||
int exitCode;
|
||||
QByteArray output;
|
||||
};
|
||||
TaskResult runTask(const QString cmd);
|
||||
TaskResult runTask(const QString cmd, const bool sudo = false);
|
||||
|
||||
|
||||
#endif /* TASKADDS_H */
|
||||
|
Reference in New Issue
Block a user