patch post requested by Waldo

AlanE alane at geeksrus.net
Thu Dec 19 07:46:32 GMT 2002


The following patch has been confirmed to fix a kdesu-related bug in
arts. 

http://bugs.kde.org/show_bug.cgi?id=51381

This patch was against KDE 3.1-RC5.

==8<====8<====8<====8<====8<====8<====8<====8<====8<====8<==
--- mcop/mcoputils.cc.orig	Sat Feb  9 08:10:12 2002
+++ mcop/mcoputils.cc	Thu Dec 19 02:31:13 2002
@@ -31,6 +31,7 @@
 #include <errno.h>
 #include <config.h>
 #include <ctype.h>
+#include <pwd.h>	//included to get logname from uid
 #include <map>
 	
 using namespace std;
@@ -73,8 +74,18 @@
 
 string MCOPUtils::createFilePath(string name)
 {
+// changed to get logname from uid instead of environment variable
+// LOGNAME to avoid trouble when LOGNAME does not exist or
+// is wrong (such as in kdesu environment)
+// S. Voitzsch Sebastian.Voitzsch at web.de
+// 2002-12-03
+
+	struct passwd *pwd = NULL;
+	pwd = getpwuid(geteuid());
+	if (pwd == NULL) arts_fatal("could not get user name from user id");
+
 	string logname = "unknown";
-	if(getenv("LOGNAME")) logname = getenv("LOGNAME");
+	logname = pwd->pw_name;
 
 	string tmpdir = "/tmp/mcop-"+uglify(logname);
 	if(mkdir(tmpdir.c_str(),0700) != 0 && errno != EEXIST)
==8<====8<====8<====8<====8<====8<====8<====8<====8<====8<==

-- 
AlanE (Alan Eldridge), who likes fixing weird distributed systems bugs.
Unix/C(++) IT Pro for 20 yrs, desperately seeking employment in NYC.
(http://wwweasel.geeksrus.net/~alane/resume.rtf)
KDE, KDE-FreeBSD Teams (http://www.kde.org, http://freebsd.kde.org/)



More information about the kde-core-devel mailing list