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@402
|
148 char *ep;
|
meillo@317
|
149 address *addr = calloc(1, sizeof(address));
|
meillo@317
|
150
|
meillo@402
|
151 ep = item + strlen(item) - 1;
|
meillo@402
|
152 if (*item == '<' && *ep == '>') {
|
meillo@402
|
153 *item = '\0';
|
meillo@402
|
154 *ep = '\0';
|
meillo@402
|
155 g_strstrip(item);
|
meillo@317
|
156 }
|
meillo@317
|
157
|
meillo@402
|
158 addr->address = strdup(item);
|
meillo@402
|
159 at = strrchr(item, '@');
|
meillo@317
|
160 if (at) {
|
meillo@317
|
161 *at = '\0';
|
meillo@402
|
162 addr->local_part = strdup(item);
|
meillo@317
|
163 addr->domain = strdup(at+1);
|
meillo@317
|
164 } else {
|
meillo@402
|
165 addr->local_part = strdup(item);
|
meillo@330
|
166 /* No `@', thus any domain is okay. */
|
meillo@330
|
167 addr->domain = "*";
|
meillo@317
|
168 }
|
meillo@317
|
169 list = g_list_append(list, addr);
|
meillo@392
|
170 DEBUG(6) debugf("parse_address_glob_list: "
|
meillo@392
|
171 "read pattern `%s' `%s'\n",
|
meillo@317
|
172 addr->local_part, addr->domain);
|
meillo@10
|
173 g_free(item);
|
meillo@10
|
174 }
|
meillo@10
|
175 g_list_free(plain_list);
|
meillo@10
|
176 return list;
|
meillo@0
|
177 }
|
meillo@0
|
178
|
meillo@10
|
179 static GList*
|
meillo@366
|
180 parse_resolve_list(gchar *line)
|
meillo@0
|
181 {
|
meillo@10
|
182 GList *list;
|
meillo@10
|
183 GList *list_node;
|
meillo@10
|
184 GList *res_list = NULL;
|
meillo@392
|
185 gchar *item;
|
meillo@0
|
186
|
meillo@392
|
187 list = parse_list(line, TRUE);
|
meillo@28
|
188 if (!list) {
|
meillo@28
|
189 return NULL;
|
meillo@28
|
190 }
|
meillo@28
|
191 foreach(list, list_node) {
|
meillo@392
|
192 item = (gchar *) list_node->data;
|
meillo@392
|
193 if (strcmp(item, "byname")==0) {
|
meillo@28
|
194 res_list = g_list_append(res_list, resolve_byname);
|
meillo@0
|
195 #ifdef ENABLE_RESOLVER
|
meillo@392
|
196 } else if (strcmp(item, "dns_a")==0) {
|
meillo@28
|
197 res_list = g_list_append(res_list, resolve_dns_a);
|
meillo@392
|
198 } else if (strcmp(item, "dns_mx")==0) {
|
meillo@28
|
199 res_list = g_list_append(res_list, resolve_dns_mx);
|
meillo@0
|
200 #endif
|
meillo@28
|
201 } else {
|
meillo@28
|
202 logwrite(LOG_ALERT, "unknown resolver %s\n", item);
|
meillo@262
|
203 exit(1);
|
meillo@10
|
204 }
|
meillo@28
|
205 g_free(item);
|
meillo@10
|
206 }
|
meillo@28
|
207 g_list_free(list);
|
meillo@10
|
208 return res_list;
|
meillo@0
|
209 }
|
meillo@0
|
210
|
meillo@10
|
211 static interface*
|
meillo@366
|
212 parse_interface(gchar *line, gint def_port)
|
meillo@0
|
213 {
|
meillo@392
|
214 gchar *cp;
|
meillo@392
|
215 interface *iface = g_malloc(sizeof(interface));
|
meillo@0
|
216
|
meillo@333
|
217 DEBUG(9) fprintf(stderr, "parse_interface: %s\n", line);
|
meillo@392
|
218 if ((cp = strchr(line, ':'))) {
|
meillo@392
|
219 *cp = '\0';
|
meillo@392
|
220 }
|
meillo@402
|
221 g_strstrip(line);
|
meillo@392
|
222 iface->address = g_strdup(line);
|
meillo@392
|
223 iface->port = (cp) ? atoi(++cp) : def_port;
|
meillo@392
|
224 DEBUG(9) fprintf(stderr,"found: address:port=%s:%u\n",
|
meillo@392
|
225 iface->address, iface->port);
|
meillo@10
|
226 return iface;
|
meillo@0
|
227 }
|
meillo@0
|
228
|
meillo@10
|
229 static gboolean
|
meillo@366
|
230 eat_comments(FILE *in)
|
meillo@0
|
231 {
|
meillo@10
|
232 gint c;
|
meillo@392
|
233 int incomment = 0;
|
meillo@0
|
234
|
meillo@392
|
235 while ((c = fgetc(in)) != EOF) {
|
meillo@392
|
236 if (incomment) {
|
meillo@392
|
237 /* eat until end of line */
|
meillo@392
|
238 if (c == '\n') {
|
meillo@392
|
239 incomment = 0;
|
meillo@392
|
240 continue;
|
meillo@392
|
241 } else {
|
meillo@392
|
242 continue;
|
meillo@392
|
243 }
|
meillo@392
|
244 } else {
|
meillo@392
|
245 /* eat whitespace and watch for comments */
|
meillo@392
|
246 if (isspace(c)) {
|
meillo@392
|
247 continue;
|
meillo@392
|
248 } else if (c == '#') {
|
meillo@392
|
249 incomment = 1;
|
meillo@392
|
250 continue;
|
meillo@392
|
251 } else {
|
meillo@392
|
252 /* found something (that's not our business) */
|
meillo@392
|
253 ungetc(c, in);
|
meillo@392
|
254 return TRUE;
|
meillo@392
|
255 }
|
meillo@10
|
256 }
|
meillo@10
|
257 }
|
meillo@392
|
258 return FALSE;
|
meillo@0
|
259 }
|
meillo@0
|
260
|
meillo@10
|
261 static gboolean
|
meillo@366
|
262 eat_spaces(FILE *in)
|
meillo@0
|
263 {
|
meillo@10
|
264 gint c;
|
meillo@10
|
265
|
meillo@392
|
266 while ((c = fgetc(in)) != EOF) {
|
meillo@392
|
267 if (!isspace(c)) {
|
meillo@392
|
268 ungetc(c, in);
|
meillo@392
|
269 return TRUE;
|
meillo@392
|
270 }
|
meillo@28
|
271 }
|
meillo@392
|
272 return FALSE;
|
meillo@0
|
273 }
|
meillo@0
|
274
|
meillo@10
|
275 static gboolean
|
meillo@366
|
276 read_lval(FILE *in, gchar *buf, gint size)
|
meillo@0
|
277 {
|
meillo@10
|
278 gint c;
|
meillo@10
|
279 gchar *ptr = buf;
|
meillo@0
|
280
|
meillo@333
|
281 DEBUG(9) fprintf(stderr, "read_lval()\n");
|
meillo@392
|
282 if (!eat_spaces(in)) {
|
meillo@10
|
283 return FALSE;
|
meillo@392
|
284 }
|
meillo@0
|
285
|
meillo@333
|
286 DEBUG(9) fprintf(stderr, "read_lval() 2\n");
|
meillo@392
|
287 while (1) {
|
meillo@402
|
288 c = fgetc(in);
|
meillo@402
|
289 if (c == EOF) {
|
meillo@392
|
290 fprintf(stderr, "unexpected EOF after %s\n", buf);
|
meillo@392
|
291 return FALSE;
|
meillo@392
|
292 }
|
meillo@392
|
293 if (ptr >= buf+size-1) {
|
meillo@392
|
294 fprintf(stderr, "lval too long\n");
|
meillo@392
|
295 break;
|
meillo@392
|
296 }
|
meillo@392
|
297 if (!isalnum(c) && c != '_' && c != '-' && c != '.') {
|
meillo@392
|
298 break;
|
meillo@392
|
299 }
|
meillo@392
|
300 *ptr++ = c;
|
meillo@10
|
301 }
|
meillo@14
|
302 *ptr = '\0';
|
meillo@402
|
303 g_strstrip(buf);
|
meillo@10
|
304 ungetc(c, in);
|
meillo@10
|
305 eat_spaces(in);
|
meillo@333
|
306 DEBUG(9) fprintf(stderr, "lval = %s\n", buf);
|
meillo@392
|
307 return *buf != '\0';
|
meillo@0
|
308 }
|
meillo@0
|
309
|
meillo@10
|
310 static gboolean
|
meillo@366
|
311 read_rval(FILE *in, gchar *buf, gint size)
|
meillo@0
|
312 {
|
meillo@10
|
313 gint c;
|
meillo@10
|
314 gchar *ptr = buf;
|
meillo@0
|
315
|
meillo@333
|
316 DEBUG(9) fprintf(stderr, "read_rval()\n");
|
meillo@392
|
317 if (!eat_spaces(in)) {
|
meillo@10
|
318 return FALSE;
|
meillo@392
|
319 }
|
meillo@10
|
320
|
meillo@10
|
321 c = fgetc(in);
|
meillo@394
|
322 if (c != '"') {
|
meillo@394
|
323 /* unquoted rval */
|
meillo@394
|
324 ungetc(c, in);
|
meillo@394
|
325 while ((c = fgetc(in)) != EOF) {
|
meillo@394
|
326 if (ptr >= buf+size-1) {
|
meillo@394
|
327 /* rval too long */
|
meillo@394
|
328 break;
|
meillo@394
|
329 }
|
meillo@394
|
330 if (!isalnum(c) && c != '_' && c != '-' &&
|
meillo@394
|
331 c != '.' && c != '/' && c != '@' &&
|
meillo@394
|
332 c != ';' && c != ':') {
|
meillo@394
|
333 break;
|
meillo@394
|
334 }
|
meillo@394
|
335 *ptr++ = c;
|
meillo@10
|
336 }
|
meillo@14
|
337 *ptr = '\0';
|
meillo@10
|
338 ungetc(c, in);
|
meillo@10
|
339 } else {
|
meillo@394
|
340 /* quoted rval */
|
meillo@10
|
341 gboolean escape = FALSE;
|
meillo@394
|
342 while ((c = fgetc(in)) != EOF) {
|
meillo@394
|
343 if (ptr >= buf+size-1) {
|
meillo@394
|
344 /* rval too long */
|
meillo@394
|
345 break;
|
meillo@10
|
346 }
|
meillo@394
|
347 if (!escape && c == '"') {
|
meillo@394
|
348 break;
|
meillo@394
|
349 }
|
meillo@394
|
350 if (!escape && c == '\\') {
|
meillo@394
|
351 escape = TRUE;
|
meillo@394
|
352 continue;
|
meillo@394
|
353 }
|
meillo@394
|
354 *ptr++ = c;
|
meillo@394
|
355 escape = FALSE;
|
meillo@10
|
356 }
|
meillo@14
|
357 *ptr = '\0';
|
meillo@0
|
358 }
|
meillo@402
|
359 g_strstrip(buf);
|
meillo@333
|
360 DEBUG(9) fprintf(stderr, "rval = %s\n", buf);
|
meillo@394
|
361 /* eat trailing of line */
|
meillo@394
|
362 while ((c = fgetc(in)) != EOF && c != '\n') {
|
meillo@394
|
363 continue;
|
meillo@394
|
364 }
|
meillo@10
|
365
|
meillo@10
|
366 return TRUE;
|
meillo@0
|
367 }
|
meillo@0
|
368
|
meillo@10
|
369 static gboolean
|
meillo@366
|
370 read_statement(FILE *in, gchar *lval, gint lsize, gchar *rval, gint rsize)
|
meillo@0
|
371 {
|
meillo@10
|
372 gint c;
|
meillo@0
|
373
|
meillo@333
|
374 DEBUG(9) fprintf(stderr, "read_statement()\n");
|
meillo@0
|
375
|
meillo@10
|
376 /* eat comments and empty lines: */
|
meillo@393
|
377 if (!eat_comments(in)) {
|
meillo@10
|
378 return FALSE;
|
meillo@393
|
379 }
|
meillo@28
|
380 if (!read_lval(in, lval, lsize)) {
|
meillo@28
|
381 return FALSE;
|
meillo@28
|
382 }
|
meillo@28
|
383
|
meillo@333
|
384 DEBUG(9) fprintf(stderr, " lval = %s\n", lval);
|
meillo@393
|
385 if ((c = fgetc(in) != '=')) {
|
meillo@393
|
386 fprintf(stderr, "'=' expected after %s, char was '%c'\n",
|
meillo@393
|
387 lval, c);
|
meillo@10
|
388 }
|
meillo@393
|
389 if (!read_rval(in, rval, rsize)) {
|
meillo@393
|
390 return FALSE;
|
meillo@393
|
391 }
|
meillo@393
|
392 DEBUG(9) fprintf(stderr, " rval = %s\n", rval);
|
meillo@393
|
393 return TRUE;
|
meillo@0
|
394 }
|
meillo@0
|
395
|
meillo@10
|
396 gboolean
|
meillo@366
|
397 read_conf(gchar *filename)
|
meillo@0
|
398 {
|
meillo@10
|
399 FILE *in;
|
meillo@393
|
400 gchar lval[256], rval[2048];
|
meillo@393
|
401 GList *listen_addrs_tmp = NULL;
|
meillo@0
|
402
|
meillo@10
|
403 conf.do_relay = TRUE;
|
meillo@244
|
404 conf.localpartcmp = strcmp;
|
meillo@10
|
405 conf.max_defer_time = 86400 * 4; /* 4 days */
|
meillo@120
|
406 conf.max_msg_size = 0; /* no limit on msg size */
|
meillo@151
|
407 conf.spool_dir = SPOOL_DIR;
|
meillo@152
|
408 conf.mail_dir = "/var/mail";
|
meillo@0
|
409
|
meillo@393
|
410 if (!(in = fopen(filename, "r"))) {
|
meillo@393
|
411 logwrite(LOG_ALERT, "could not open config file %s: %s\n",
|
meillo@393
|
412 filename, strerror(errno));
|
meillo@28
|
413 return FALSE;
|
meillo@28
|
414 }
|
meillo@28
|
415
|
meillo@392
|
416 while (read_statement(in, lval, sizeof lval, rval, sizeof rval)) {
|
meillo@333
|
417 DEBUG(9) fprintf(stderr,"read_conf(): lval=%s\n", lval);
|
meillo@393
|
418 if (strcmp(lval, "debug_level")==0) {
|
meillo@28
|
419 conf.debug_level = atoi(rval);
|
meillo@393
|
420 } else if (strcmp(lval, "run_as_user")==0) {
|
meillo@393
|
421 if (!conf.run_as_user) {
|
meillo@393
|
422 /* you should not be able to reset that flag */
|
meillo@28
|
423 conf.run_as_user = parse_boolean(rval);
|
meillo@393
|
424 }
|
meillo@393
|
425 } else if (strcmp(lval, "use_syslog")==0) {
|
meillo@28
|
426 conf.use_syslog = parse_boolean(rval);
|
meillo@393
|
427 } else if (strcmp(lval, "mail_dir")==0) {
|
meillo@28
|
428 conf.mail_dir = g_strdup(rval);
|
meillo@393
|
429 } else if (strcmp(lval, "lock_dir")==0) {
|
meillo@28
|
430 conf.lock_dir = g_strdup(rval);
|
meillo@393
|
431 } else if (strcmp(lval, "spool_dir")==0) {
|
meillo@28
|
432 conf.spool_dir = g_strdup(rval);
|
meillo@393
|
433 } else if (strcmp(lval, "log_dir")==0) {
|
meillo@28
|
434 conf.log_dir = g_strdup(rval);
|
meillo@393
|
435 } else if (strcmp(lval, "host_name")==0) {
|
meillo@393
|
436 if (rval[0] != '/') {
|
meillo@28
|
437 conf.host_name = g_strdup(rval);
|
meillo@393
|
438 } else {
|
meillo@28
|
439 char buf[256];
|
meillo@28
|
440 FILE *fptr = fopen(rval, "rt");
|
meillo@307
|
441 if (!fptr) {
|
meillo@393
|
442 logwrite(LOG_ALERT, "could not open "
|
meillo@393
|
443 "%s: %s\n", rval,
|
meillo@393
|
444 strerror(errno));
|
meillo@28
|
445 return FALSE;
|
meillo@10
|
446 }
|
meillo@393
|
447 fgets(buf, sizeof buf, fptr);
|
meillo@393
|
448 g_strstrip(buf);
|
meillo@28
|
449 conf.host_name = g_strdup(buf);
|
meillo@28
|
450 fclose(fptr);
|
meillo@28
|
451 }
|
meillo@393
|
452 } else if (strcmp(lval, "local_hosts")==0) {
|
meillo@392
|
453 conf.local_hosts = parse_list(rval, TRUE);
|
meillo@393
|
454 } else if (strcmp(lval, "local_addresses")==0) {
|
meillo@28
|
455 conf.local_addresses = parse_list(rval, TRUE);
|
meillo@393
|
456 } else if (strcmp(lval, "not_local_addresses")==0) {
|
meillo@28
|
457 conf.not_local_addresses = parse_list(rval, TRUE);
|
meillo@393
|
458 } else if (strcmp(lval, "do_save_envelope_to")==0) {
|
meillo@28
|
459 conf.do_save_envelope_to = parse_boolean(rval);
|
meillo@393
|
460 } else if (strcmp(lval, "defer_all")==0) {
|
meillo@28
|
461 conf.defer_all = parse_boolean(rval);
|
meillo@393
|
462 } else if (strcmp(lval, "do_relay")==0) {
|
meillo@28
|
463 conf.do_relay = parse_boolean(rval);
|
meillo@393
|
464 } else if (strcmp(lval, "alias_file")==0) {
|
meillo@28
|
465 conf.alias_file = g_strdup(rval);
|
meillo@393
|
466 } else if (strcmp(lval, "globalias_file")==0) {
|
meillo@387
|
467 conf.globalias_file = g_strdup(rval);
|
meillo@393
|
468 } else if (strcmp(lval, "caseless_matching")==0) {
|
meillo@393
|
469 conf.localpartcmp = parse_boolean(rval) ?
|
meillo@393
|
470 strcasecmp : strcmp;
|
meillo@393
|
471 } else if (strcmp(lval, "mbox_default")==0) {
|
meillo@28
|
472 conf.mbox_default = g_strdup(rval);
|
meillo@393
|
473 } else if (strcmp(lval, "mbox_users")==0) {
|
meillo@28
|
474 conf.mbox_users = parse_list(rval, TRUE);
|
meillo@393
|
475 } else if (strcmp(lval, "mda_users")==0) {
|
meillo@28
|
476 conf.mda_users = parse_list(rval, TRUE);
|
meillo@393
|
477 } else if (strcmp(lval, "mda")==0) {
|
meillo@28
|
478 conf.mda = g_strdup(rval);
|
meillo@393
|
479 } else if (strcmp(lval, "mda_fromline")==0) {
|
meillo@28
|
480 conf.mda_fromline = parse_boolean(rval);
|
meillo@393
|
481 } else if (strcmp(lval, "mda_fromhack")==0) {
|
meillo@28
|
482 conf.mda_fromhack = parse_boolean(rval);
|
meillo@393
|
483 } else if (strcmp(lval, "pipe_fromline")==0) {
|
meillo@28
|
484 conf.pipe_fromline = parse_boolean(rval);
|
meillo@393
|
485 } else if (strcmp(lval, "pipe_fromhack")==0) {
|
meillo@28
|
486 conf.pipe_fromhack = parse_boolean(rval);
|
meillo@393
|
487 } else if (strcmp(lval, "listen_addresses")==0) {
|
meillo@393
|
488 listen_addrs_tmp = parse_list(rval, TRUE);
|
meillo@393
|
489 } else if (strncmp(lval, "query_routes.", 13)==0) {
|
meillo@28
|
490 GList *file_list = parse_list(rval, FALSE);
|
meillo@354
|
491 table_pair *pair = create_pair(lval+13, file_list);
|
meillo@393
|
492 conf.query_routes = g_list_append(conf.query_routes,
|
meillo@393
|
493 pair);
|
meillo@393
|
494 } else if (strcmp(lval, "permanent_routes")==0) {
|
meillo@354
|
495 conf.perma_routes = parse_list(rval, FALSE);
|
meillo@393
|
496 } else if (strcmp(lval, "online_query")==0) {
|
meillo@310
|
497 conf.online_query = g_strdup(rval);
|
meillo@393
|
498 } else if (strcmp(lval, "do_queue")==0) {
|
meillo@28
|
499 conf.do_queue = parse_boolean(rval);
|
meillo@393
|
500 } else if (strcmp(lval, "errmsg_file")==0) {
|
meillo@28
|
501 conf.errmsg_file = g_strdup(rval);
|
meillo@393
|
502 } else if (strcmp(lval, "warnmsg_file")==0) {
|
meillo@28
|
503 conf.warnmsg_file = g_strdup(rval);
|
meillo@393
|
504 } else if (strcmp(lval, "warn_intervals")==0) {
|
meillo@392
|
505 conf.warn_intervals = parse_list(rval, TRUE);
|
meillo@393
|
506 } else if (strcmp(lval, "max_defer_time")==0) {
|
meillo@254
|
507 gint ival = time_interval(rval);
|
meillo@393
|
508 if (ival < 0) {
|
meillo@393
|
509 logwrite(LOG_WARNING, "invalid time interval "
|
meillo@393
|
510 "for 'max_defer_time': %s\n",
|
meillo@393
|
511 rval);
|
meillo@393
|
512 } else {
|
meillo@28
|
513 conf.max_defer_time = ival;
|
meillo@393
|
514 }
|
meillo@393
|
515 } else if (strcmp(lval, "log_user")==0) {
|
meillo@28
|
516 conf.log_user = g_strdup(rval);
|
meillo@393
|
517 } else if(strcmp(lval, "max_msg_size")==0) {
|
meillo@117
|
518 conf.max_msg_size = atol(rval);
|
meillo@393
|
519 DEBUG(9) fprintf(stderr,
|
meillo@393
|
520 "rval=%s, conf.max_msg_size=%ld\n",
|
meillo@117
|
521 rval, conf.max_msg_size);
|
meillo@393
|
522 } else {
|
meillo@393
|
523 logwrite(LOG_WARNING, "var '%s' unknown: ignored\n",
|
meillo@393
|
524 lval);
|
meillo@117
|
525 }
|
meillo@28
|
526 }
|
meillo@28
|
527 fclose(in);
|
meillo@0
|
528
|
meillo@156
|
529 if (!conf.host_name) {
|
meillo@393
|
530 logwrite(LOG_ALERT, "`host_name' MUST be set in "
|
meillo@393
|
531 "masqmail.conf. See man page\n");
|
meillo@156
|
532 return FALSE;
|
meillo@156
|
533 }
|
meillo@393
|
534 if (!conf.errmsg_file) {
|
meillo@28
|
535 conf.errmsg_file = g_strdup(DATA_DIR "/tpl/failmsg.tpl");
|
meillo@393
|
536 }
|
meillo@393
|
537 if (!conf.warnmsg_file) {
|
meillo@28
|
538 conf.warnmsg_file = g_strdup(DATA_DIR "/tpl/warnmsg.tpl");
|
meillo@393
|
539 }
|
meillo@393
|
540 if (!conf.lock_dir) {
|
meillo@28
|
541 conf.lock_dir = g_strdup_printf("%s/lock/", conf.spool_dir);
|
meillo@393
|
542 }
|
meillo@393
|
543 if (!conf.mbox_default) {
|
meillo@28
|
544 conf.mbox_default = g_strdup("mbox");
|
meillo@393
|
545 }
|
meillo@393
|
546 if (!conf.warn_intervals) {
|
meillo@392
|
547 conf.warn_intervals = parse_list("1h;4h;8h;1d;2d;3d", TRUE);
|
meillo@393
|
548 }
|
meillo@157
|
549 if (!conf.local_hosts) {
|
meillo@366
|
550 char *shortname = strdup(conf.host_name);
|
meillo@366
|
551 char *p = strchr(shortname, '.');
|
meillo@157
|
552 if (p) {
|
meillo@157
|
553 *p = '\0';
|
meillo@157
|
554 }
|
meillo@392
|
555 /* don't care if shortname and conf.host_name are the same */
|
meillo@392
|
556 char *local_hosts_str = g_strdup_printf("localhost;%s;%s",
|
meillo@392
|
557 shortname, conf.host_name);
|
meillo@392
|
558 conf.local_hosts = parse_list(local_hosts_str, TRUE);
|
meillo@157
|
559 free(shortname);
|
meillo@157
|
560 free(local_hosts_str);
|
meillo@157
|
561 }
|
meillo@393
|
562 if (!listen_addrs_tmp) {
|
meillo@393
|
563 conf.listen_addresses = g_list_append(NULL,
|
meillo@393
|
564 parse_interface("localhost", 25));
|
meillo@393
|
565 } else {
|
meillo@393
|
566 GList *node;
|
meillo@157
|
567
|
meillo@393
|
568 foreach(listen_addrs_tmp, node) {
|
meillo@393
|
569 conf.listen_addresses =
|
meillo@393
|
570 g_list_append(conf.listen_addresses,
|
meillo@393
|
571 parse_interface((gchar *) node->data,
|
meillo@393
|
572 25));
|
meillo@393
|
573 g_free(node->data);
|
meillo@393
|
574 }
|
meillo@393
|
575 g_list_free(listen_addrs_tmp);
|
meillo@393
|
576 }
|
meillo@157
|
577
|
meillo@28
|
578 return TRUE;
|
meillo@0
|
579 }
|
meillo@0
|
580
|
meillo@10
|
581 connect_route*
|
meillo@366
|
582 read_route(gchar *filename, gboolean is_perma)
|
meillo@0
|
583 {
|
meillo@10
|
584 FILE *in;
|
meillo@393
|
585 connect_route *route;
|
meillo@393
|
586 gchar lval[256], rval[2048];
|
meillo@0
|
587
|
meillo@10
|
588 DEBUG(5) debugf("read_route, filename = %s\n", filename);
|
meillo@0
|
589
|
meillo@393
|
590 if (!(in = fopen(filename, "r"))) {
|
meillo@393
|
591 logwrite(LOG_ALERT, "could not open route file %s: %s\n",
|
meillo@393
|
592 filename, strerror(errno));
|
meillo@28
|
593 return NULL;
|
meillo@28
|
594 }
|
meillo@0
|
595
|
meillo@393
|
596 route = g_malloc(sizeof(connect_route));
|
meillo@393
|
597 memset(route, 0, sizeof(connect_route));
|
meillo@393
|
598 route->filename = g_strdup(filename);
|
meillo@393
|
599 route->name = route->filename; /* quick hack */
|
meillo@393
|
600 route->expand_h_sender_address = TRUE;
|
meillo@393
|
601 route->is_perma = is_perma;
|
meillo@393
|
602 route->do_pipelining = TRUE;
|
meillo@393
|
603
|
meillo@392
|
604 while (read_statement(in, lval, sizeof lval, rval, sizeof rval)) {
|
meillo@393
|
605 if (strcmp(lval, "mail_host")==0) {
|
meillo@178
|
606 route->mail_host = parse_interface(rval, 25);
|
meillo@393
|
607 } else if (strcmp(lval, "helo_name")==0) {
|
meillo@28
|
608 route->helo_name = g_strdup(rval);
|
meillo@393
|
609 } else if (strcmp(lval, "wrapper")==0) {
|
meillo@28
|
610 route->wrapper = g_strdup(rval);
|
meillo@393
|
611 } else if (strcmp(lval, "connect_error_fail")==0) {
|
meillo@28
|
612 route->connect_error_fail = parse_boolean(rval);
|
meillo@393
|
613 } else if (strcmp(lval, "do_correct_helo")==0) {
|
meillo@28
|
614 route->do_correct_helo = parse_boolean(rval);
|
meillo@393
|
615 } else if (strcmp(lval, "instant_helo")==0) {
|
meillo@222
|
616 route->instant_helo = parse_boolean(rval);
|
meillo@393
|
617 } else if (strcmp(lval, "do_pipelining")==0) {
|
meillo@28
|
618 route->do_pipelining = parse_boolean(rval);
|
meillo@317
|
619
|
meillo@393
|
620 } else if (strcmp(lval, "allowed_senders")==0) {
|
meillo@392
|
621 route->allowed_senders = parse_address_glob_list(rval);
|
meillo@393
|
622 } else if (strcmp(lval, "denied_senders")==0) {
|
meillo@392
|
623 route->denied_senders = parse_address_glob_list(rval);
|
meillo@393
|
624 } else if (strcmp(lval, "allowed_recipients")==0) {
|
meillo@392
|
625 route->allowed_recipients = parse_address_glob_list(rval);
|
meillo@393
|
626 } else if (strcmp(lval, "denied_recipients")==0) {
|
meillo@392
|
627 route->denied_recipients = parse_address_glob_list(rval);
|
meillo@317
|
628
|
meillo@393
|
629 } else if (strcmp(lval, "set_h_from_domain")==0) {
|
meillo@28
|
630 route->set_h_from_domain = g_strdup(rval);
|
meillo@393
|
631 } else if (strcmp(lval, "set_h_reply_to_domain")==0) {
|
meillo@28
|
632 route->set_h_reply_to_domain = g_strdup(rval);
|
meillo@393
|
633 } else if (strcmp(lval, "set_return_path_domain")==0) {
|
meillo@28
|
634 route->set_return_path_domain = g_strdup(rval);
|
meillo@393
|
635 } else if (strcmp(lval, "map_return_path_addresses")==0) {
|
meillo@28
|
636 GList *node, *list;
|
meillo@10
|
637
|
meillo@28
|
638 list = parse_list(rval, TRUE);
|
meillo@28
|
639 foreach(list, node) {
|
meillo@28
|
640 gchar *item = (gchar *) (node->data);
|
meillo@28
|
641 table_pair *pair = parse_table_pair(item, ':');
|
meillo@393
|
642 address *addr = create_address(
|
meillo@393
|
643 (gchar *) (pair->value), TRUE);
|
meillo@28
|
644 g_free(pair->value);
|
meillo@28
|
645 pair->value = (gpointer *) addr;
|
meillo@402
|
646 route->map_return_path_addresses = g_list_append(route->map_return_path_addresses, pair);
|
meillo@28
|
647 g_free(item);
|
meillo@28
|
648 }
|
meillo@28
|
649 g_list_free(list);
|
meillo@393
|
650 } else if (strcmp(lval, "map_h_from_addresses")==0) {
|
meillo@28
|
651 GList *list, *node;
|
meillo@10
|
652
|
meillo@28
|
653 list = parse_list(rval, TRUE);
|
meillo@28
|
654 foreach(list, node) {
|
meillo@28
|
655 gchar *item = (gchar *) (node->data);
|
meillo@28
|
656 table_pair *pair = parse_table_pair(item, ':');
|
meillo@28
|
657 route->map_h_from_addresses = g_list_append(route->map_h_from_addresses, pair);
|
meillo@28
|
658 g_free(item);
|
meillo@28
|
659 }
|
meillo@28
|
660 g_list_free(list);
|
meillo@393
|
661 } else if (strcmp(lval, "map_h_reply_to_addresses")==0) {
|
meillo@28
|
662 GList *list, *node;
|
meillo@10
|
663
|
meillo@28
|
664 list = parse_list(rval, TRUE);
|
meillo@28
|
665 foreach(list, node) {
|
meillo@28
|
666 gchar *item = (gchar *) (node->data);
|
meillo@28
|
667 table_pair *pair = parse_table_pair(item, ':');
|
meillo@28
|
668 route->map_h_reply_to_addresses = g_list_append(route->map_h_reply_to_addresses, pair);
|
meillo@28
|
669 g_free(item);
|
meillo@10
|
670 }
|
meillo@28
|
671 g_list_free(list);
|
meillo@393
|
672 } else if (strcmp(lval, "map_h_mail_followup_to_addresses")==0) {
|
meillo@28
|
673 GList *list, *node;
|
meillo@28
|
674
|
meillo@28
|
675 list = parse_list(rval, TRUE);
|
meillo@28
|
676 foreach(list, node) {
|
meillo@28
|
677 gchar *item = (gchar *) (node->data);
|
meillo@28
|
678 table_pair *pair = parse_table_pair(item, ':');
|
meillo@28
|
679 route->map_h_mail_followup_to_addresses = g_list_append(route->map_h_mail_followup_to_addresses, pair);
|
meillo@28
|
680 g_free(item);
|
meillo@28
|
681 }
|
meillo@28
|
682 g_list_free(list);
|
meillo@393
|
683 } else if (strcmp(lval, "expand_h_sender_domain")==0) {
|
meillo@28
|
684 route->expand_h_sender_domain = parse_boolean(rval);
|
meillo@393
|
685 } else if (strcmp(lval, "expand_h_sender_address")==0) {
|
meillo@28
|
686 route->expand_h_sender_address = parse_boolean(rval);
|
meillo@393
|
687 } else if (strcmp(lval, "resolve_list")==0) {
|
meillo@28
|
688 route->resolve_list = parse_resolve_list(rval);
|
meillo@393
|
689 } else if (strcmp(lval, "do_ssl")==0) {
|
meillo@28
|
690 /* we ignore this. This option is used by sqilconf */
|
meillo@28
|
691 ;
|
meillo@10
|
692 #ifdef ENABLE_AUTH
|
meillo@393
|
693 } else if (strcmp(lval, "auth_name")==0) {
|
meillo@28
|
694 route->auth_name = g_strdup(rval);
|
meillo@393
|
695 } else if (strcmp(lval, "auth_login")==0) {
|
meillo@28
|
696 route->auth_login = g_strdup(rval);
|
meillo@393
|
697 } else if (strcmp(lval, "auth_secret")==0) {
|
meillo@28
|
698 route->auth_secret = g_strdup(rval);
|
meillo@10
|
699 #else
|
meillo@393
|
700 } else if ((strcmp(lval, "auth_name")==0) ||
|
meillo@393
|
701 (strcmp(lval, "auth_login")==0) ||
|
meillo@393
|
702 (strcmp(lval, "auth_secret")==0)) {
|
meillo@393
|
703 logwrite(LOG_WARNING, "%s ignored: not compiled with "
|
meillo@393
|
704 "auth support.\n", lval);
|
meillo@28
|
705 }
|
meillo@10
|
706 #endif
|
meillo@393
|
707 } else if (strcmp(lval, "pipe")==0) {
|
meillo@28
|
708 route->pipe = g_strdup(rval);
|
meillo@393
|
709 } else if (strcmp(lval, "pipe_fromline")==0) {
|
meillo@28
|
710 route->pipe_fromline = parse_boolean(rval);
|
meillo@393
|
711 } else if (strcmp(lval, "pipe_fromhack")==0) {
|
meillo@28
|
712 route->pipe_fromhack = parse_boolean(rval);
|
meillo@393
|
713 } else if (strcmp(lval, "last_route")==0) {
|
meillo@28
|
714 route->last_route = parse_boolean(rval);
|
meillo@393
|
715 } else {
|
meillo@393
|
716 logwrite(LOG_WARNING, "var '%s' unknown: ignored\n",
|
meillo@393
|
717 lval);
|
meillo@393
|
718 }
|
meillo@28
|
719 }
|
meillo@28
|
720
|
meillo@319
|
721 if (!route->resolve_list) {
|
meillo@28
|
722 #ifdef ENABLE_RESOLVER
|
meillo@393
|
723 route->resolve_list = g_list_append(route->resolve_list,
|
meillo@393
|
724 resolve_dns_mx);
|
meillo@393
|
725 route->resolve_list = g_list_append(route->resolve_list,
|
meillo@393
|
726 resolve_dns_a);
|
meillo@28
|
727 #endif
|
meillo@393
|
728 route->resolve_list = g_list_append(route->resolve_list,
|
meillo@393
|
729 resolve_byname);
|
meillo@28
|
730 }
|
meillo@28
|
731 fclose(in);
|
meillo@10
|
732
|
meillo@393
|
733 /* warn user about mis-configurations: */
|
meillo@393
|
734 if (route->map_h_from_addresses && route->set_h_from_domain) {
|
meillo@393
|
735 logwrite(LOG_WARNING, "'map_h_from_addresses' overrides "
|
meillo@393
|
736 "'set_h_from_domain'\n");
|
meillo@28
|
737 g_free(route->set_h_from_domain);
|
meillo@28
|
738 route->set_h_from_domain = NULL;
|
meillo@28
|
739 }
|
meillo@393
|
740 if (route->map_h_reply_to_addresses && route->set_h_reply_to_domain) {
|
meillo@393
|
741 logwrite(LOG_WARNING, "'map_h_reply_to_addresses' overrides "
|
meillo@393
|
742 "'set_h_reply_to_domain'\n");
|
meillo@28
|
743 g_free(route->set_h_reply_to_domain);
|
meillo@28
|
744 route->set_h_reply_to_domain = NULL;
|
meillo@10
|
745 }
|
meillo@10
|
746
|
meillo@10
|
747 return route;
|
meillo@10
|
748 }
|
meillo@10
|
749
|
meillo@10
|
750 static void
|
meillo@366
|
751 _g_list_free_all(GList *list)
|
meillo@10
|
752 {
|
meillo@10
|
753 GList *node;
|
meillo@393
|
754 if (!list) {
|
meillo@393
|
755 return;
|
meillo@10
|
756 }
|
meillo@393
|
757 foreach(list, node) {
|
meillo@393
|
758 g_free(node->data);
|
meillo@393
|
759 }
|
meillo@393
|
760 g_list_free(list);
|
meillo@10
|
761 }
|
meillo@10
|
762
|
meillo@10
|
763 void
|
meillo@366
|
764 destroy_route(connect_route *r)
|
meillo@10
|
765 {
|
meillo@393
|
766 if (r->filename) {
|
meillo@10
|
767 g_free(r->filename);
|
meillo@393
|
768 }
|
meillo@10
|
769 if (r->mail_host) {
|
meillo@10
|
770 g_free(r->mail_host->address);
|
meillo@10
|
771 g_free(r->mail_host);
|
meillo@10
|
772 }
|
meillo@393
|
773 if (r->wrapper) {
|
meillo@10
|
774 g_free(r->wrapper);
|
meillo@393
|
775 }
|
meillo@393
|
776 if (r->helo_name) {
|
meillo@10
|
777 g_free(r->helo_name);
|
meillo@393
|
778 }
|
meillo@317
|
779 _g_list_free_all(r->allowed_senders);
|
meillo@317
|
780 _g_list_free_all(r->denied_senders);
|
meillo@317
|
781 _g_list_free_all(r->allowed_recipients);
|
meillo@317
|
782 _g_list_free_all(r->denied_recipients);
|
meillo@393
|
783 if (r->set_h_from_domain) {
|
meillo@10
|
784 g_free(r->set_h_from_domain);
|
meillo@393
|
785 }
|
meillo@393
|
786 if (r->set_h_reply_to_domain) {
|
meillo@10
|
787 g_free(r->set_h_reply_to_domain);
|
meillo@393
|
788 }
|
meillo@393
|
789 if (r->set_return_path_domain) {
|
meillo@10
|
790 g_free(r->set_return_path_domain);
|
meillo@393
|
791 }
|
meillo@393
|
792 if (r->map_h_reply_to_addresses) {
|
meillo@10
|
793 destroy_table(r->map_h_reply_to_addresses);
|
meillo@393
|
794 }
|
meillo@393
|
795 if (r->resolve_list) {
|
meillo@10
|
796 g_list_free(r->resolve_list);
|
meillo@393
|
797 }
|
meillo@10
|
798 #ifdef ENABLE_AUTH
|
meillo@393
|
799 if (r->auth_name) {
|
meillo@10
|
800 g_free(r->auth_name);
|
meillo@393
|
801 }
|
meillo@393
|
802 if (r->auth_login) {
|
meillo@10
|
803 g_free(r->auth_login);
|
meillo@393
|
804 }
|
meillo@393
|
805 if (r->auth_secret) {
|
meillo@10
|
806 g_free(r->auth_secret);
|
meillo@393
|
807 }
|
meillo@10
|
808 #endif
|
meillo@393
|
809 if (r->pipe) {
|
meillo@10
|
810 g_free(r->pipe);
|
meillo@393
|
811 }
|
meillo@10
|
812 g_free(r);
|
meillo@10
|
813 }
|
meillo@10
|
814
|
meillo@10
|
815 GList*
|
meillo@366
|
816 read_route_list(GList *rf_list, gboolean is_perma)
|
meillo@10
|
817 {
|
meillo@10
|
818 GList *list = NULL;
|
meillo@10
|
819 GList *node;
|
meillo@10
|
820 uid_t saved_uid, saved_gid;
|
meillo@10
|
821
|
meillo@10
|
822 if (!conf.run_as_user) {
|
meillo@10
|
823 set_euidgid(0, 0, &saved_uid, &saved_gid);
|
meillo@10
|
824 }
|
meillo@10
|
825 foreach(rf_list, node) {
|
meillo@10
|
826 gchar *fname = (gchar *) (node->data);
|
meillo@354
|
827 connect_route *route = read_route(fname, is_perma);
|
meillo@393
|
828 if (route) {
|
meillo@10
|
829 list = g_list_append(list, route);
|
meillo@393
|
830 } else {
|
meillo@393
|
831 logwrite(LOG_ALERT, "could not read route "
|
meillo@393
|
832 "configuration %s\n", fname);
|
meillo@393
|
833 }
|
meillo@10
|
834 }
|
meillo@10
|
835 /* set uid and gid back */
|
meillo@10
|
836 if (!conf.run_as_user) {
|
meillo@10
|
837 set_euidgid(saved_uid, saved_gid, NULL, NULL);
|
meillo@10
|
838 }
|
meillo@10
|
839 return list;
|
meillo@10
|
840 }
|
meillo@10
|
841
|
meillo@10
|
842 void
|
meillo@366
|
843 destroy_route_list(GList *list)
|
meillo@10
|
844 {
|
meillo@10
|
845 GList *node;
|
meillo@10
|
846
|
meillo@10
|
847 foreach(list, node) {
|
meillo@10
|
848 connect_route *route = (connect_route *) (node->data);
|
meillo@10
|
849 destroy_route(route);
|
meillo@0
|
850 }
|
meillo@0
|
851 g_list_free(list);
|
meillo@0
|
852 }
|