* @brief Set the executable path for Launch mode. */
| 124 | * @brief Set the executable path for Launch mode. |
| 125 | */ |
| 126 | API::CommandResponse API::Handlers::ProcessHandler::setExecutable(const QString& id, |
| 127 | const QJsonObject& params) |
| 128 | { |
| 129 | if (!params.contains(QStringLiteral("executable"))) { |
| 130 | return CommandResponse::makeError( |
| 131 | id, ErrorCode::MissingParam, QStringLiteral("Missing required parameter: executable")); |
| 132 | } |
| 133 | |
| 134 | const QString path = params.value(QStringLiteral("executable")).toString(); |
| 135 | |
| 136 | if (!API::isPathAllowed(path)) |
| 137 | return CommandResponse::makeError( |
| 138 | id, ErrorCode::InvalidParam, QStringLiteral("Path is not allowed: ") + path); |
| 139 | |
| 140 | IO::ConnectionManager::instance().process()->setExecutable(path); |
| 141 | |
| 142 | QJsonObject result; |
| 143 | result[QStringLiteral("executable")] = path; |
| 144 | return CommandResponse::makeSuccess(id, result); |
| 145 | } |
| 146 | |
| 147 | /** |
| 148 | * @brief Set the command-line arguments for Launch mode. |