summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2023-12-09 21:37:47 -0600
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2023-12-09 21:37:47 -0600
commite415fc62b02d416dae39f2d53765ca839abca419 (patch)
tree83e56661e87462a387e075b69e678d4c05d67a2b
parent9f971cc0aedae6c89052bedc684245fc8c893cdf (diff)
downloadhorizon-e415fc62b02d416dae39f2d53765ca839abca419.tar.gz
horizon-e415fc62b02d416dae39f2d53765ca839abca419.tar.bz2
horizon-e415fc62b02d416dae39f2d53765ca839abca419.tar.xz
horizon-e415fc62b02d416dae39f2d53765ca839abca419.zip
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.
-rw-r--r--ui/qt5/CMakeLists.txt1
-rw-r--r--ui/qt5/runner/executepage.cc3
-rw-r--r--ui/qt5/runner/executorprocess.cc20
-rw-r--r--ui/qt5/runner/executorprocess.hh25
4 files changed, 48 insertions, 1 deletions
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 <QAbstractButton>
#include <QGridLayout>
@@ -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 <unistd.h>
+
+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 <QProcess>
+
+class ExecutorProcess : public QProcess {
+public:
+ ExecutorProcess(QObject *parent = nullptr) : QProcess(parent) {};
+protected:
+ void setupChildProcess() override;
+};
+
+#endif /* !ERRORPAGE_HH */