Mercurial > masqmail
annotate src/conf.c @ 431:34c919a8d74e 0.3.5
Bumps version number and updates Changelog and NEWS
author | markus schnalke <meillo@marmaro.de> |
---|---|
date | Sat, 07 Feb 2015 11:17:53 +0100 |
parents | 5593964ec779 |
children |
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 | 19 */ |
20 | |
13 | 21 #include <pwd.h> |
22 #include <grp.h> | |
0 | 23 |
13 | 24 #include "masqmail.h" |
0 | 25 |
26 masqmail_conf conf; | |
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 | 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 | 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 | 49 } |
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 | 53 }; |
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 | 57 }; |
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 | 61 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
62 gchar **str; |
0 | 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 | 77 } |
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 | 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 | 87 gchar buf[256]; |
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 } |
428
e972c3cbe1e0
Bugfix: Read as long as there *is* content.
markus schnalke <meillo@marmaro.de>
parents:
421
diff
changeset
|
94 while (fgets(buf, sizeof buf, fptr)) { |
392
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 | 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 | 101 } |
102 fclose(fptr); | |
103 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
104 return list; |
0 | 105 } |
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 | 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 | 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 | 129 } |
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 | 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 | 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 | 177 } |
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 | 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 | 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 | 188 if (!list) { |
189 return NULL; | |
190 } | |
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 | 194 res_list = g_list_append(res_list, resolve_byname); |
0 | 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 | 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 | 199 res_list = g_list_append(res_list, resolve_dns_mx); |
0 | 200 #endif |
28 | 201 } else { |
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 | 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 | 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 | 209 } |
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 | 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 | 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 | 227 } |
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 | 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 | 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 | 259 } |
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 | 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 | 271 } |
392
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
272 return FALSE; |
0 | 273 } |
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 | 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 | 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 | 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 | 308 } |
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 | 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 | 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 | 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 | 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 | 365 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
366 return TRUE; |
0 | 367 } |
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 | 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 | 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 | 380 if (!read_lval(in, lval, lsize)) { |
381 return FALSE; | |
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 | 395 } |
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 | 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 | 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 | 409 conf.spool_dir = SPOOL_DIR; |
152 | 410 conf.mail_dir = "/var/mail"; |
0 | 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 | 415 return FALSE; |
416 } | |
0 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 441 char buf[256]; |
442 FILE *fptr = fopen(rval, "rt"); | |
307 | 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 | 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 | 451 conf.host_name = g_strdup(buf); |
452 fclose(fptr); | |
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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 528 } |
529 fclose(in); | |
0 | 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 | 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 | 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 | 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 | 577 return TRUE; |
0 | 578 } |
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 | 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 | 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 | 592 return NULL; |
593 } | |
0 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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); |
429
5593964ec779
Added route conditions based on the From header
markus schnalke <meillo@marmaro.de>
parents:
428
diff
changeset
|
627 } else if (strcmp(lval, "allowed_from_hdrs")==0) { |
5593964ec779
Added route conditions based on the From header
markus schnalke <meillo@marmaro.de>
parents:
428
diff
changeset
|
628 route->allowed_from_hdrs = parse_address_glob_list(rval); |
5593964ec779
Added route conditions based on the From header
markus schnalke <meillo@marmaro.de>
parents:
428
diff
changeset
|
629 } else if (strcmp(lval, "denied_from_hdrs")==0) { |
5593964ec779
Added route conditions based on the From header
markus schnalke <meillo@marmaro.de>
parents:
428
diff
changeset
|
630 route->denied_from_hdrs = parse_address_glob_list(rval); |
317
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
311
diff
changeset
|
631 |
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_h_from_domain")==0) { |
28 | 633 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
|
634 } else if (strcmp(lval, "set_h_reply_to_domain")==0) { |
28 | 635 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
|
636 } else if (strcmp(lval, "set_return_path_domain")==0) { |
28 | 637 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
|
638 } else if (strcmp(lval, "map_return_path_addresses")==0) { |
28 | 639 GList *node, *list; |
0 | 640 |
28 | 641 list = parse_list(rval, TRUE); |
642 foreach(list, node) { | |
643 gchar *item = (gchar *) (node->data); | |
644 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
|
645 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
|
646 (gchar *) (pair->value), TRUE); |
28 | 647 g_free(pair->value); |
648 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
|
649 route->map_return_path_addresses = g_list_append(route->map_return_path_addresses, pair); |
28 | 650 g_free(item); |
651 } | |
652 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
|
653 } else if (strcmp(lval, "map_h_from_addresses")==0) { |
28 | 654 GList *list, *node; |
0 | 655 |
28 | 656 list = parse_list(rval, TRUE); |
657 foreach(list, node) { | |
658 gchar *item = (gchar *) (node->data); | |
659 table_pair *pair = parse_table_pair(item, ':'); | |
660 route->map_h_from_addresses = g_list_append(route->map_h_from_addresses, pair); | |
661 g_free(item); | |
662 } | |
663 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
|
664 } else if (strcmp(lval, "map_h_reply_to_addresses")==0) { |
28 | 665 GList *list, *node; |
0 | 666 |
28 | 667 list = parse_list(rval, TRUE); |
668 foreach(list, node) { | |
669 gchar *item = (gchar *) (node->data); | |
670 table_pair *pair = parse_table_pair(item, ':'); | |
671 route->map_h_reply_to_addresses = g_list_append(route->map_h_reply_to_addresses, pair); | |
672 g_free(item); | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
673 } |
28 | 674 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
|
675 } else if (strcmp(lval, "map_h_mail_followup_to_addresses")==0) { |
28 | 676 GList *list, *node; |
677 | |
678 list = parse_list(rval, TRUE); | |
679 foreach(list, node) { | |
680 gchar *item = (gchar *) (node->data); | |
681 table_pair *pair = parse_table_pair(item, ':'); | |
682 route->map_h_mail_followup_to_addresses = g_list_append(route->map_h_mail_followup_to_addresses, pair); | |
683 g_free(item); | |
684 } | |
685 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
|
686 } else if (strcmp(lval, "expand_h_sender_domain")==0) { |
28 | 687 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
|
688 } else if (strcmp(lval, "expand_h_sender_address")==0) { |
28 | 689 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
|
690 } else if (strcmp(lval, "resolve_list")==0) { |
28 | 691 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
|
692 } else if (strcmp(lval, "do_ssl")==0) { |
28 | 693 /* we ignore this. This option is used by sqilconf */ |
694 ; | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
695 #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
|
696 } else if (strcmp(lval, "auth_name")==0) { |
28 | 697 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
|
698 } else if (strcmp(lval, "auth_login")==0) { |
28 | 699 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
|
700 } else if (strcmp(lval, "auth_secret")==0) { |
28 | 701 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
|
702 #else |
393
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
703 } 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
|
704 (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
|
705 (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
|
706 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
|
707 "auth support.\n", lval); |
28 | 708 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
709 #endif |
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")==0) { |
28 | 711 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
|
712 } else if (strcmp(lval, "pipe_fromline")==0) { |
28 | 713 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
|
714 } else if (strcmp(lval, "pipe_fromhack")==0) { |
28 | 715 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
|
716 } else if (strcmp(lval, "last_route")==0) { |
28 | 717 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
|
718 } else { |
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
719 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
|
720 lval); |
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
721 } |
28 | 722 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
723 |
319 | 724 if (!route->resolve_list) { |
28 | 725 #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
|
726 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
|
727 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
|
728 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
|
729 resolve_dns_a); |
28 | 730 #endif |
393
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
731 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
|
732 resolve_byname); |
28 | 733 } |
734 fclose(in); | |
735 | |
393
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
736 /* 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
|
737 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
|
738 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
|
739 "'set_h_from_domain'\n"); |
28 | 740 g_free(route->set_h_from_domain); |
741 route->set_h_from_domain = NULL; | |
742 } | |
393
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
743 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
|
744 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
|
745 "'set_h_reply_to_domain'\n"); |
28 | 746 g_free(route->set_h_reply_to_domain); |
747 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
|
748 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
749 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
750 return route; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
751 } |
0 | 752 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
753 static void |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
359
diff
changeset
|
754 _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
|
755 { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
756 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
|
757 if (!list) { |
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
758 return; |
0 | 759 } |
393
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
760 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
|
761 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
|
762 } |
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
763 g_list_free(list); |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
764 } |
0 | 765 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
766 void |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
359
diff
changeset
|
767 destroy_route(connect_route *r) |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
768 { |
393
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
769 if (r->filename) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
770 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
|
771 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
772 if (r->mail_host) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
773 g_free(r->mail_host->address); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
774 g_free(r->mail_host); |
0 | 775 } |
393
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
776 if (r->wrapper) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
777 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
|
778 } |
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
779 if (r->helo_name) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
780 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
|
781 } |
317
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
311
diff
changeset
|
782 _g_list_free_all(r->allowed_senders); |
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
311
diff
changeset
|
783 _g_list_free_all(r->denied_senders); |
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
311
diff
changeset
|
784 _g_list_free_all(r->allowed_recipients); |
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
311
diff
changeset
|
785 _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
|
786 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
|
787 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
|
788 } |
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
789 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
|
790 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
|
791 } |
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
792 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
|
793 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
|
794 } |
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
795 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
|
796 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
|
797 } |
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->resolve_list) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
799 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
|
800 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
801 #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
|
802 if (r->auth_name) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
803 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
|
804 } |
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
805 if (r->auth_login) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
806 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
|
807 } |
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->auth_secret) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
809 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
|
810 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
811 #endif |
393
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
812 if (r->pipe) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
813 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
|
814 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
815 g_free(r); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
816 } |
0 | 817 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
818 GList* |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
359
diff
changeset
|
819 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
|
820 { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
821 GList *list = NULL; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
822 GList *node; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
823 uid_t saved_uid, saved_gid; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
824 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
825 if (!conf.run_as_user) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
826 set_euidgid(0, 0, &saved_uid, &saved_gid); |
0 | 827 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
828 foreach(rf_list, node) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
829 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
|
830 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
|
831 if (route) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
832 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
|
833 } else { |
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
834 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
|
835 "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
|
836 } |
10
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 /* set uid and gid back */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
839 if (!conf.run_as_user) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
840 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
|
841 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
842 return list; |
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 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
845 void |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
359
diff
changeset
|
846 destroy_route_list(GList *list) |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
847 { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
848 GList *node; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
849 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
850 foreach(list, node) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
851 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
|
852 destroy_route(route); |
0 | 853 } |
854 g_list_free(list); | |
855 } |