From 176173b60c4611941566a87db438c1ff377a1c83 Mon Sep 17 00:00:00 2001 From: "Andreas K. Huettel (dilfridge)" Date: Sun, 21 Jul 2013 16:44:20 +0200 Subject: [PATCH] Make sure HOME is never unset, to prevent creation of files in / BUG: 249217 REVIEW: 110655 --- kdecore/auth/kauthhelpersupport.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/kdecore/auth/kauthhelpersupport.cpp b/kdecore/auth/kauthhelpersupport.cpp index 41b673b..f99b64d 100644 --- a/kdecore/auth/kauthhelpersupport.cpp +++ b/kdecore/auth/kauthhelpersupport.cpp @@ -23,6 +23,12 @@ #include #include +#ifdef Q_OS_UNIX +#include +#include +#include +#endif + #include #include @@ -40,8 +46,27 @@ void helperDebugHandler(QtMsgType type, const char *msg); static bool remote_dbg = false; +#ifdef Q_OS_UNIX +static void fixEnvironment() +{ + //try correct HOME + char *home = "HOME"; + if(getenv(home)==NULL) + { + struct passwd *pw = getpwuid(getuid()); + int overwrite = 0; + + if (pw!=NULL) setenv(home, pw->pw_dir, overwrite); + } +} +#endif + int HelperSupport::helperMain(int argc, char **argv, const char *id, QObject *responder) { +#ifdef Q_OS_UNIX + fixEnvironment(); +#endif + openlog(id, 0, LOG_USER); qInstallMsgHandler(&HelperSupport::helperDebugHandler); -- 1.8.3.2