Lines 1-192
Link Here
|
1 |
From 72625a9dacfbd448ba7a84725d66bb2bfc9801f0 Mon Sep 17 00:00:00 2001 |
|
|
2 |
From: Eygene Ryabinkin <rea@codelabs.ru> |
3 |
Date: Wed, 20 May 2009 18:44:57 +0400 |
4 |
Subject: [PATCH] Do not specify magic cookie for xauth in the xauth command line |
5 |
|
6 |
Instead, open xauth as a pipe and feed commands via its stdin. |
7 |
|
8 |
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru> |
9 |
--- |
10 |
Makefile | 3 ++- |
11 |
Makefile.freebsd | 3 ++- |
12 |
Makefile.netbsd | 3 ++- |
13 |
Makefile.openbsd | 3 ++- |
14 |
app.cpp | 5 +++-- |
15 |
switchuser.cpp | 7 ++++--- |
16 |
util.cpp | 32 ++++++++++++++++++++++++++++++++ |
17 |
util.h | 19 +++++++++++++++++++ |
18 |
8 files changed, 66 insertions(+), 9 deletions(-) |
19 |
create mode 100644 util.cpp |
20 |
create mode 100644 util.h |
21 |
|
22 |
diff --git Makefile b/Makefile |
23 |
index f7d3d2d..240669d 100644 |
24 |
--- Makefile |
25 |
+++ Makefile |
26 |
@@ -25,7 +25,8 @@ VERSION=1.3.1 |
27 |
DEFINES=-DPACKAGE=\"$(NAME)\" -DVERSION=\"$(VERSION)\" \ |
28 |
-DPKGDATADIR=\"$(PREFIX)/share/slim\" -DSYSCONFDIR=\"$(CFGDIR)\" |
29 |
|
30 |
-OBJECTS=jpeg.o png.o main.o image.o numlock.o cfg.o switchuser.o app.o panel.o |
31 |
+OBJECTS=jpeg.o png.o main.o image.o numlock.o cfg.o switchuser.o app.o \ |
32 |
+ panel.o util.o |
33 |
ifdef USE_PAM |
34 |
OBJECTS+=PAM.o |
35 |
endif |
36 |
diff --git Makefile.freebsd b/Makefile.freebsd |
37 |
index 3ff326e..c925a39 100644 |
38 |
--- Makefile.freebsd |
39 |
+++ Makefile.freebsd |
40 |
@@ -24,7 +24,8 @@ VERSION=1.3.1 |
41 |
DEFINES=-DPACKAGE=\"$(NAME)\" -DVERSION=\"$(VERSION)\" \ |
42 |
-DPKGDATADIR=\"$(PREFIX)/share/slim\" -DSYSCONFDIR=\"$(CFGDIR)\" |
43 |
|
44 |
-OBJECTS=jpeg.o png.o main.o image.o numlock.o cfg.o switchuser.o app.o panel.o |
45 |
+OBJECTS=jpeg.o png.o main.o image.o numlock.o cfg.o switchuser.o app.o \ |
46 |
+ panel.o util.o |
47 |
.ifdef USE_PAM |
48 |
OBJECTS+=PAM.o |
49 |
.endif |
50 |
diff --git Makefile.netbsd b/Makefile.netbsd |
51 |
index ad8bb8b..45f33e6 100644 |
52 |
--- Makefile.netbsd |
53 |
+++ Makefile.netbsd |
54 |
@@ -24,7 +24,8 @@ VERSION=1.3.1 |
55 |
DEFINES=-DPACKAGE=\"$(NAME)\" -DVERSION=\"$(VERSION)\" \ |
56 |
-DPKGDATADIR=\"$(PREFIX)/share/slim\" -DSYSCONFDIR=\"$(CFGDIR)\" |
57 |
|
58 |
-OBJECTS=jpeg.o png.o main.o image.o numlock.o cfg.o switchuser.o app.o panel.o |
59 |
+OBJECTS=jpeg.o png.o main.o image.o numlock.o cfg.o switchuser.o app.o \ |
60 |
+ panel.o util.o |
61 |
.ifdef USE_PAM |
62 |
OBJECTS+=PAM.o |
63 |
.endif |
64 |
diff --git Makefile.openbsd b/Makefile.openbsd |
65 |
index b1829f8..1205b84 100644 |
66 |
--- Makefile.openbsd |
67 |
+++ Makefile.openbsd |
68 |
@@ -20,7 +20,8 @@ VERSION=1.3.1 |
69 |
DEFINES=-DPACKAGE=\"$(NAME)\" -DVERSION=\"$(VERSION)\" \ |
70 |
-DPKGDATADIR=\"$(PREFIX)/share/slim\" -DSYSCONFDIR=\"$(CFGDIR)\" |
71 |
|
72 |
-OBJECTS=jpeg.o png.o main.o image.o numlock.o cfg.o switchuser.o app.o panel.o |
73 |
+OBJECTS=jpeg.o png.o main.o image.o numlock.o cfg.o switchuser.o app.o \ |
74 |
+ util.o panel.o |
75 |
|
76 |
.SUFFIXES: .c.o .cpp.o |
77 |
|
78 |
diff --git app.cpp b/app.cpp |
79 |
index 83ae947..04caaa1 100644 |
80 |
--- app.cpp |
81 |
+++ app.cpp |
82 |
@@ -24,6 +24,7 @@ |
83 |
#include <algorithm> |
84 |
#include "app.h" |
85 |
#include "numlock.h" |
86 |
+#include "util.h" |
87 |
|
88 |
|
89 |
#ifdef HAVE_SHADOW |
90 |
@@ -1185,8 +1186,8 @@ void App::CreateServerAuth() { |
91 |
authfile = cfg->getOption("authfile"); |
92 |
remove(authfile.c_str()); |
93 |
putenv(StrConcat("XAUTHORITY=", authfile.c_str())); |
94 |
- cmd = cfg->getOption("xauth_path") + " -q -f " + authfile + " add :0 . " + mcookie; |
95 |
- system(cmd.c_str()); |
96 |
+ Util::add_mcookie(mcookie, ":0", cfg->getOption("xauth_path"), |
97 |
+ authfile); |
98 |
} |
99 |
|
100 |
char* App::StrConcat(const char* str1, const char* str2) { |
101 |
diff --git switchuser.cpp b/switchuser.cpp |
102 |
index e72a8fc..ec298e1 100644 |
103 |
--- switchuser.cpp |
104 |
+++ switchuser.cpp |
105 |
@@ -10,6 +10,7 @@ |
106 |
*/ |
107 |
|
108 |
#include "switchuser.h" |
109 |
+#include "util.h" |
110 |
|
111 |
using namespace std; |
112 |
|
113 |
@@ -53,10 +54,10 @@ void SwitchUser::Execute(const char* cmd) { |
114 |
} |
115 |
|
116 |
void SwitchUser::SetClientAuth(const char* mcookie) { |
117 |
- int r; |
118 |
+ bool r; |
119 |
string home = string(Pw->pw_dir); |
120 |
string authfile = home + "/.Xauthority"; |
121 |
remove(authfile.c_str()); |
122 |
- string cmd = cfg->getOption("xauth_path") + " -q -f " + authfile + " add :0 . " + mcookie; |
123 |
- r = system(cmd.c_str()); |
124 |
+ r = Util::add_mcookie(mcookie, ":0", cfg->getOption("xauth_path"), |
125 |
+ authfile); |
126 |
} |
127 |
diff --git util.cpp b/util.cpp |
128 |
new file mode 100644 |
129 |
index 0000000..309ce4f |
130 |
--- /dev/null |
131 |
+++ util.cpp |
132 |
@@ -0,0 +1,32 @@ |
133 |
+/* SLiM - Simple Login Manager |
134 |
+ Copyright (C) 2009 Eygene Ryabinkin <rea@codelabs.ru> |
135 |
+ |
136 |
+ This program is free software; you can redistribute it and/or modify |
137 |
+ it under the terms of the GNU General Public License as published by |
138 |
+ the Free Software Foundation; either version 2 of the License, or |
139 |
+ (at your option) any later version. |
140 |
+*/ |
141 |
+ |
142 |
+#include <stdio.h> |
143 |
+#include "util.h" |
144 |
+ |
145 |
+/* |
146 |
+ * Adds the given cookie to the specified Xauthority file. |
147 |
+ * Returns true on success, false on fault. |
148 |
+ */ |
149 |
+bool Util::add_mcookie(const std::string &mcookie, const char *display, |
150 |
+ const std::string &xauth_cmd, const std::string &authfile) |
151 |
+{ |
152 |
+ FILE *fp; |
153 |
+ std::string cmd = xauth_cmd + " -f " + authfile + " -q"; |
154 |
+ |
155 |
+ fp = popen(cmd.c_str(), "w"); |
156 |
+ if (!fp) |
157 |
+ return false; |
158 |
+ fprintf(fp, "remove %s\n", display); |
159 |
+ fprintf(fp, "add %s %s %s\n", display, ".", mcookie.c_str()); |
160 |
+ fprintf(fp, "exit\n"); |
161 |
+ |
162 |
+ pclose(fp); |
163 |
+ return true; |
164 |
+} |
165 |
diff --git util.h b/util.h |
166 |
new file mode 100644 |
167 |
index 0000000..8bd52be |
168 |
--- /dev/null |
169 |
+++ util.h |
170 |
@@ -0,0 +1,19 @@ |
171 |
+/* SLiM - Simple Login Manager |
172 |
+ Copyright (C) 2009 Eygene Ryabinkin <rea@codelabs.ru> |
173 |
+ |
174 |
+ This program is free software; you can redistribute it and/or modify |
175 |
+ it under the terms of the GNU General Public License as published by |
176 |
+ the Free Software Foundation; either version 2 of the License, or |
177 |
+ (at your option) any later version. |
178 |
+*/ |
179 |
+#ifndef __UTIL_H__ |
180 |
+#define __UTIL_H__ |
181 |
+ |
182 |
+#include <string> |
183 |
+ |
184 |
+namespace Util { |
185 |
+ bool add_mcookie(const std::string &mcookie, const char *display, |
186 |
+ const std::string &xauth_cmd, const std::string &authfile); |
187 |
+}; |
188 |
+ |
189 |
+#endif /* __UTIL_H__ */ |
190 |
-- |
191 |
1.6.3.1 |
192 |
|