KStandardDirs vs $HOME

Oswald Buddenhagen ossi at kde.org
Sun Nov 23 03:29:14 GMT 2003


moin,

i think kstddirs is overzealous in regard to setting root's kde home
correctly.
using KDEROOTHOME instead of KDEHOME makes perfect sense: an unthoughful
command in a "su" shell and your permissions are screwed.
but explicitly looking up root's home directory instead of simply using
$HOME is definitely too much. there is simply no "natural" scenario
where $HOME is incorrectly set - it is to be expected, that such a
manipulation was done on purpose. of course i'm doing that in kdm (i
simply have to exploit all border cases :), and the attached patch would
be the cleanest solution.

ok to commit?

greetings

-- 
Hi! I'm a .signature virus! Copy me into your ~/.signature, please!
--
Chaos, panic, and disorder - my work here is done.
-------------- next part --------------
Index: kstandarddirs.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdecore/kstandarddirs.cpp,v
retrieving revision 1.167
diff -U2 -r1.167 kstandarddirs.cpp
--- kstandarddirs.cpp	28 Oct 2003 13:02:11 -0000	1.167
+++ kstandarddirs.cpp	23 Nov 2003 03:16:17 -0000
@@ -1048,34 +1048,15 @@
 #endif
 
-    QString localKdeDir;
-    if (getuid())
+    // We treat root different to prevent root messing up the
+    // file permissions in the users home directory.
+    QString localKdeDir = getuid() ? readEnvPath("KDEHOME") : readEnvPath("KDEROOTHOME");
+    if (!localKdeDir.isEmpty())
     {
-       localKdeDir = readEnvPath("KDEHOME");
-       if (!localKdeDir.isEmpty())
-       {
-          if (localKdeDir[localKdeDir.length()-1] != '/')
-             localKdeDir += '/';
-       }
-       else
-       {
-          localKdeDir =  QDir::homeDirPath() + "/.kde/";
-       }
+       if (localKdeDir[localKdeDir.length()-1] != '/')
+          localKdeDir += '/';
     }
     else
     {
-       // We treat root different to prevent root messing up the
-       // file permissions in the users home directory.
-       localKdeDir = readEnvPath("KDEROOTHOME");
-       if (!localKdeDir.isEmpty())
-       {
-          if (localKdeDir[localKdeDir.length()-1] != '/')
-             localKdeDir += '/';
-       }
-       else
-       {
-          struct passwd *pw = getpwuid(0);
-          localKdeDir =  QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root")  + "/.kde/";
-       }
-
+       localKdeDir =  QDir::homeDirPath() + "/.kde/";
     }
 


More information about the kde-core-devel mailing list