1 |
--- mailman-2.1.7/configure.in.multimail 2005-08-27 03:40:15.000000000 +0200 |
2 |
+++ mailman-2.1.7/configure.in 2006-01-10 10:53:14.000000000 +0100 |
3 |
@@ -208,26 +208,101 @@ |
4 |
fi |
5 |
|
6 |
# new macro for finding group names |
7 |
-AC_DEFUN(MM_FIND_GROUP_NAME, [ |
8 |
+# returns a comma separated list of quoted group names |
9 |
+# the list is returned in the same order as specified with any duplicates removed |
10 |
+# the filter flag must be "yes" or "no", e.g. this is permcheck |
11 |
+# "no" ==> none existing groups are not filtered out |
12 |
+# "yes" ==> only those groups that are in the group database are included |
13 |
+# in the list |
14 |
+AC_DEFUN(MM_FIND_GROUP_LIST, [ |
15 |
# $1 == variable name |
16 |
-# $2 == user id to check for |
17 |
+# $2 == white space separated list of groups to check, |
18 |
+# list may contain mix of id's and names |
19 |
+# $3 == filter, if == 'yes' then remove any non-existing groups |
20 |
AC_SUBST($1) |
21 |
changequote(,) |
22 |
if test -z "$$1" |
23 |
then |
24 |
cat > conftest.py <<EOF |
25 |
import grp |
26 |
-gid = '' |
27 |
+group_names = [] |
28 |
+seen = {} |
29 |
+filter = "$3" |
30 |
+ |
31 |
for group in "$2".split(): |
32 |
try: |
33 |
+ gid = int(group) |
34 |
+ try: |
35 |
+ gname = grp.getgrgid(gid)[0] |
36 |
+ except KeyError: |
37 |
+ gname = '' |
38 |
+ except ValueError: |
39 |
try: |
40 |
- gname = grp.getgrgid(int(group))[0] |
41 |
- break |
42 |
- except ValueError: |
43 |
gname = grp.getgrnam(group)[0] |
44 |
+ except KeyError: |
45 |
+ if filter == "yes": |
46 |
+ gname = '' |
47 |
+ else: |
48 |
+ gname = group |
49 |
+ if gname: |
50 |
+ if gname not in seen: |
51 |
+ seen[gname] = 1 |
52 |
+ group_names.append(gname) |
53 |
+ |
54 |
+if group_names: |
55 |
+ val = '"' + '", "'.join(group_names) + '"' |
56 |
+ #val = "'"+val+"'" |
57 |
+else: |
58 |
+ val = '' |
59 |
+ |
60 |
+fp = open("conftest.out", "w") |
61 |
+fp.write("%s\n" % val) |
62 |
+fp.close() |
63 |
+EOF |
64 |
+ $PYTHON conftest.py |
65 |
+ $1=`cat conftest.out` |
66 |
+fi |
67 |
+changequote([, ]) |
68 |
+rm -f conftest.out conftest.py]) |
69 |
+ |
70 |
+ |
71 |
+# new macro for finding group names |
72 |
+AC_DEFUN(MM_FIND_GROUP_NAME, [ |
73 |
+# Given a list of tokens, either a name or a number (gid) |
74 |
+# return the first one in the list that is found in the |
75 |
+# group database. The return value is always a name, possibly |
76 |
+# translated from a gid. If permcheck is "no" then the group |
77 |
+# database is not checked, instead the first token in the list |
78 |
+# which is a name is returned (e.g. the default value). If permcheck |
79 |
+# is no and only gid's are in the list then the null string is returned. |
80 |
+# $1 == variable name |
81 |
+# $2 == group id to check for |
82 |
+# $3 == permcheck, either "yes" or "no" |
83 |
+AC_SUBST($1) |
84 |
+changequote(,) |
85 |
+if test -z "$$1" |
86 |
+then |
87 |
+ cat > conftest.py <<EOF |
88 |
+import grp |
89 |
+gname='' |
90 |
+if "$3" == "yes": |
91 |
+ for group in "$2".split(): |
92 |
+ try: |
93 |
+ try: |
94 |
+ gname = grp.getgrgid(int(group))[0] |
95 |
+ break |
96 |
+ except ValueError: |
97 |
+ gname = grp.getgrnam(group)[0] |
98 |
+ break |
99 |
+ except KeyError: |
100 |
+ gname = '' |
101 |
+else: |
102 |
+ for group in "$2".split(): |
103 |
+ try: |
104 |
+ int(group) |
105 |
+ except ValueError: |
106 |
+ gname = group |
107 |
break |
108 |
- except KeyError: |
109 |
- gname = '' |
110 |
fp = open("conftest.out", "w") |
111 |
fp.write("%s\n" % gname) |
112 |
fp.close() |
113 |
@@ -241,25 +316,41 @@ |
114 |
|
115 |
# new macro for finding UIDs |
116 |
AC_DEFUN(MM_FIND_USER_NAME, [ |
117 |
+# Given a list of tokens, either a name or a number (uid) |
118 |
+# return the first one in the list that is found in the |
119 |
+# password database. The return value is always a name, possibly |
120 |
+# translated from a uid. If permcheck is "no" then the password |
121 |
+# database is not checked, instead the first token in the list |
122 |
+# which is a name is returned (e.g. the default value). If permcheck |
123 |
+# is no and only uid's are in the list then the null string is returned. |
124 |
# $1 == variable name |
125 |
# $2 == user id to check for |
126 |
+# $3 == permcheck, either "yes" or "no" |
127 |
AC_SUBST($1) |
128 |
changequote(,) |
129 |
if test -z "$$1" |
130 |
then |
131 |
cat > conftest.py <<EOF |
132 |
import pwd |
133 |
-uid = '' |
134 |
-for user in "$2".split(): |
135 |
- try: |
136 |
+uname='' |
137 |
+if "$3" == "yes": |
138 |
+ for user in "$2".split(): |
139 |
try: |
140 |
- uname = pwd.getpwuid(int(user))[0] |
141 |
- break |
142 |
+ try: |
143 |
+ uname = pwd.getpwuid(int(user))[0] |
144 |
+ break |
145 |
+ except ValueError: |
146 |
+ uname = pwd.getpwnam(user)[0] |
147 |
+ break |
148 |
+ except KeyError: |
149 |
+ uname = '' |
150 |
+else: |
151 |
+ for user in "$2".split(): |
152 |
+ try: |
153 |
+ int(user) |
154 |
except ValueError: |
155 |
- uname = pwd.getpwnam(user)[0] |
156 |
+ uname = user |
157 |
break |
158 |
- except KeyError: |
159 |
- uname = '' |
160 |
fp = open("conftest.out", "w") |
161 |
fp.write("%s\n" % uname) |
162 |
fp.close() |
163 |
@@ -285,7 +376,7 @@ |
164 |
# User `mailman' must exist |
165 |
AC_SUBST(MAILMAN_USER) |
166 |
AC_MSG_CHECKING(for user name \"$USERNAME\") |
167 |
-MM_FIND_USER_NAME(MAILMAN_USER, $USERNAME) |
168 |
+MM_FIND_USER_NAME(MAILMAN_USER, $USERNAME, $with_permcheck) |
169 |
if test -z "$MAILMAN_USER" |
170 |
then |
171 |
if test "$with_permcheck" = "yes" |
172 |
@@ -316,7 +407,7 @@ |
173 |
# Target group must exist |
174 |
AC_SUBST(MAILMAN_GROUP) |
175 |
AC_MSG_CHECKING(for group name \"$GROUPNAME\") |
176 |
-MM_FIND_GROUP_NAME(MAILMAN_GROUP, $GROUPNAME) |
177 |
+MM_FIND_GROUP_NAME(MAILMAN_GROUP, $GROUPNAME, $with_permcheck) |
178 |
if test -z "$MAILMAN_GROUP" |
179 |
then |
180 |
if test "$with_permcheck" = "yes" |
181 |
@@ -339,11 +430,11 @@ |
182 |
prefix = "$prefixcheck" |
183 |
groupname = "$GROUPNAME" |
184 |
mailmangroup = "$MAILMAN_GROUP" |
185 |
-try: |
186 |
- mailmangid = grp.getgrnam(mailmangroup)[2] |
187 |
-except KeyError: |
188 |
- mailmangid = -1 |
189 |
problems = [] |
190 |
+try: mailmangid = grp.getgrnam(mailmangroup)[2] |
191 |
+except KeyError: |
192 |
+ problems.append("group doesn't exist: " + mailmangroup) |
193 |
+ mailmangid = 41 |
194 |
try: statdata = os.stat(prefix) |
195 |
except OSError: |
196 |
problems.append("Directory doesn't exist: " + prefix) |
197 |
@@ -393,7 +484,7 @@ |
198 |
then |
199 |
with_mail_gid="mailman other mail daemon" |
200 |
fi |
201 |
-MM_FIND_GROUP_NAME(MAIL_GROUP, $with_mail_gid) |
202 |
+MM_FIND_GROUP_LIST(MAIL_GROUP, $with_mail_gid, $with_permcheck) |
203 |
if test -z "$MAIL_GROUP" |
204 |
then |
205 |
if test "$with_permcheck" = "yes" |
206 |
@@ -420,7 +511,7 @@ |
207 |
with_cgi_gid="www www-data nobody" |
208 |
fi |
209 |
|
210 |
-MM_FIND_GROUP_NAME(CGI_GROUP, $with_cgi_gid) |
211 |
+MM_FIND_GROUP_LIST(CGI_GROUP, $with_cgi_gid, $with_permcheck) |
212 |
if test -z "$CGI_GROUP" |
213 |
then |
214 |
if test "$with_permcheck" = "yes" |
215 |
--- mailman-2.1.7/src/Makefile.in.multimail 2005-08-27 03:40:17.000000000 +0200 |
216 |
+++ mailman-2.1.7/src/Makefile.in 2006-01-10 10:53:14.000000000 +0100 |
217 |
@@ -49,9 +49,9 @@ |
218 |
|
219 |
SHELL= /bin/sh |
220 |
|
221 |
-MAIL_FLAGS= -DMAIL_GROUP="\"$(MAIL_GROUP)\"" |
222 |
+MAIL_FLAGS= -DMAIL_GROUP='$(MAIL_GROUP)' |
223 |
|
224 |
-CGI_FLAGS= -DCGI_GROUP="\"$(CGI_GROUP)\"" |
225 |
+CGI_FLAGS= -DCGI_GROUP='$(CGI_GROUP)' |
226 |
|
227 |
HELPFUL= -DHELPFUL |
228 |
|
229 |
--- mailman-2.1.7/src/common.h.multimail 2005-08-27 03:40:17.000000000 +0200 |
230 |
+++ mailman-2.1.7/src/common.h 2006-01-10 10:53:14.000000000 +0100 |
231 |
@@ -33,7 +33,7 @@ |
232 |
#define GID_T GETGROUPS_T |
233 |
|
234 |
extern void fatal(const char*, int, char*, ...); |
235 |
-extern void check_caller(const char*, const char*); |
236 |
+extern void check_caller(const char* ident, const char**, size_t); |
237 |
extern int run_script(const char*, int, char**, char**); |
238 |
|
239 |
/* Global variable used as a flag. */ |
240 |
@@ -51,7 +51,7 @@ |
241 |
#define MAIL_USAGE_ERROR 5 |
242 |
#define MAIL_ILLEGAL_COMMAND 6 |
243 |
#define ADDALIAS_USAGE_ERROR 7 |
244 |
-#define GROUP_NAME_NOT_FOUND 8 |
245 |
+#define GROUP_ID_NOT_FOUND 8 |
246 |
|
247 |
|
248 |
/* |
249 |
--- mailman-2.1.7/src/cgi-wrapper.c.multimail 2005-08-27 03:40:17.000000000 +0200 |
250 |
+++ mailman-2.1.7/src/cgi-wrapper.c 2006-01-10 10:53:14.000000000 +0100 |
251 |
@@ -28,11 +28,11 @@ |
252 |
/* Group name that CGI scripts run as. See your web server's documentation |
253 |
* for details. |
254 |
*/ |
255 |
-#define LEGAL_PARENT_GROUP CGI_GROUP |
256 |
+#define LEGAL_PARENT_GROUPS CGI_GROUP |
257 |
|
258 |
const char* logident = LOG_IDENT; |
259 |
char* script = SCRIPTNAME; |
260 |
-const char* parentgroup = LEGAL_PARENT_GROUP; |
261 |
+const char* parentgroups[] = {LEGAL_PARENT_GROUPS}; |
262 |
|
263 |
|
264 |
int |
265 |
@@ -42,7 +42,7 @@ |
266 |
char* fake_argv[3]; |
267 |
|
268 |
running_as_cgi = 1; |
269 |
- check_caller(logident, parentgroup); |
270 |
+ check_caller(logident, parentgroups, sizeof(parentgroups) / sizeof(parentgroups[0])); |
271 |
|
272 |
/* For these CGI programs, we can ignore argc and argv since they |
273 |
* don't contain anything useful. `script' will always be the driver |
274 |
--- mailman-2.1.7/src/common.c.multimail 2005-12-30 19:50:08.000000000 +0100 |
275 |
+++ mailman-2.1.7/src/common.c 2006-01-10 11:01:43.000000000 +0100 |
276 |
@@ -117,13 +117,14 @@ |
277 |
/* Is the parent process allowed to call us? |
278 |
*/ |
279 |
void |
280 |
-check_caller(const char* ident, const char* parentgroup) |
281 |
+check_caller(const char* ident, const char** parentgroups, size_t numgroups) |
282 |
{ |
283 |
GID_T mygid = getgid(); |
284 |
struct group *mygroup = getgrgid(mygid); |
285 |
char* option; |
286 |
char* server; |
287 |
char* wrapper; |
288 |
+ int i; |
289 |
|
290 |
if (running_as_cgi) { |
291 |
option = "--with-cgi-gid"; |
292 |
@@ -136,28 +137,46 @@ |
293 |
wrapper = "mail"; |
294 |
} |
295 |
|
296 |
- if (!mygroup) |
297 |
- fatal(ident, GROUP_NAME_NOT_FOUND, |
298 |
- "Failure to find group name for GID %d. Mailman\n" |
299 |
- "expected the %s wrapper to be executed as group\n" |
300 |
- "\"%s\", but the system's %s server executed the\n" |
301 |
- "wrapper as GID %d for which the name could not be\n" |
302 |
- "found. Try adding GID %d to your system as \"%s\",\n" |
303 |
- "or tweak your %s server to run the wrapper as group\n" |
304 |
- "\"%s\".", |
305 |
- mygid, wrapper, parentgroup, server, mygid, mygid, |
306 |
- parentgroup, server, parentgroup); |
307 |
+ if (!mygroup) |
308 |
+ fatal(ident, GROUP_ID_NOT_FOUND, |
309 |
+ "Failure to lookup via getgrgid() the group info for group id %d that this Mailman %s wrapper is executing under.\n" |
310 |
+ "This is probably due to an incorrectly configured system and is not a Mailman problem", |
311 |
+ mygid, wrapper); |
312 |
+ |
313 |
+ for (i = 0; i < numgroups; i++) { |
314 |
+ if (strcmp(parentgroups[i], mygroup->gr_name) == 0) break; |
315 |
+ } |
316 |
+ |
317 |
+ if (i >= numgroups) { |
318 |
+ char *groupset = NULL; |
319 |
+ size_t size = 0; |
320 |
+ |
321 |
+ for (i = 0; i < numgroups; i++) { |
322 |
+ size += strlen(parentgroups[i]) + 2; |
323 |
+ } |
324 |
+ |
325 |
+ groupset = malloc(size); |
326 |
+ |
327 |
+ if (groupset) { |
328 |
+ groupset[0] = 0; |
329 |
+ for (i = 0; i < numgroups; i++) { |
330 |
+ strcat(groupset, parentgroups[i]); |
331 |
+ if (i < numgroups-1) strcat(groupset, ", "); |
332 |
+ } |
333 |
+ } |
334 |
|
335 |
- if (strcmp(parentgroup, mygroup->gr_name)) |
336 |
fatal(ident, GROUP_MISMATCH, |
337 |
- "Group mismatch error. Mailman expected the %s\n" |
338 |
- "wrapper script to be executed as group \"%s\", but\n" |
339 |
- "the system's %s server executed the %s script as\n" |
340 |
- "group \"%s\". Try tweaking the %s server to run the\n" |
341 |
- "script as group \"%s\", or re-run configure, \n" |
342 |
- "providing the command line option `%s=%s'.", |
343 |
- wrapper, parentgroup, server, wrapper, mygroup->gr_name, |
344 |
- server, parentgroup, option, mygroup->gr_name); |
345 |
+ "Group mismatch error. Mailman expected the %s wrapper script to be\n" |
346 |
+ "executed as one of the following groups:\n" |
347 |
+ "[%s],\n" |
348 |
+ "but the system's %s server executed the %s script as group: \"%s\".\n" |
349 |
+ "Try tweaking the %s server to run the script as one of these groups:\n" |
350 |
+ "[%s],\n" |
351 |
+ "or re-run configure providing the command line option:\n" |
352 |
+ "'%s=%s'.", |
353 |
+ wrapper, groupset, server, wrapper, mygroup->gr_name, |
354 |
+ server, groupset, option, mygroup->gr_name); |
355 |
+ } |
356 |
} |
357 |
|
358 |
|
359 |
--- mailman-2.1.7/src/mail-wrapper.c.multimail 2005-08-27 03:40:17.000000000 +0200 |
360 |
+++ mailman-2.1.7/src/mail-wrapper.c 2006-01-10 10:53:14.000000000 +0100 |
361 |
@@ -23,9 +23,9 @@ |
362 |
/* Group name that your mail programs run as. See your mail server's |
363 |
* documentation for details. |
364 |
*/ |
365 |
-#define LEGAL_PARENT_GROUP MAIL_GROUP |
366 |
+#define LEGAL_PARENT_GROUPS MAIL_GROUP |
367 |
|
368 |
-const char* parentgroup = LEGAL_PARENT_GROUP; |
369 |
+const char* parentgroups[] = {LEGAL_PARENT_GROUPS}; |
370 |
const char* logident = "Mailman mail-wrapper"; |
371 |
|
372 |
|
373 |
@@ -74,7 +74,7 @@ |
374 |
fatal(logident, MAIL_ILLEGAL_COMMAND, |
375 |
"Illegal command: %s", argv[1]); |
376 |
|
377 |
- check_caller(logident, parentgroup); |
378 |
+ check_caller(logident, parentgroups, sizeof(parentgroups) / sizeof(parentgroups[0])); |
379 |
|
380 |
/* If we got here, everything must be OK */ |
381 |
status = run_script(argv[1], argc, argv, env); |