annotate src/conf.c @ 426:d48d3622b64f

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