23c1e9460e
x11/slim, does not setlogin(). Some software use getlogin() to decide the user name, so when user is using slim as the login manager, those software would get wrong results, and some programs refuse to start (Seen with opencvs some times ago, reminded by a discution with zinovik and theo and setlogin hint from guenter) ok maintainer & dcoppa@
35 lines
1.1 KiB
Plaintext
35 lines
1.1 KiB
Plaintext
$OpenBSD: patch-switchuser_cpp,v 1.2 2010/07/10 10:46:52 armani Exp $
|
|
--- switchuser.cpp.orig Fri Sep 26 02:54:15 2008
|
|
+++ switchuser.cpp Fri Jul 9 22:23:47 2010
|
|
@@ -10,7 +10,7 @@
|
|
*/
|
|
|
|
#include "switchuser.h"
|
|
-
|
|
+#include "app.h"
|
|
using namespace std;
|
|
|
|
SwitchUser::SwitchUser(struct passwd *pw, Cfg *c, const string& display,
|
|
@@ -37,6 +37,8 @@ void SwitchUser::Login(const char* cmd, const char* mc
|
|
|
|
void SwitchUser::SetUserId() {
|
|
if( (Pw == 0) ||
|
|
+ (setsid() == -1) ||
|
|
+ (setlogin(Pw->pw_name) != 0) ||
|
|
(initgroups(Pw->pw_name, Pw->pw_gid) != 0) ||
|
|
(setgid(Pw->pw_gid) != 0) ||
|
|
(setuid(Pw->pw_uid) != 0) ) {
|
|
@@ -53,10 +55,9 @@ void SwitchUser::Execute(const char* cmd) {
|
|
}
|
|
|
|
void SwitchUser::SetClientAuth(const char* mcookie) {
|
|
- int r;
|
|
+ bool r;
|
|
string home = string(Pw->pw_dir);
|
|
string authfile = home + "/.Xauthority";
|
|
remove(authfile.c_str());
|
|
- string cmd = cfg->getOption("xauth_path") + " -q -f " + authfile + " add :0 . " + mcookie;
|
|
- r = system(cmd.c_str());
|
|
+ r = Util::add_mcookie(mcookie, ":0", cfg->getOption("xauth_path"), authfile);
|
|
}
|