Commit c05bb54b authored by Andrius Štikonas's avatar Andrius Štikonas
Browse files

Set "false" as the default return value and change it to "true" on success.

Please enter the commit message for your changes. Lines starting
parent fb1708b9
Pipeline #137954 passed with stage
in 1 minute and 8 seconds
......@@ -339,10 +339,9 @@ QVariantMap ExternalCommandHelper::RunCommand(const QString& command, const QStr
#endif
QVariantMap reply;
reply[QStringLiteral("success")] = true;
reply[QStringLiteral("success")] = false;
if (command.isEmpty()) {
reply[QStringLiteral("success")] = false;
return reply;
}
......@@ -350,7 +349,6 @@ QVariantMap ExternalCommandHelper::RunCommand(const QString& command, const QStr
QString basename = command.mid(command.lastIndexOf(QLatin1Char('/')) + 1);
if (allowedCommands.find(basename) == allowedCommands.end()) { // TODO: C++20: replace with contains
qInfo() << command <<" command is not one of the whitelisted command";
reply[QStringLiteral("success")] = false;
return reply;
}
......@@ -360,7 +358,6 @@ QVariantMap ExternalCommandHelper::RunCommand(const QString& command, const QStr
cmd.setEnvironment( { QStringLiteral("LVM_SUPPRESS_FD_WARNINGS=1") } );
if((processChannelMode != QProcess::SeparateChannels) && (processChannelMode != QProcess::MergedChannels)) {
reply[QStringLiteral("success")] = false;
return reply;
}
cmd.setProcessChannelMode(static_cast<QProcess::ProcessChannelMode>(processChannelMode));
......@@ -372,6 +369,7 @@ QVariantMap ExternalCommandHelper::RunCommand(const QString& command, const QStr
reply[QStringLiteral("output")] = output;
reply[QStringLiteral("exitCode")] = cmd.exitCode();
reply[QStringLiteral("success")] = true;
return reply;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment