rev |
line source |
meillo@367
|
1 /*
|
meillo@367
|
2 ** MasqMail
|
meillo@367
|
3 ** Copyright (C) 1999-2001 Oliver Kurth
|
meillo@367
|
4 ** Copyright (C) 2010 markus schnalke <meillo@marmaro.de>
|
meillo@367
|
5 **
|
meillo@367
|
6 ** This program is free software; you can redistribute it and/or modify
|
meillo@367
|
7 ** it under the terms of the GNU General Public License as published by
|
meillo@367
|
8 ** the Free Software Foundation; either version 2 of the License, or
|
meillo@367
|
9 ** (at your option) any later version.
|
meillo@367
|
10 **
|
meillo@367
|
11 ** This program is distributed in the hope that it will be useful,
|
meillo@367
|
12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
meillo@367
|
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
meillo@367
|
14 ** GNU General Public License for more details.
|
meillo@367
|
15 **
|
meillo@367
|
16 ** You should have received a copy of the GNU General Public License
|
meillo@367
|
17 ** along with this program; if not, write to the Free Software
|
meillo@367
|
18 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
meillo@0
|
19 */
|
meillo@0
|
20
|
meillo@13
|
21 #include <pwd.h>
|
meillo@13
|
22 #include <grp.h>
|
meillo@13
|
23
|
meillo@0
|
24 #include "masqmail.h"
|
meillo@0
|
25
|
meillo@0
|
26 masqmail_conf conf;
|
meillo@0
|
27
|
meillo@10
|
28 void
|
meillo@10
|
29 init_conf()
|
meillo@0
|
30 {
|
meillo@10
|
31 struct passwd *passwd;
|
meillo@10
|
32 struct group *group;
|
meillo@0
|
33
|
meillo@392
|
34 if (!(passwd = getpwnam(DEF_MAIL_USER))) {
|
meillo@392
|
35 fprintf(stderr, "user %s not found! (terminating)\n",
|
meillo@392
|
36 DEF_MAIL_USER);
|
meillo@392
|
37 exit(1);
|
meillo@392
|
38 }
|
meillo@392
|
39 if (!(group = getgrnam(DEF_MAIL_GROUP))) {
|
meillo@392
|
40 fprintf(stderr, "group %s not found! (terminating)\n",
|
meillo@392
|
41 DEF_MAIL_GROUP);
|
meillo@392
|
42 exit(1);
|
meillo@392
|
43 }
|
meillo@10
|
44 memset(&conf, 0, sizeof(masqmail_conf));
|
meillo@10
|
45 conf.orig_uid = getuid();
|
meillo@10
|
46 conf.orig_gid = getgid();
|
meillo@392
|
47 conf.mail_uid = passwd->pw_uid;
|
meillo@392
|
48 conf.mail_gid = group->gr_gid;
|
meillo@0
|
49 }
|
meillo@0
|
50
|
meillo@366
|
51 static gchar *true_strings[] = {
|
meillo@10
|
52 "yes", "on", "true", NULL
|
meillo@0
|
53 };
|
meillo@0
|
54
|
meillo@10
|
55 static gchar *false_strings[] = {
|
meillo@10
|
56 "no", "off", "false", NULL
|
meillo@0
|
57 };
|
meillo@0
|
58
|
meillo@10
|
59 static gboolean
|
meillo@366
|
60 parse_boolean(gchar *rval)
|
meillo@0
|
61 {
|
meillo@10
|
62 gchar **str;
|
meillo@0
|
63
|
meillo@333
|
64 DEBUG(9) fprintf(stderr, "parse_boolean: %s\n", rval);
|
meillo@392
|
65 for (str = true_strings; *str; str++) {
|
meillo@392
|
66 if (strncasecmp(*str, rval, strlen(*str))==0) {
|
meillo@10
|
67 return TRUE;
|
meillo@392
|
68 }
|
meillo@10
|
69 }
|
meillo@392
|
70 for (str = false_strings; *str; str++) {
|
meillo@392
|
71 if (strncasecmp(*str, rval, strlen(*str))==0) {
|
meillo@10
|
72 return FALSE;
|
meillo@392
|
73 }
|
meillo@10
|
74 }
|
meillo@10
|
75 fprintf(stderr, "cannot parse value '%s'\n", rval);
|
meillo@262
|
76 exit(1);
|
meillo@0
|
77 }
|
meillo@0
|
78
|
meillo@392
|
79 /*
|
meillo@392
|
80 ** make a list from the lines of a file
|
meillo@392
|
81 */
|
meillo@10
|
82 static GList*
|
meillo@392
|
83 parse_list_file(const gchar *fname)
|
meillo@0
|
84 {
|
meillo@10
|
85 GList *list = NULL;
|
meillo@10
|
86 FILE *fptr;
|
meillo@392
|
87 gchar buf[256];
|
meillo@0
|
88
|
meillo@392
|
89 if (!(fptr = fopen(fname, "rt"))) {
|
meillo@392
|
90 logwrite(LOG_ALERT, "could not open %s for reading: %s\n",
|
meillo@392
|
91 fname, strerror(errno));
|
meillo@262
|
92 exit(1);
|
meillo@10
|
93 }
|
meillo@392
|
94 while (!fgets(buf, sizeof buf, fptr)) {
|
meillo@392
|
95 g_strstrip(buf);
|
meillo@392
|
96 if (!*buf || *buf == '#') {
|
meillo@392
|
97 continue;
|
meillo@28
|
98 }
|
meillo@392
|
99 DEBUG(9) fprintf(stderr, "parse_list_file: item = %s\n", buf);
|
meillo@392
|
100 list = g_list_append(list, g_strdup(buf));
|
meillo@28
|
101 }
|
meillo@28
|
102 fclose(fptr);
|
meillo@28
|
103
|
meillo@10
|
104 return list;
|
meillo@0
|
105 }
|
meillo@0
|
106
|
meillo@392
|
107 /*
|
meillo@392
|
108 ** given a semicolon separated string, this function makes a GList out of it.
|
meillo@392
|
109 */
|
meillo@392
|
110 static GList*
|
meillo@366
|
111 parse_list(gchar *line, gboolean read_file)
|
meillo@0
|
112 {
|
meillo@10
|
113 GList *list = NULL;
|
meillo@392
|
114 gchar *tok;
|
meillo@0
|
115
|
meillo@392
|
116 DEBUG(9) fprintf(stderr, "parsing list %s, file?:%d\n",
|
meillo@392
|
117 line, read_file);
|
meillo@392
|
118 for (tok = strtok(strdup(line), ";"); tok; tok = strtok(NULL, ";")) {
|
meillo@392
|
119 DEBUG(9) fprintf(stderr, "item = %s\n", tok);
|
meillo@392
|
120 if (read_file && *tok == '/') {
|
meillo@10
|
121 /* item is a filename, include its contents */
|
meillo@392
|
122 list = g_list_concat(list, parse_list_file(tok));
|
meillo@392
|
123 } else {
|
meillo@10
|
124 /* just a normal item */
|
meillo@392
|
125 list = g_list_append(list, g_strdup(tok));
|
meillo@392
|
126 }
|
meillo@10
|
127 }
|
meillo@10
|
128 return list;
|
meillo@0
|
129 }
|
meillo@0
|
130
|
meillo@367
|
131 /*
|
meillo@367
|
132 ** Split the addrs at '@' into local_part and domain. Without an '@'
|
meillo@392
|
133 ** everything is local_part. Create and return a list of address structs.
|
meillo@392
|
134 ** This funktion is used for lists of addrs containing globbing chars
|
meillo@392
|
135 ** (* and ?). We don't need valid RFC821 addresses here, just patterns
|
meillo@392
|
136 ** to match against.
|
meillo@317
|
137 */
|
meillo@10
|
138 static GList*
|
meillo@392
|
139 parse_address_glob_list(gchar *line)
|
meillo@0
|
140 {
|
meillo@392
|
141 GList *plain_list = parse_list(line, TRUE);
|
meillo@10
|
142 GList *node;
|
meillo@10
|
143 GList *list = NULL;
|
meillo@0
|
144
|
meillo@10
|
145 foreach(plain_list, node) {
|
meillo@10
|
146 gchar *item = (gchar *) (node->data);
|
meillo@366
|
147 char *at;
|
meillo@366
|
148 char *p;
|
meillo@317
|
149 address *addr = calloc(1, sizeof(address));
|
meillo@317
|
150
|
meillo@317
|
151 for (p=item+strlen(item)-1; isspace(*p) || *p=='>'; p--) {
|
meillo@317
|
152 *p = '\0';
|
meillo@317
|
153 }
|
meillo@317
|
154 for (p=item; isspace(*p) || *p=='<'; p++) {
|
meillo@317
|
155 }
|
meillo@317
|
156
|
meillo@317
|
157 addr->address = strdup(p);
|
meillo@317
|
158 at = strrchr(p, '@');
|
meillo@317
|
159 if (at) {
|
meillo@317
|
160 *at = '\0';
|
meillo@317
|
161 addr->local_part = strdup(p);
|
meillo@317
|
162 addr->domain = strdup(at+1);
|
meillo@317
|
163 } else {
|
meillo@317
|
164 addr->local_part = strdup(p);
|
meillo@330
|
165 /* No `@', thus any domain is okay. */
|
meillo@330
|
166 addr->domain = "*";
|
meillo@317
|
167 }
|
meillo@317
|
168 list = g_list_append(list, addr);
|
meillo@392
|
169 DEBUG(6) debugf("parse_address_glob_list: "
|
meillo@392
|
170 "read pattern `%s' `%s'\n",
|
meillo@317
|
171 addr->local_part, addr->domain);
|
meillo@10
|
172 g_free(item);
|
meillo@10
|
173 }
|
meillo@10
|
174 g_list_free(plain_list);
|
meillo@10
|
175 return list;
|
meillo@0
|
176 }
|
meillo@0
|
177
|
meillo@10
|
178 static GList*
|
meillo@366
|
179 parse_resolve_list(gchar *line)
|
meillo@0
|
180 {
|
meillo@10
|
181 GList *list;
|
meillo@10
|
182 GList *list_node;
|
meillo@10
|
183 GList *res_list = NULL;
|
meillo@392
|
184 gchar *item;
|
meillo@0
|
185
|
meillo@392
|
186 list = parse_list(line, TRUE);
|
meillo@28
|
187 if (!list) {
|
meillo@28
|
188 return NULL;
|
meillo@28
|
189 }
|
meillo@28
|
190 foreach(list, list_node) {
|
meillo@392
|
191 item = (gchar *) list_node->data;
|
meillo@392
|
192 if (strcmp(item, "byname")==0) {
|
meillo@28
|
193 res_list = g_list_append(res_list, resolve_byname);
|
meillo@0
|
194 #ifdef ENABLE_RESOLVER
|
meillo@392
|
195 } else if (strcmp(item, "dns_a")==0) {
|
meillo@28
|
196 res_list = g_list_append(res_list, resolve_dns_a);
|
meillo@392
|
197 } else if (strcmp(item, "dns_mx")==0) {
|
meillo@28
|
198 res_list = g_list_append(res_list, resolve_dns_mx);
|
meillo@0
|
199 #endif
|
meillo@28
|
200 } else {
|
meillo@28
|
201 logwrite(LOG_ALERT, "unknown resolver %s\n", item);
|
meillo@262
|
202 exit(1);
|
meillo@10
|
203 }
|
meillo@28
|
204 g_free(item);
|
meillo@10
|
205 }
|
meillo@28
|
206 g_list_free(list);
|
meillo@10
|
207 return res_list;
|
meillo@0
|
208 }
|
meillo@0
|
209
|
meillo@10
|
210 static interface*
|
meillo@366
|
211 parse_interface(gchar *line, gint def_port)
|
meillo@0
|
212 {
|
meillo@392
|
213 gchar *cp;
|
meillo@392
|
214 interface *iface = g_malloc(sizeof(interface));
|
meillo@0
|
215
|
meillo@333
|
216 DEBUG(9) fprintf(stderr, "parse_interface: %s\n", line);
|
meillo@392
|
217 if ((cp = strchr(line, ':'))) {
|
meillo@392
|
218 *cp = '\0';
|
meillo@392
|
219 }
|
meillo@392
|
220 iface->address = g_strdup(line);
|
meillo@392
|
221 iface->port = (cp) ? atoi(++cp) : def_port;
|
meillo@392
|
222 DEBUG(9) fprintf(stderr,"found: address:port=%s:%u\n",
|
meillo@392
|
223 iface->address, iface->port);
|
meillo@10
|
224 return iface;
|
meillo@0
|
225 }
|
meillo@0
|
226
|
meillo@10
|
227 static gboolean
|
meillo@366
|
228 eat_comments(FILE *in)
|
meillo@0
|
229 {
|
meillo@10
|
230 gint c;
|
meillo@392
|
231 int incomment = 0;
|
meillo@0
|
232
|
meillo@392
|
233 while ((c = fgetc(in)) != EOF) {
|
meillo@392
|
234 if (incomment) {
|
meillo@392
|
235 /* eat until end of line */
|
meillo@392
|
236 if (c == '\n') {
|
meillo@392
|
237 incomment = 0;
|
meillo@392
|
238 continue;
|
meillo@392
|
239 } else {
|
meillo@392
|
240 continue;
|
meillo@392
|
241 }
|
meillo@392
|
242 } else {
|
meillo@392
|
243 /* eat whitespace and watch for comments */
|
meillo@392
|
244 if (isspace(c)) {
|
meillo@392
|
245 continue;
|
meillo@392
|
246 } else if (c == '#') {
|
meillo@392
|
247 incomment = 1;
|
meillo@392
|
248 continue;
|
meillo@392
|
249 } else {
|
meillo@392
|
250 /* found something (that's not our business) */
|
meillo@392
|
251 ungetc(c, in);
|
meillo@392
|
252 return TRUE;
|
meillo@392
|
253 }
|
meillo@10
|
254 }
|
meillo@10
|
255 }
|
meillo@392
|
256 return FALSE;
|
meillo@0
|
257 }
|
meillo@0
|
258
|
meillo@10
|
259 static gboolean
|
meillo@366
|
260 eat_spaces(FILE *in)
|
meillo@0
|
261 {
|
meillo@10
|
262 gint c;
|
meillo@10
|
263
|
meillo@392
|
264 while ((c = fgetc(in)) != EOF) {
|
meillo@392
|
265 if (!isspace(c)) {
|
meillo@392
|
266 ungetc(c, in);
|
meillo@392
|
267 return TRUE;
|
meillo@392
|
268 }
|
meillo@28
|
269 }
|
meillo@392
|
270 return FALSE;
|
meillo@0
|
271 }
|
meillo@0
|
272
|
meillo@10
|
273 static gboolean
|
meillo@366
|
274 read_lval(FILE *in, gchar *buf, gint size)
|
meillo@0
|
275 {
|
meillo@10
|
276 gint c;
|
meillo@10
|
277 gchar *ptr = buf;
|
meillo@0
|
278
|
meillo@333
|
279 DEBUG(9) fprintf(stderr, "read_lval()\n");
|
meillo@392
|
280 if (!eat_spaces(in)) {
|
meillo@10
|
281 return FALSE;
|
meillo@392
|
282 }
|
meillo@0
|
283
|
meillo@333
|
284 DEBUG(9) fprintf(stderr, "read_lval() 2\n");
|
meillo@392
|
285 while (1) {
|
meillo@392
|
286 if ((c = fgetc(in)) == EOF) {
|
meillo@392
|
287 fprintf(stderr, "unexpected EOF after %s\n", buf);
|
meillo@392
|
288 return FALSE;
|
meillo@392
|
289 }
|
meillo@392
|
290 if (ptr >= buf+size-1) {
|
meillo@392
|
291 fprintf(stderr, "lval too long\n");
|
meillo@392
|
292 break;
|
meillo@392
|
293 }
|
meillo@392
|
294 if (!isalnum(c) && c != '_' && c != '-' && c != '.') {
|
meillo@392
|
295 break;
|
meillo@392
|
296 }
|
meillo@392
|
297 *ptr++ = c;
|
meillo@10
|
298 }
|
meillo@14
|
299 *ptr = '\0';
|
meillo@10
|
300 ungetc(c, in);
|
meillo@10
|
301 eat_spaces(in);
|
meillo@333
|
302 DEBUG(9) fprintf(stderr, "lval = %s\n", buf);
|
meillo@392
|
303 return *buf != '\0';
|
meillo@0
|
304 }
|
meillo@0
|
305
|
meillo@10
|
306 static gboolean
|
meillo@366
|
307 read_rval(FILE *in, gchar *buf, gint size)
|
meillo@0
|
308 {
|
meillo@10
|
309 gint c;
|
meillo@10
|
310 gchar *ptr = buf;
|
meillo@0
|
311
|
meillo@333
|
312 DEBUG(9) fprintf(stderr, "read_rval()\n");
|
meillo@392
|
313 if (!eat_spaces(in)) {
|
meillo@10
|
314 return FALSE;
|
meillo@392
|
315 }
|
meillo@10
|
316
|
meillo@10
|
317 c = fgetc(in);
|
meillo@394
|
318 if (c != '"') {
|
meillo@394
|
319 /* unquoted rval */
|
meillo@394
|
320 ungetc(c, in);
|
meillo@394
|
321 while ((c = fgetc(in)) != EOF) {
|
meillo@394
|
322 if (ptr >= buf+size-1) {
|
meillo@394
|
323 /* rval too long */
|
meillo@394
|
324 break;
|
meillo@394
|
325 }
|
meillo@394
|
326 if (!isalnum(c) && c != '_' && c != '-' &&
|
meillo@394
|
327 c != '.' && c != '/' && c != '@' &&
|
meillo@394
|
328 c != ';' && c != ':') {
|
meillo@394
|
329 break;
|
meillo@394
|
330 }
|
meillo@394
|
331 *ptr++ = c;
|
meillo@10
|
332 }
|
meillo@14
|
333 *ptr = '\0';
|
meillo@10
|
334 ungetc(c, in);
|
meillo@10
|
335 } else {
|
meillo@394
|
336 /* quoted rval */
|
meillo@10
|
337 gboolean escape = FALSE;
|
meillo@394
|
338 while ((c = fgetc(in)) != EOF) {
|
meillo@394
|
339 if (ptr >= buf+size-1) {
|
meillo@394
|
340 /* rval too long */
|
meillo@394
|
341 break;
|
meillo@10
|
342 }
|
meillo@394
|
343 if (!escape && c == '"') {
|
meillo@394
|
344 break;
|
meillo@394
|
345 }
|
meillo@394
|
346 if (!escape && c == '\\') {
|
meillo@394
|
347 escape = TRUE;
|
meillo@394
|
348 continue;
|
meillo@394
|
349 }
|
meillo@394
|
350 *ptr++ = c;
|
meillo@394
|
351 escape = FALSE;
|
meillo@10
|
352 }
|
meillo@14
|
353 *ptr = '\0';
|
meillo@0
|
354 }
|
meillo@333
|
355 DEBUG(9) fprintf(stderr, "rval = %s\n", buf);
|
meillo@394
|
356 /* eat trailing of line */
|
meillo@394
|
357 while ((c = fgetc(in)) != EOF && c != '\n') {
|
meillo@394
|
358 continue;
|
meillo@394
|
359 }
|
meillo@10
|
360
|
meillo@10
|
361 return TRUE;
|
meillo@0
|
362 }
|
meillo@0
|
363
|
meillo@10
|
364 static gboolean
|
meillo@366
|
365 read_statement(FILE *in, gchar *lval, gint lsize, gchar *rval, gint rsize)
|
meillo@0
|
366 {
|
meillo@10
|
367 gint c;
|
meillo@0
|
368
|
meillo@333
|
369 DEBUG(9) fprintf(stderr, "read_statement()\n");
|
meillo@0
|
370
|
meillo@10
|
371 /* eat comments and empty lines: */
|
meillo@393
|
372 if (!eat_comments(in)) {
|
meillo@10
|
373 return FALSE;
|
meillo@393
|
374 }
|
meillo@28
|
375 if (!read_lval(in, lval, lsize)) {
|
meillo@28
|
376 return FALSE;
|
meillo@28
|
377 }
|
meillo@28
|
378
|
meillo@333
|
379 DEBUG(9) fprintf(stderr, " lval = %s\n", lval);
|
meillo@393
|
380 if ((c = fgetc(in) != '=')) {
|
meillo@393
|
381 fprintf(stderr, "'=' expected after %s, char was '%c'\n",
|
meillo@393
|
382 lval, c);
|
meillo@10
|
383 }
|
meillo@393
|
384 if (!read_rval(in, rval, rsize)) {
|
meillo@393
|
385 return FALSE;
|
meillo@393
|
386 }
|
meillo@393
|
387 DEBUG(9) fprintf(stderr, " rval = %s\n", rval);
|
meillo@393
|
388 return TRUE;
|
meillo@0
|
389 }
|
meillo@0
|
390
|
meillo@10
|
391 gboolean
|
meillo@366
|
392 read_conf(gchar *filename)
|
meillo@0
|
393 {
|
meillo@10
|
394 FILE *in;
|
meillo@393
|
395 gchar lval[256], rval[2048];
|
meillo@393
|
396 GList *listen_addrs_tmp = NULL;
|
meillo@0
|
397
|
meillo@10
|
398 conf.do_relay = TRUE;
|
meillo@244
|
399 conf.localpartcmp = strcmp;
|
meillo@10
|
400 conf.max_defer_time = 86400 * 4; /* 4 days */
|
meillo@120
|
401 conf.max_msg_size = 0; /* no limit on msg size */
|
meillo@151
|
402 conf.spool_dir = SPOOL_DIR;
|
meillo@152
|
403 conf.mail_dir = "/var/mail";
|
meillo@0
|
404
|
meillo@393
|
405 if (!(in = fopen(filename, "r"))) {
|
meillo@393
|
406 logwrite(LOG_ALERT, "could not open config file %s: %s\n",
|
meillo@393
|
407 filename, strerror(errno));
|
meillo@28
|
408 return FALSE;
|
meillo@28
|
409 }
|
meillo@28
|
410
|
meillo@392
|
411 while (read_statement(in, lval, sizeof lval, rval, sizeof rval)) {
|
meillo@333
|
412 DEBUG(9) fprintf(stderr,"read_conf(): lval=%s\n", lval);
|
meillo@393
|
413 if (strcmp(lval, "debug_level")==0) {
|
meillo@28
|
414 conf.debug_level = atoi(rval);
|
meillo@393
|
415 } else if (strcmp(lval, "run_as_user")==0) {
|
meillo@393
|
416 if (!conf.run_as_user) {
|
meillo@393
|
417 /* you should not be able to reset that flag */
|
meillo@28
|
418 conf.run_as_user = parse_boolean(rval);
|
meillo@393
|
419 }
|
meillo@393
|
420 } else if (strcmp(lval, "use_syslog")==0) {
|
meillo@28
|
421 conf.use_syslog = parse_boolean(rval);
|
meillo@393
|
422 } else if (strcmp(lval, "mail_dir")==0) {
|
meillo@28
|
423 conf.mail_dir = g_strdup(rval);
|
meillo@393
|
424 } else if (strcmp(lval, "lock_dir")==0) {
|
meillo@28
|
425 conf.lock_dir = g_strdup(rval);
|
meillo@393
|
426 } else if (strcmp(lval, "spool_dir")==0) {
|
meillo@28
|
427 conf.spool_dir = g_strdup(rval);
|
meillo@393
|
428 } else if (strcmp(lval, "log_dir")==0) {
|
meillo@28
|
429 conf.log_dir = g_strdup(rval);
|
meillo@393
|
430 } else if (strcmp(lval, "host_name")==0) {
|
meillo@393
|
431 if (rval[0] != '/') {
|
meillo@28
|
432 conf.host_name = g_strdup(rval);
|
meillo@393
|
433 } else {
|
meillo@28
|
434 char buf[256];
|
meillo@28
|
435 FILE *fptr = fopen(rval, "rt");
|
meillo@307
|
436 if (!fptr) {
|
meillo@393
|
437 logwrite(LOG_ALERT, "could not open "
|
meillo@393
|
438 "%s: %s\n", rval,
|
meillo@393
|
439 strerror(errno));
|
meillo@28
|
440 return FALSE;
|
meillo@10
|
441 }
|
meillo@393
|
442 fgets(buf, sizeof buf, fptr);
|
meillo@393
|
443 g_strstrip(buf);
|
meillo@28
|
444 conf.host_name = g_strdup(buf);
|
meillo@28
|
445 fclose(fptr);
|
meillo@28
|
446 }
|
meillo@393
|
447 } else if (strcmp(lval, "local_hosts")==0) {
|
meillo@392
|
448 conf.local_hosts = parse_list(rval, TRUE);
|
meillo@393
|
449 } else if (strcmp(lval, "local_addresses")==0) {
|
meillo@28
|
450 conf.local_addresses = parse_list(rval, TRUE);
|
meillo@393
|
451 } else if (strcmp(lval, "not_local_addresses")==0) {
|
meillo@28
|
452 conf.not_local_addresses = parse_list(rval, TRUE);
|
meillo@393
|
453 } else if (strcmp(lval, "do_save_envelope_to")==0) {
|
meillo@28
|
454 conf.do_save_envelope_to = parse_boolean(rval);
|
meillo@393
|
455 } else if (strcmp(lval, "defer_all")==0) {
|
meillo@28
|
456 conf.defer_all = parse_boolean(rval);
|
meillo@393
|
457 } else if (strcmp(lval, "do_relay")==0) {
|
meillo@28
|
458 conf.do_relay = parse_boolean(rval);
|
meillo@393
|
459 } else if (strcmp(lval, "alias_file")==0) {
|
meillo@28
|
460 conf.alias_file = g_strdup(rval);
|
meillo@393
|
461 } else if (strcmp(lval, "globalias_file")==0) {
|
meillo@387
|
462 conf.globalias_file = g_strdup(rval);
|
meillo@393
|
463 } else if (strcmp(lval, "caseless_matching")==0) {
|
meillo@393
|
464 conf.localpartcmp = parse_boolean(rval) ?
|
meillo@393
|
465 strcasecmp : strcmp;
|
meillo@393
|
466 } else if (strcmp(lval, "mbox_default")==0) {
|
meillo@28
|
467 conf.mbox_default = g_strdup(rval);
|
meillo@393
|
468 } else if (strcmp(lval, "mbox_users")==0) {
|
meillo@28
|
469 conf.mbox_users = parse_list(rval, TRUE);
|
meillo@393
|
470 } else if (strcmp(lval, "mda_users")==0) {
|
meillo@28
|
471 conf.mda_users = parse_list(rval, TRUE);
|
meillo@393
|
472 } else if (strcmp(lval, "mda")==0) {
|
meillo@28
|
473 conf.mda = g_strdup(rval);
|
meillo@393
|
474 } else if (strcmp(lval, "mda_fromline")==0) {
|
meillo@28
|
475 conf.mda_fromline = parse_boolean(rval);
|
meillo@393
|
476 } else if (strcmp(lval, "mda_fromhack")==0) {
|
meillo@28
|
477 conf.mda_fromhack = parse_boolean(rval);
|
meillo@393
|
478 } else if (strcmp(lval, "pipe_fromline")==0) {
|
meillo@28
|
479 conf.pipe_fromline = parse_boolean(rval);
|
meillo@393
|
480 } else if (strcmp(lval, "pipe_fromhack")==0) {
|
meillo@28
|
481 conf.pipe_fromhack = parse_boolean(rval);
|
meillo@393
|
482 } else if (strcmp(lval, "listen_addresses")==0) {
|
meillo@393
|
483 listen_addrs_tmp = parse_list(rval, TRUE);
|
meillo@393
|
484 } else if (strncmp(lval, "query_routes.", 13)==0) {
|
meillo@28
|
485 GList *file_list = parse_list(rval, FALSE);
|
meillo@354
|
486 table_pair *pair = create_pair(lval+13, file_list);
|
meillo@393
|
487 conf.query_routes = g_list_append(conf.query_routes,
|
meillo@393
|
488 pair);
|
meillo@393
|
489 } else if (strcmp(lval, "permanent_routes")==0) {
|
meillo@354
|
490 conf.perma_routes = parse_list(rval, FALSE);
|
meillo@393
|
491 } else if (strcmp(lval, "online_query")==0) {
|
meillo@310
|
492 conf.online_query = g_strdup(rval);
|
meillo@393
|
493 } else if (strcmp(lval, "do_queue")==0) {
|
meillo@28
|
494 conf.do_queue = parse_boolean(rval);
|
meillo@393
|
495 } else if (strcmp(lval, "errmsg_file")==0) {
|
meillo@28
|
496 conf.errmsg_file = g_strdup(rval);
|
meillo@393
|
497 } else if (strcmp(lval, "warnmsg_file")==0) {
|
meillo@28
|
498 conf.warnmsg_file = g_strdup(rval);
|
meillo@393
|
499 } else if (strcmp(lval, "warn_intervals")==0) {
|
meillo@392
|
500 conf.warn_intervals = parse_list(rval, TRUE);
|
meillo@393
|
501 } else if (strcmp(lval, "max_defer_time")==0) {
|
meillo@254
|
502 gint ival = time_interval(rval);
|
meillo@393
|
503 if (ival < 0) {
|
meillo@393
|
504 logwrite(LOG_WARNING, "invalid time interval "
|
meillo@393
|
505 "for 'max_defer_time': %s\n",
|
meillo@393
|
506 rval);
|
meillo@393
|
507 } else {
|
meillo@28
|
508 conf.max_defer_time = ival;
|
meillo@393
|
509 }
|
meillo@393
|
510 } else if (strcmp(lval, "log_user")==0) {
|
meillo@28
|
511 conf.log_user = g_strdup(rval);
|
meillo@393
|
512 } else if(strcmp(lval, "max_msg_size")==0) {
|
meillo@117
|
513 conf.max_msg_size = atol(rval);
|
meillo@393
|
514 DEBUG(9) fprintf(stderr,
|
meillo@393
|
515 "rval=%s, conf.max_msg_size=%ld\n",
|
meillo@117
|
516 rval, conf.max_msg_size);
|
meillo@393
|
517 } else {
|
meillo@393
|
518 logwrite(LOG_WARNING, "var '%s' unknown: ignored\n",
|
meillo@393
|
519 lval);
|
meillo@117
|
520 }
|
meillo@28
|
521 }
|
meillo@28
|
522 fclose(in);
|
meillo@0
|
523
|
meillo@156
|
524 if (!conf.host_name) {
|
meillo@393
|
525 logwrite(LOG_ALERT, "`host_name' MUST be set in "
|
meillo@393
|
526 "masqmail.conf. See man page\n");
|
meillo@156
|
527 return FALSE;
|
meillo@156
|
528 }
|
meillo@393
|
529 if (!conf.errmsg_file) {
|
meillo@28
|
530 conf.errmsg_file = g_strdup(DATA_DIR "/tpl/failmsg.tpl");
|
meillo@393
|
531 }
|
meillo@393
|
532 if (!conf.warnmsg_file) {
|
meillo@28
|
533 conf.warnmsg_file = g_strdup(DATA_DIR "/tpl/warnmsg.tpl");
|
meillo@393
|
534 }
|
meillo@393
|
535 if (!conf.lock_dir) {
|
meillo@28
|
536 conf.lock_dir = g_strdup_printf("%s/lock/", conf.spool_dir);
|
meillo@393
|
537 }
|
meillo@393
|
538 if (!conf.mbox_default) {
|
meillo@28
|
539 conf.mbox_default = g_strdup("mbox");
|
meillo@393
|
540 }
|
meillo@393
|
541 if (!conf.warn_intervals) {
|
meillo@392
|
542 conf.warn_intervals = parse_list("1h;4h;8h;1d;2d;3d", TRUE);
|
meillo@393
|
543 }
|
meillo@157
|
544 if (!conf.local_hosts) {
|
meillo@366
|
545 char *shortname = strdup(conf.host_name);
|
meillo@366
|
546 char *p = strchr(shortname, '.');
|
meillo@157
|
547 if (p) {
|
meillo@157
|
548 *p = '\0';
|
meillo@157
|
549 }
|
meillo@392
|
550 /* don't care if shortname and conf.host_name are the same */
|
meillo@392
|
551 char *local_hosts_str = g_strdup_printf("localhost;%s;%s",
|
meillo@392
|
552 shortname, conf.host_name);
|
meillo@392
|
553 conf.local_hosts = parse_list(local_hosts_str, TRUE);
|
meillo@157
|
554 free(shortname);
|
meillo@157
|
555 free(local_hosts_str);
|
meillo@157
|
556 }
|
meillo@393
|
557 if (!listen_addrs_tmp) {
|
meillo@393
|
558 conf.listen_addresses = g_list_append(NULL,
|
meillo@393
|
559 parse_interface("localhost", 25));
|
meillo@393
|
560 } else {
|
meillo@393
|
561 GList *node;
|
meillo@157
|
562
|
meillo@393
|
563 foreach(listen_addrs_tmp, node) {
|
meillo@393
|
564 conf.listen_addresses =
|
meillo@393
|
565 g_list_append(conf.listen_addresses,
|
meillo@393
|
566 parse_interface((gchar *) node->data,
|
meillo@393
|
567 25));
|
meillo@393
|
568 g_free(node->data);
|
meillo@393
|
569 }
|
meillo@393
|
570 g_list_free(listen_addrs_tmp);
|
meillo@393
|
571 }
|
meillo@157
|
572
|
meillo@28
|
573 return TRUE;
|
meillo@0
|
574 }
|
meillo@0
|
575
|
meillo@10
|
576 connect_route*
|
meillo@366
|
577 read_route(gchar *filename, gboolean is_perma)
|
meillo@0
|
578 {
|
meillo@10
|
579 FILE *in;
|
meillo@393
|
580 connect_route *route;
|
meillo@393
|
581 gchar lval[256], rval[2048];
|
meillo@0
|
582
|
meillo@10
|
583 DEBUG(5) debugf("read_route, filename = %s\n", filename);
|
meillo@0
|
584
|
meillo@393
|
585 if (!(in = fopen(filename, "r"))) {
|
meillo@393
|
586 logwrite(LOG_ALERT, "could not open route file %s: %s\n",
|
meillo@393
|
587 filename, strerror(errno));
|
meillo@28
|
588 return NULL;
|
meillo@28
|
589 }
|
meillo@0
|
590
|
meillo@393
|
591 route = g_malloc(sizeof(connect_route));
|
meillo@393
|
592 memset(route, 0, sizeof(connect_route));
|
meillo@393
|
593 route->filename = g_strdup(filename);
|
meillo@393
|
594 route->name = route->filename; /* quick hack */
|
meillo@393
|
595 route->expand_h_sender_address = TRUE;
|
meillo@393
|
596 route->is_perma = is_perma;
|
meillo@393
|
597 route->do_pipelining = TRUE;
|
meillo@393
|
598
|
meillo@392
|
599 while (read_statement(in, lval, sizeof lval, rval, sizeof rval)) {
|
meillo@393
|
600 if (strcmp(lval, "mail_host")==0) {
|
meillo@178
|
601 route->mail_host = parse_interface(rval, 25);
|
meillo@393
|
602 } else if (strcmp(lval, "helo_name")==0) {
|
meillo@28
|
603 route->helo_name = g_strdup(rval);
|
meillo@393
|
604 } else if (strcmp(lval, "wrapper")==0) {
|
meillo@28
|
605 route->wrapper = g_strdup(rval);
|
meillo@393
|
606 } else if (strcmp(lval, "connect_error_fail")==0) {
|
meillo@28
|
607 route->connect_error_fail = parse_boolean(rval);
|
meillo@393
|
608 } else if (strcmp(lval, "do_correct_helo")==0) {
|
meillo@28
|
609 route->do_correct_helo = parse_boolean(rval);
|
meillo@393
|
610 } else if (strcmp(lval, "instant_helo")==0) {
|
meillo@222
|
611 route->instant_helo = parse_boolean(rval);
|
meillo@393
|
612 } else if (strcmp(lval, "do_pipelining")==0) {
|
meillo@28
|
613 route->do_pipelining = parse_boolean(rval);
|
meillo@317
|
614
|
meillo@393
|
615 } else if (strcmp(lval, "allowed_senders")==0) {
|
meillo@392
|
616 route->allowed_senders = parse_address_glob_list(rval);
|
meillo@393
|
617 } else if (strcmp(lval, "denied_senders")==0) {
|
meillo@392
|
618 route->denied_senders = parse_address_glob_list(rval);
|
meillo@393
|
619 } else if (strcmp(lval, "allowed_recipients")==0) {
|
meillo@392
|
620 route->allowed_recipients = parse_address_glob_list(rval);
|
meillo@393
|
621 } else if (strcmp(lval, "denied_recipients")==0) {
|
meillo@392
|
622 route->denied_recipients = parse_address_glob_list(rval);
|
meillo@317
|
623
|
meillo@393
|
624 } else if (strcmp(lval, "set_h_from_domain")==0) {
|
meillo@28
|
625 route->set_h_from_domain = g_strdup(rval);
|
meillo@393
|
626 } else if (strcmp(lval, "set_h_reply_to_domain")==0) {
|
meillo@28
|
627 route->set_h_reply_to_domain = g_strdup(rval);
|
meillo@393
|
628 } else if (strcmp(lval, "set_return_path_domain")==0) {
|
meillo@28
|
629 route->set_return_path_domain = g_strdup(rval);
|
meillo@393
|
630 } else if (strcmp(lval, "map_return_path_addresses")==0) {
|
meillo@28
|
631 GList *node, *list;
|
meillo@10
|
632
|
meillo@28
|
633 list = parse_list(rval, TRUE);
|
meillo@28
|
634 foreach(list, node) {
|
meillo@28
|
635 gchar *item = (gchar *) (node->data);
|
meillo@28
|
636 table_pair *pair = parse_table_pair(item, ':');
|
meillo@393
|
637 address *addr = create_address(
|
meillo@393
|
638 (gchar *) (pair->value), TRUE);
|
meillo@28
|
639 g_free(pair->value);
|
meillo@28
|
640 pair->value = (gpointer *) addr;
|
meillo@393
|
641 route->map_return_path_addresses = g_list_append( route->map_return_path_addresses, pair);
|
meillo@28
|
642 g_free(item);
|
meillo@28
|
643 }
|
meillo@28
|
644 g_list_free(list);
|
meillo@393
|
645 } else if (strcmp(lval, "map_h_from_addresses")==0) {
|
meillo@28
|
646 GList *list, *node;
|
meillo@10
|
647
|
meillo@28
|
648 list = parse_list(rval, TRUE);
|
meillo@28
|
649 foreach(list, node) {
|
meillo@28
|
650 gchar *item = (gchar *) (node->data);
|
meillo@28
|
651 table_pair *pair = parse_table_pair(item, ':');
|
meillo@28
|
652 route->map_h_from_addresses = g_list_append(route->map_h_from_addresses, pair);
|
meillo@28
|
653 g_free(item);
|
meillo@28
|
654 }
|
meillo@28
|
655 g_list_free(list);
|
meillo@393
|
656 } else if (strcmp(lval, "map_h_reply_to_addresses")==0) {
|
meillo@28
|
657 GList *list, *node;
|
meillo@10
|
658
|
meillo@28
|
659 list = parse_list(rval, TRUE);
|
meillo@28
|
660 foreach(list, node) {
|
meillo@28
|
661 gchar *item = (gchar *) (node->data);
|
meillo@28
|
662 table_pair *pair = parse_table_pair(item, ':');
|
meillo@28
|
663 route->map_h_reply_to_addresses = g_list_append(route->map_h_reply_to_addresses, pair);
|
meillo@28
|
664 g_free(item);
|
meillo@10
|
665 }
|
meillo@28
|
666 g_list_free(list);
|
meillo@393
|
667 } else if (strcmp(lval, "map_h_mail_followup_to_addresses")==0) {
|
meillo@28
|
668 GList *list, *node;
|
meillo@28
|
669
|
meillo@28
|
670 list = parse_list(rval, TRUE);
|
meillo@28
|
671 foreach(list, node) {
|
meillo@28
|
672 gchar *item = (gchar *) (node->data);
|
meillo@28
|
673 table_pair *pair = parse_table_pair(item, ':');
|
meillo@28
|
674 route->map_h_mail_followup_to_addresses = g_list_append(route->map_h_mail_followup_to_addresses, pair);
|
meillo@28
|
675 g_free(item);
|
meillo@28
|
676 }
|
meillo@28
|
677 g_list_free(list);
|
meillo@393
|
678 } else if (strcmp(lval, "expand_h_sender_domain")==0) {
|
meillo@28
|
679 route->expand_h_sender_domain = parse_boolean(rval);
|
meillo@393
|
680 } else if (strcmp(lval, "expand_h_sender_address")==0) {
|
meillo@28
|
681 route->expand_h_sender_address = parse_boolean(rval);
|
meillo@393
|
682 } else if (strcmp(lval, "resolve_list")==0) {
|
meillo@28
|
683 route->resolve_list = parse_resolve_list(rval);
|
meillo@393
|
684 } else if (strcmp(lval, "do_ssl")==0) {
|
meillo@28
|
685 /* we ignore this. This option is used by sqilconf */
|
meillo@28
|
686 ;
|
meillo@10
|
687 #ifdef ENABLE_AUTH
|
meillo@393
|
688 } else if (strcmp(lval, "auth_name")==0) {
|
meillo@28
|
689 route->auth_name = g_strdup(rval);
|
meillo@393
|
690 } else if (strcmp(lval, "auth_login")==0) {
|
meillo@28
|
691 route->auth_login = g_strdup(rval);
|
meillo@393
|
692 } else if (strcmp(lval, "auth_secret")==0) {
|
meillo@28
|
693 route->auth_secret = g_strdup(rval);
|
meillo@10
|
694 #else
|
meillo@393
|
695 } else if ((strcmp(lval, "auth_name")==0) ||
|
meillo@393
|
696 (strcmp(lval, "auth_login")==0) ||
|
meillo@393
|
697 (strcmp(lval, "auth_secret")==0)) {
|
meillo@393
|
698 logwrite(LOG_WARNING, "%s ignored: not compiled with "
|
meillo@393
|
699 "auth support.\n", lval);
|
meillo@28
|
700 }
|
meillo@10
|
701 #endif
|
meillo@393
|
702 } else if (strcmp(lval, "pipe")==0) {
|
meillo@28
|
703 route->pipe = g_strdup(rval);
|
meillo@393
|
704 } else if (strcmp(lval, "pipe_fromline")==0) {
|
meillo@28
|
705 route->pipe_fromline = parse_boolean(rval);
|
meillo@393
|
706 } else if (strcmp(lval, "pipe_fromhack")==0) {
|
meillo@28
|
707 route->pipe_fromhack = parse_boolean(rval);
|
meillo@393
|
708 } else if (strcmp(lval, "last_route")==0) {
|
meillo@28
|
709 route->last_route = parse_boolean(rval);
|
meillo@393
|
710 } else {
|
meillo@393
|
711 logwrite(LOG_WARNING, "var '%s' unknown: ignored\n",
|
meillo@393
|
712 lval);
|
meillo@393
|
713 }
|
meillo@28
|
714 }
|
meillo@28
|
715
|
meillo@319
|
716 if (!route->resolve_list) {
|
meillo@28
|
717 #ifdef ENABLE_RESOLVER
|
meillo@393
|
718 route->resolve_list = g_list_append(route->resolve_list,
|
meillo@393
|
719 resolve_dns_mx);
|
meillo@393
|
720 route->resolve_list = g_list_append(route->resolve_list,
|
meillo@393
|
721 resolve_dns_a);
|
meillo@28
|
722 #endif
|
meillo@393
|
723 route->resolve_list = g_list_append(route->resolve_list,
|
meillo@393
|
724 resolve_byname);
|
meillo@28
|
725 }
|
meillo@28
|
726 fclose(in);
|
meillo@10
|
727
|
meillo@393
|
728 /* warn user about mis-configurations: */
|
meillo@393
|
729 if (route->map_h_from_addresses && route->set_h_from_domain) {
|
meillo@393
|
730 logwrite(LOG_WARNING, "'map_h_from_addresses' overrides "
|
meillo@393
|
731 "'set_h_from_domain'\n");
|
meillo@28
|
732 g_free(route->set_h_from_domain);
|
meillo@28
|
733 route->set_h_from_domain = NULL;
|
meillo@28
|
734 }
|
meillo@393
|
735 if (route->map_h_reply_to_addresses && route->set_h_reply_to_domain) {
|
meillo@393
|
736 logwrite(LOG_WARNING, "'map_h_reply_to_addresses' overrides "
|
meillo@393
|
737 "'set_h_reply_to_domain'\n");
|
meillo@28
|
738 g_free(route->set_h_reply_to_domain);
|
meillo@28
|
739 route->set_h_reply_to_domain = NULL;
|
meillo@10
|
740 }
|
meillo@10
|
741
|
meillo@10
|
742 return route;
|
meillo@10
|
743 }
|
meillo@10
|
744
|
meillo@10
|
745 static void
|
meillo@366
|
746 _g_list_free_all(GList *list)
|
meillo@10
|
747 {
|
meillo@10
|
748 GList *node;
|
meillo@393
|
749 if (!list) {
|
meillo@393
|
750 return;
|
meillo@10
|
751 }
|
meillo@393
|
752 foreach(list, node) {
|
meillo@393
|
753 g_free(node->data);
|
meillo@393
|
754 }
|
meillo@393
|
755 g_list_free(list);
|
meillo@10
|
756 }
|
meillo@10
|
757
|
meillo@10
|
758 void
|
meillo@366
|
759 destroy_route(connect_route *r)
|
meillo@10
|
760 {
|
meillo@393
|
761 if (r->filename) {
|
meillo@10
|
762 g_free(r->filename);
|
meillo@393
|
763 }
|
meillo@10
|
764 if (r->mail_host) {
|
meillo@10
|
765 g_free(r->mail_host->address);
|
meillo@10
|
766 g_free(r->mail_host);
|
meillo@10
|
767 }
|
meillo@393
|
768 if (r->wrapper) {
|
meillo@10
|
769 g_free(r->wrapper);
|
meillo@393
|
770 }
|
meillo@393
|
771 if (r->helo_name) {
|
meillo@10
|
772 g_free(r->helo_name);
|
meillo@393
|
773 }
|
meillo@317
|
774 _g_list_free_all(r->allowed_senders);
|
meillo@317
|
775 _g_list_free_all(r->denied_senders);
|
meillo@317
|
776 _g_list_free_all(r->allowed_recipients);
|
meillo@317
|
777 _g_list_free_all(r->denied_recipients);
|
meillo@393
|
778 if (r->set_h_from_domain) {
|
meillo@10
|
779 g_free(r->set_h_from_domain);
|
meillo@393
|
780 }
|
meillo@393
|
781 if (r->set_h_reply_to_domain) {
|
meillo@10
|
782 g_free(r->set_h_reply_to_domain);
|
meillo@393
|
783 }
|
meillo@393
|
784 if (r->set_return_path_domain) {
|
meillo@10
|
785 g_free(r->set_return_path_domain);
|
meillo@393
|
786 }
|
meillo@393
|
787 if (r->map_h_reply_to_addresses) {
|
meillo@10
|
788 destroy_table(r->map_h_reply_to_addresses);
|
meillo@393
|
789 }
|
meillo@393
|
790 if (r->resolve_list) {
|
meillo@10
|
791 g_list_free(r->resolve_list);
|
meillo@393
|
792 }
|
meillo@10
|
793 #ifdef ENABLE_AUTH
|
meillo@393
|
794 if (r->auth_name) {
|
meillo@10
|
795 g_free(r->auth_name);
|
meillo@393
|
796 }
|
meillo@393
|
797 if (r->auth_login) {
|
meillo@10
|
798 g_free(r->auth_login);
|
meillo@393
|
799 }
|
meillo@393
|
800 if (r->auth_secret) {
|
meillo@10
|
801 g_free(r->auth_secret);
|
meillo@393
|
802 }
|
meillo@10
|
803 #endif
|
meillo@393
|
804 if (r->pipe) {
|
meillo@10
|
805 g_free(r->pipe);
|
meillo@393
|
806 }
|
meillo@10
|
807 g_free(r);
|
meillo@10
|
808 }
|
meillo@10
|
809
|
meillo@10
|
810 GList*
|
meillo@366
|
811 read_route_list(GList *rf_list, gboolean is_perma)
|
meillo@10
|
812 {
|
meillo@10
|
813 GList *list = NULL;
|
meillo@10
|
814 GList *node;
|
meillo@10
|
815 uid_t saved_uid, saved_gid;
|
meillo@10
|
816
|
meillo@10
|
817 if (!conf.run_as_user) {
|
meillo@10
|
818 set_euidgid(0, 0, &saved_uid, &saved_gid);
|
meillo@10
|
819 }
|
meillo@10
|
820 foreach(rf_list, node) {
|
meillo@10
|
821 gchar *fname = (gchar *) (node->data);
|
meillo@354
|
822 connect_route *route = read_route(fname, is_perma);
|
meillo@393
|
823 if (route) {
|
meillo@10
|
824 list = g_list_append(list, route);
|
meillo@393
|
825 } else {
|
meillo@393
|
826 logwrite(LOG_ALERT, "could not read route "
|
meillo@393
|
827 "configuration %s\n", fname);
|
meillo@393
|
828 }
|
meillo@10
|
829 }
|
meillo@10
|
830 /* set uid and gid back */
|
meillo@10
|
831 if (!conf.run_as_user) {
|
meillo@10
|
832 set_euidgid(saved_uid, saved_gid, NULL, NULL);
|
meillo@10
|
833 }
|
meillo@10
|
834 return list;
|
meillo@10
|
835 }
|
meillo@10
|
836
|
meillo@10
|
837 void
|
meillo@366
|
838 destroy_route_list(GList *list)
|
meillo@10
|
839 {
|
meillo@10
|
840 GList *node;
|
meillo@10
|
841
|
meillo@10
|
842 foreach(list, node) {
|
meillo@10
|
843 connect_route *route = (connect_route *) (node->data);
|
meillo@10
|
844 destroy_route(route);
|
meillo@0
|
845 }
|
meillo@0
|
846 g_list_free(list);
|
meillo@0
|
847 }
|