debconf-kde: fix TPH #212, pass home to prevent requests.

This commit is contained in:
Ark74 2025-06-02 19:11:21 -06:00
parent 52ff0938c4
commit 0416f8a1b7
2 changed files with 61 additions and 0 deletions

View file

@ -0,0 +1,33 @@
diff --git a/tools/main.cpp b/tools/main.cpp
index 813aba5a..5f91e057 100644
--- a/tools/main.cpp
+++ b/tools/main.cpp
@@ -37,6 +37,8 @@
#include <DebconfGui.h>
+#include <pwd.h>
+
using namespace DebconfKde;
// Handle SIGQUIT. Clients (e.g. packagekit) may use QUIT which would otherwise
@@ -73,6 +76,19 @@ static void setupQuitHandler() {
int main(int argc, char **argv)
{
+ /* TPH: #212 | LP: #1851573 — When the helper is started through pkexec/aptdaemon
+ * the environment may arrive without $HOME. Without HOME, KConfig writes
+ * to "//.config/..." and shows a "not writable" dialog for every debconf
+ * question. Substitute the passwd entrys home directory.
+ */
+ const char *homeEnv = getenv("HOME");
+ if (!homeEnv || homeEnv[0] == '\0') {
+ struct passwd *pw = getpwuid(getuid());
+ if (pw && pw->pw_dir) {
+ setenv("HOME", pw->pw_dir, /* overwrite = */ 1);
+ }
+ }
+
QApplication app(argc, argv);
setupQuitHandler();

28
helpers/make-debconf-kde Normal file
View file

@ -0,0 +1,28 @@
#!/bin/sh
#
# Copyright (C) 2025 Luis Guzmán <ark@switnet.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
VERSION=1
. ./config
apply_patch_changes
changelog "Patch package to pass HOME to prevent dialog for every request."
package