From e415fc62b02d416dae39f2d53765ca839abca419 Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Sat, 9 Dec 2023 21:37:47 -0600 Subject: Qt UI: Runner: Use specialised QProcess subclass This allows us to set the uid/gid in the executor process so that APK inherits full root, which prevents a weird error that causes APK Tools to write out all files as owned by the live user's GID when run under live media. --- ui/qt5/CMakeLists.txt | 1 + ui/qt5/runner/executepage.cc | 3 ++- ui/qt5/runner/executorprocess.cc | 20 ++++++++++++++++++++ ui/qt5/runner/executorprocess.hh | 25 +++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 ui/qt5/runner/executorprocess.cc create mode 100644 ui/qt5/runner/executorprocess.hh diff --git a/ui/qt5/CMakeLists.txt b/ui/qt5/CMakeLists.txt index 086abc7..74b9c68 100644 --- a/ui/qt5/CMakeLists.txt +++ b/ui/qt5/CMakeLists.txt @@ -44,6 +44,7 @@ set(RUN_QT_SOURCES horizonwizardpage.cc stepprogresswidget.cc runner/main.cc + runner/executorprocess.cc runner/executorwizard.cc runner/executepage.cc runner/errorpage.cc diff --git a/ui/qt5/runner/executepage.cc b/ui/qt5/runner/executepage.cc index 0d0980a..ce69c5e 100644 --- a/ui/qt5/runner/executepage.cc +++ b/ui/qt5/runner/executepage.cc @@ -13,6 +13,7 @@ #include "executepage.hh" #include "executorwizard.hh" +#include "executorprocess.hh" #include #include @@ -53,7 +54,7 @@ ExecutePage::ExecutePage(QWidget *parent) : HorizonWizardPage(parent) { this->current = Prepare; markRunning(this->current); - executor = new QProcess(this); + executor = new ExecutorProcess(this); executor->setProgram("hscript-executor"); connect(executor, &QProcess::readyReadStandardError, this, &ExecutePage::executorReady); diff --git a/ui/qt5/runner/executorprocess.cc b/ui/qt5/runner/executorprocess.cc new file mode 100644 index 0000000..1712fd9 --- /dev/null +++ b/ui/qt5/runner/executorprocess.cc @@ -0,0 +1,20 @@ +/* + * executorprocess.cc - Implementation of the QProcess class for the executor + * horizon-run-qt5, the Qt 5 executor user interface for + * Project Horizon + * + * Copyright (c) 2023 Adélie Linux and contributors. All rights reserved. + * This code is licensed under the AGPL 3.0 license, as noted in the + * LICENSE-code file in the root directory of this repository. + * + * SPDX-License-Identifier: AGPL-3.0-only + */ + +#include "executorprocess.hh" + +#include + +void ExecutorProcess::setupChildProcess() { + ::setuid(::geteuid()); + ::setgid(::getegid()); +} diff --git a/ui/qt5/runner/executorprocess.hh b/ui/qt5/runner/executorprocess.hh new file mode 100644 index 0000000..bec1d18 --- /dev/null +++ b/ui/qt5/runner/executorprocess.hh @@ -0,0 +1,25 @@ +/* + * executorprocess.hh - Definition of the QProcess class for the executor + * horizon-run-qt5, the Qt 5 executor user interface for + * Project Horizon + * + * Copyright (c) 2023 Adélie Linux and contributors. All rights reserved. + * This code is licensed under the AGPL 3.0 license, as noted in the + * LICENSE-code file in the root directory of this repository. + * + * SPDX-License-Identifier: AGPL-3.0-only + */ + +#ifndef EXECUTORPROCESS_HH +#define EXECUTORPROCESS_HH + +#include + +class ExecutorProcess : public QProcess { +public: + ExecutorProcess(QObject *parent = nullptr) : QProcess(parent) {}; +protected: + void setupChildProcess() override; +}; + +#endif /* !ERRORPAGE_HH */ -- cgit v1.2.3-60-g2f50