Fix support for QProcess::ProcessChannelMode.
This commit is contained in:
parent
e761c131d0
commit
e5b63b0d6f
|
@ -54,6 +54,7 @@ struct ExternalCommandPrivate
|
|||
QByteArray m_Output;
|
||||
QByteArray m_Input;
|
||||
DBusThread *m_thread;
|
||||
QProcess::ProcessChannelMode processChannelMode;
|
||||
};
|
||||
|
||||
unsigned int ExternalCommand::counter = 0;
|
||||
|
@ -81,7 +82,7 @@ ExternalCommand::ExternalCommand(const QString& cmd, const QStringList& args, co
|
|||
if(!startHelper())
|
||||
Log(Log::Level::error) << xi18nc("@info:status", "Could not obtain administrator privileges.");
|
||||
|
||||
setup(processChannelMode);
|
||||
d->processChannelMode = processChannelMode;
|
||||
}
|
||||
|
||||
/** Creates a new ExternalCommand instance with Report.
|
||||
|
@ -98,20 +99,18 @@ ExternalCommand::ExternalCommand(Report& report, const QString& cmd, const QStri
|
|||
d->m_ExitCode = -1;
|
||||
d->m_Output = QByteArray();
|
||||
|
||||
setup(processChannelMode);
|
||||
d->processChannelMode = processChannelMode;
|
||||
}
|
||||
|
||||
ExternalCommand::~ExternalCommand()
|
||||
{
|
||||
}
|
||||
|
||||
void ExternalCommand::setup(const QProcess::ProcessChannelMode processChannelMode)
|
||||
{
|
||||
// d->arguments.insert(QStringLiteral("processChannelMode"), processChannelMode); // FIXME
|
||||
|
||||
// void ExternalCommand::setup()
|
||||
// {
|
||||
// connect(this, qOverload<int, QProcess::ExitStatus>(&QProcess::finished), this, &ExternalCommand::onFinished);
|
||||
// connect(this, &ExternalCommand::readyReadStandardOutput, this, &ExternalCommand::onReadOutput);
|
||||
}
|
||||
// }
|
||||
|
||||
/** Executes the external command.
|
||||
@param timeout timeout to wait for the process to start
|
||||
|
@ -150,6 +149,7 @@ bool ExternalCommand::start(int timeout)
|
|||
for (const auto &argument : qAsConst(d->m_Args))
|
||||
request.append(argument.toUtf8());
|
||||
request.append(d->m_Input);
|
||||
request.append(d->processChannelMode);
|
||||
|
||||
QByteArray hash = QCryptographicHash::hash(request, QCryptographicHash::Sha512);
|
||||
|
||||
|
@ -157,7 +157,8 @@ bool ExternalCommand::start(int timeout)
|
|||
privateKey->signMessage(hash, QCA::EMSA3_Raw),
|
||||
cmd,
|
||||
args(),
|
||||
d->m_Input);
|
||||
d->m_Input,
|
||||
d->processChannelMode);
|
||||
|
||||
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pcall, this);
|
||||
|
||||
|
|
|
@ -126,7 +126,6 @@ public Q_SLOTS:
|
|||
|
||||
private:
|
||||
void setExitCode(int i);
|
||||
void setup(const QProcess::ProcessChannelMode processChannelMode);
|
||||
|
||||
void onFinished(int exitCode, QProcess::ExitStatus exitStatus);
|
||||
void onReadOutput();
|
||||
|
|
|
@ -244,7 +244,7 @@ bool ExternalCommandHelper::copyblocks(const QByteArray& signature, const QStrin
|
|||
return rval;
|
||||
}
|
||||
|
||||
QVariantMap ExternalCommandHelper::start(const QByteArray& signature, const QString& command, const QStringList& arguments, const QByteArray& input)
|
||||
QVariantMap ExternalCommandHelper::start(const QByteArray& signature, const QString& command, const QStringList& arguments, const QByteArray& input, const int processChannelMode)
|
||||
{
|
||||
QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
|
||||
QVariantMap reply;
|
||||
|
@ -255,6 +255,7 @@ QVariantMap ExternalCommandHelper::start(const QByteArray& signature, const QStr
|
|||
for (const auto &argument : arguments)
|
||||
request.append(argument.toUtf8());
|
||||
request.append(input);
|
||||
request.append(processChannelMode);
|
||||
QByteArray hash = QCryptographicHash::hash(request, QCryptographicHash::Sha512);
|
||||
if (!m_publicKey.verifyMessage(hash, signature, QCA::EMSA3_Raw)) {
|
||||
qCritical() << xi18n("Invalid cryptographic signature");
|
||||
|
@ -265,6 +266,7 @@ QVariantMap ExternalCommandHelper::start(const QByteArray& signature, const QStr
|
|||
// connect(&cmd, &QProcess::readyReadStandardOutput, this, &ExternalCommandHelper::onReadOutput);
|
||||
|
||||
m_cmd.setEnvironment( { QStringLiteral("LVM_SUPPRESS_FD_WARNINGS=1") } );
|
||||
m_cmd.setProcessChannelMode(static_cast<QProcess::ProcessChannelMode>(processChannelMode));
|
||||
m_cmd.start(command, arguments);
|
||||
m_cmd.write(input);
|
||||
m_cmd.closeWriteChannel();
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
|
||||
public Q_SLOTS:
|
||||
ActionReply init(const QVariantMap& args);
|
||||
Q_SCRIPTABLE QVariantMap start(const QByteArray& signature, const QString& command, const QStringList& arguments, const QByteArray& input);
|
||||
Q_SCRIPTABLE QVariantMap start(const QByteArray& signature, const QString& command, const QStringList& arguments, const QByteArray& input, const int processChannelMode);
|
||||
Q_SCRIPTABLE bool copyblocks(const QByteArray& signature, const QString& sourceDevice, const qint64 sourceFirstByte, const qint64 sourceLength, const QString& targetDevice, const qint64 targetFirstByte, const qint64 blockSize);
|
||||
Q_SCRIPTABLE void exit(const QByteArray& signature);
|
||||
|
||||
|
|
Loading…
Reference in New Issue