Blob Blame History Raw
Index: slim-1.3.1/switchuser.cpp
===================================================================
--- slim-1.3.1.orig/switchuser.cpp
+++ slim-1.3.1/switchuser.cpp
@@ -54,10 +54,8 @@ void SwitchUser::Execute(const char* cmd
 }
 
 void SwitchUser::SetClientAuth(const char* mcookie) {
-    bool r;
     string home = string(Pw->pw_dir);
     string authfile = home + "/.Xauthority";
-    remove(authfile.c_str());
-    r = Util::add_mcookie(mcookie, ":0", cfg->getOption("xauth_path"),
-      authfile);
+    string cmd = cfg->getOption("xauth_path") + " -q -f " + authfile + " add :0 . " + mcookie;
+    system(cmd.c_str());
 }
Index: slim-1.3.1/app.cpp
===================================================================
--- slim-1.3.1.orig/app.cpp
+++ slim-1.3.1/app.cpp
@@ -1190,8 +1190,8 @@ void App::CreateServerAuth() {
     authfile = cfg->getOption("authfile");
     remove(authfile.c_str());
     putenv(StrConcat("XAUTHORITY=", authfile.c_str()));
-    Util::add_mcookie(mcookie, ":0", cfg->getOption("xauth_path"),
-      authfile);
+    string cmd = cfg->getOption("xauth_path") + " -q -f " + authfile + " add :0 . " + mcookie;
+    system(cmd.c_str());
 }
 
 char* App::StrConcat(const char* str1, const char* str2) {
Index: slim-1.3.1/util.cpp
===================================================================
--- slim-1.3.1.orig/util.cpp
+++ slim-1.3.1/util.cpp
@@ -17,27 +17,6 @@
 #include "util.h"
 
 /*
- * Adds the given cookie to the specified Xauthority file.
- * Returns true on success, false on fault.
- */
-bool Util::add_mcookie(const std::string &mcookie, const char *display,
-    const std::string &xauth_cmd, const std::string &authfile)
-{
-	FILE *fp;
-	std::string cmd = xauth_cmd + " -f " + authfile + " -q";
-
-	fp = popen(cmd.c_str(), "w");
-	if (!fp)
-		return false;
-	fprintf(fp, "remove %s\n", display);
-	fprintf(fp, "add %s %s %s\n", display, ".", mcookie.c_str());
-	fprintf(fp, "exit\n");
-
-	pclose(fp);
-	return true;
-}
-
-/*
  * Interface for random number generator.  Just now it uses ordinary
  * random/srandom routines and serves as a wrapper for them.
  */