Mercurial > masqmail
annotate src/conf.c @ 392:c5fd796ea06e
Heavy refactoring in parts of conf.c.
init_conf()
parse_boolean()
parse_list_file()
Re-arrangement of code.
parse_address_glob_list()
Removed unneccessary parameter.
parse_list()
parse_interface():
Use strtok()/strchr() instead of doing is all by hand.
Removed limitation of fixed size buffer.
eat_comments()
Use a state machine.
eat_line_trailing()
eat_spaces()
read_lval()
Better structured code.
read_conf()
read_route()
Removed magic numbers.
Made all list type in the config files accept pathname entries,
except for `permanent_routes' and `query_routes.' for which this
is impossible.
author | markus schnalke <meillo@marmaro.de> |
---|---|
date | Sat, 18 Feb 2012 18:07:55 +0100 |
parents | a408411ff8df |
children | 5e728dd64c1b |
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 } |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
94 while (!fgets(buf, sizeof buf, fptr)) { |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
95 g_strstrip(buf); |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
96 if (!*buf || *buf == '#') { |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
97 continue; |
28 | 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; |
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
359
diff
changeset
|
148 char *p; |
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 |
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
311
diff
changeset
|
151 for (p=item+strlen(item)-1; isspace(*p) || *p=='>'; p--) { |
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
311
diff
changeset
|
152 *p = '\0'; |
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
311
diff
changeset
|
153 } |
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
311
diff
changeset
|
154 for (p=item; isspace(*p) || *p=='<'; p++) { |
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
311
diff
changeset
|
155 } |
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 addr->address = strdup(p); |
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
311
diff
changeset
|
158 at = strrchr(p, '@'); |
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
311
diff
changeset
|
159 if (at) { |
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
311
diff
changeset
|
160 *at = '\0'; |
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
311
diff
changeset
|
161 addr->local_part = strdup(p); |
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
311
diff
changeset
|
162 addr->domain = strdup(at+1); |
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
311
diff
changeset
|
163 } else { |
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
311
diff
changeset
|
164 addr->local_part = strdup(p); |
330
f899ca0835a8
Fixed local-part only address patterns in route conditions
markus schnalke <meillo@marmaro.de>
parents:
329
diff
changeset
|
165 /* 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
|
166 addr->domain = "*"; |
317
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
311
diff
changeset
|
167 } |
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
311
diff
changeset
|
168 list = g_list_append(list, addr); |
392
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
169 DEBUG(6) debugf("parse_address_glob_list: " |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
170 "read pattern `%s' `%s'\n", |
317
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
311
diff
changeset
|
171 addr->local_part, addr->domain); |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
172 g_free(item); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
173 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
174 g_list_free(plain_list); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
175 return list; |
0 | 176 } |
177 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
178 static GList* |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
359
diff
changeset
|
179 parse_resolve_list(gchar *line) |
0 | 180 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
181 GList *list; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
182 GList *list_node; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
183 GList *res_list = NULL; |
392
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
184 gchar *item; |
0 | 185 |
392
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
186 list = parse_list(line, TRUE); |
28 | 187 if (!list) { |
188 return NULL; | |
189 } | |
190 foreach(list, list_node) { | |
392
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
191 item = (gchar *) list_node->data; |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
192 if (strcmp(item, "byname")==0) { |
28 | 193 res_list = g_list_append(res_list, resolve_byname); |
0 | 194 #ifdef ENABLE_RESOLVER |
392
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
195 } else if (strcmp(item, "dns_a")==0) { |
28 | 196 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
|
197 } else if (strcmp(item, "dns_mx")==0) { |
28 | 198 res_list = g_list_append(res_list, resolve_dns_mx); |
0 | 199 #endif |
28 | 200 } else { |
201 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
|
202 exit(1); |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
203 } |
28 | 204 g_free(item); |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
205 } |
28 | 206 g_list_free(list); |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
207 return res_list; |
0 | 208 } |
209 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
210 static interface* |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
359
diff
changeset
|
211 parse_interface(gchar *line, gint def_port) |
0 | 212 { |
392
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
213 gchar *cp; |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
214 interface *iface = g_malloc(sizeof(interface)); |
0 | 215 |
333
0bd27f603910
Added debug level 9 for msgs to stderr during reading config
markus schnalke <meillo@marmaro.de>
parents:
330
diff
changeset
|
216 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
|
217 if ((cp = strchr(line, ':'))) { |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
218 *cp = '\0'; |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
219 } |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
220 iface->address = g_strdup(line); |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
221 iface->port = (cp) ? atoi(++cp) : def_port; |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
222 DEBUG(9) fprintf(stderr,"found: address:port=%s:%u\n", |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
223 iface->address, iface->port); |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
224 return iface; |
0 | 225 } |
226 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
227 static gboolean |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
359
diff
changeset
|
228 eat_comments(FILE *in) |
0 | 229 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
230 gint c; |
392
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
231 int incomment = 0; |
0 | 232 |
392
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
233 while ((c = fgetc(in)) != EOF) { |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
234 if (incomment) { |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
235 /* eat until end of line */ |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
236 if (c == '\n') { |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
237 incomment = 0; |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
238 continue; |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
239 } else { |
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 } |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
242 } else { |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
243 /* eat whitespace and watch for comments */ |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
244 if (isspace(c)) { |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
245 continue; |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
246 } else if (c == '#') { |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
247 incomment = 1; |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
248 continue; |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
249 } else { |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
250 /* found something (that's not our business) */ |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
251 ungetc(c, in); |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
252 return TRUE; |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
253 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
254 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
255 } |
392
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
256 return FALSE; |
0 | 257 } |
258 | |
392
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
259 /* |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
260 ** after parsing, eat trailing characters until and including the Newline |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
261 */ |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
262 static gboolean |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
359
diff
changeset
|
263 eat_line_trailing(FILE *in) |
0 | 264 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
265 gint c; |
0 | 266 |
392
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
267 while ((c = fgetc(in)) != EOF) { |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
268 if (c == '\n') { |
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 } |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
271 } |
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 eat_spaces(FILE *in) |
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 |
392
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
280 while ((c = fgetc(in)) != EOF) { |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
281 if (!isspace(c)) { |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
282 ungetc(c, in); |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
283 return TRUE; |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
284 } |
28 | 285 } |
392
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
286 return FALSE; |
0 | 287 } |
288 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
289 static gboolean |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
359
diff
changeset
|
290 read_lval(FILE *in, gchar *buf, gint size) |
0 | 291 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
292 gint c; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
293 gchar *ptr = buf; |
0 | 294 |
333
0bd27f603910
Added debug level 9 for msgs to stderr during reading config
markus schnalke <meillo@marmaro.de>
parents:
330
diff
changeset
|
295 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
|
296 if (!eat_spaces(in)) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
297 return FALSE; |
392
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
298 } |
0 | 299 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
300 c = fgetc(in); |
333
0bd27f603910
Added debug level 9 for msgs to stderr during reading config
markus schnalke <meillo@marmaro.de>
parents:
330
diff
changeset
|
301 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
|
302 while (1) { |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
303 if ((c = fgetc(in)) == EOF) { |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
304 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
|
305 return FALSE; |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
306 } |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
307 if (ptr >= buf+size-1) { |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
308 fprintf(stderr, "lval too long\n"); |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
309 break; |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
310 } |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
311 if (!isalnum(c) && c != '_' && c != '-' && c != '.') { |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
312 break; |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
313 } |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
314 *ptr++ = c; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
315 } |
14
a8f3424347dc
replaced number 0 with character \0 where appropriate
meillo@marmaro.de
parents:
13
diff
changeset
|
316 *ptr = '\0'; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
317 ungetc(c, in); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
318 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
|
319 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
|
320 return *buf != '\0'; |
0 | 321 } |
322 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
323 static gboolean |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
359
diff
changeset
|
324 read_rval(FILE *in, gchar *buf, gint size) |
0 | 325 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
326 gint c; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
327 gchar *ptr = buf; |
0 | 328 |
333
0bd27f603910
Added debug level 9 for msgs to stderr during reading config
markus schnalke <meillo@marmaro.de>
parents:
330
diff
changeset
|
329 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
|
330 if (!eat_spaces(in)) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
331 return FALSE; |
392
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
332 } |
0 | 333 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
334 c = fgetc(in); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
335 if (c != '\"') { |
115
315773f814f7
allow `:' unquoted too; updated masqmail.conf.5 (Thanks to Paolo)
meillo@marmaro.de
parents:
114
diff
changeset
|
336 while ((isalnum(c) || c == '_' || c == '-' || c == '.' |
315773f814f7
allow `:' unquoted too; updated masqmail.conf.5 (Thanks to Paolo)
meillo@marmaro.de
parents:
114
diff
changeset
|
337 || c == '/' || c == '@' || c == ';' || c == ':') |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
338 && (ptr < buf + size - 1) |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
339 && (c != EOF)) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
340 *ptr = c; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
341 ptr++; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
342 c = fgetc(in); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
343 } |
14
a8f3424347dc
replaced number 0 with character \0 where appropriate
meillo@marmaro.de
parents:
13
diff
changeset
|
344 *ptr = '\0'; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
345 ungetc(c, in); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
346 } else { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
347 gboolean escape = FALSE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
348 c = fgetc(in); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
349 while (((c != '\"') || escape) && (ptr < buf + size - 1)) { |
13 | 350 if (c != '\n') { /* ignore line breaks */ |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
351 if ((c == '\\') && (!escape)) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
352 escape = TRUE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
353 } else { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
354 *ptr = c; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
355 ptr++; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
356 escape = FALSE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
357 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
358 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
359 c = fgetc(in); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
360 } |
14
a8f3424347dc
replaced number 0 with character \0 where appropriate
meillo@marmaro.de
parents:
13
diff
changeset
|
361 *ptr = '\0'; |
0 | 362 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
363 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
364 eat_line_trailing(in); |
0 | 365 |
333
0bd27f603910
Added debug level 9 for msgs to stderr during reading config
markus schnalke <meillo@marmaro.de>
parents:
330
diff
changeset
|
366 DEBUG(9) fprintf(stderr, "rval = %s\n", buf); |
0 | 367 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
368 return TRUE; |
0 | 369 } |
370 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
371 static gboolean |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
359
diff
changeset
|
372 read_statement(FILE *in, gchar *lval, gint lsize, gchar *rval, gint rsize) |
0 | 373 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
374 gint c; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
375 |
333
0bd27f603910
Added debug level 9 for msgs to stderr during reading config
markus schnalke <meillo@marmaro.de>
parents:
330
diff
changeset
|
376 DEBUG(9) fprintf(stderr, "read_statement()\n"); |
0 | 377 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
378 /* eat comments and empty lines: */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
379 if (!eat_comments(in)) |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
380 return FALSE; |
0 | 381 |
28 | 382 if (!read_lval(in, lval, lsize)) { |
383 return FALSE; | |
384 } | |
385 | |
333
0bd27f603910
Added debug level 9 for msgs to stderr during reading config
markus schnalke <meillo@marmaro.de>
parents:
330
diff
changeset
|
386 DEBUG(9) fprintf(stderr, " lval = %s\n", lval); |
28 | 387 if ((c = fgetc(in) == '=')) { |
388 if (read_rval(in, rval, rsize)) { | |
333
0bd27f603910
Added debug level 9 for msgs to stderr during reading config
markus schnalke <meillo@marmaro.de>
parents:
330
diff
changeset
|
389 DEBUG(9) fprintf(stderr, " rval = %s\n", rval); |
28 | 390 return TRUE; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
391 } |
28 | 392 } else { |
333
0bd27f603910
Added debug level 9 for msgs to stderr during reading config
markus schnalke <meillo@marmaro.de>
parents:
330
diff
changeset
|
393 DEBUG(9) fprintf(stderr," '=' expected after %s, char was '%c'\n", lval, c); |
28 | 394 fprintf(stderr, "'=' expected after %s, char was '%c'\n", lval, c); |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
395 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
396 return FALSE; |
0 | 397 } |
398 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
399 gboolean |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
359
diff
changeset
|
400 read_conf(gchar *filename) |
0 | 401 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
402 FILE *in; |
0 | 403 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
404 conf.log_max_pri = 7; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
405 conf.do_relay = TRUE; |
244
7082044c05c6
renamed `alias_local_cmp' to `localpartcmp'
markus schnalke <meillo@marmaro.de>
parents:
243
diff
changeset
|
406 conf.localpartcmp = strcmp; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
407 conf.max_defer_time = 86400 * 4; /* 4 days */ |
120
cd59a5b4d3dd
added support for SMTP SIZE 0 (unlimited)
meillo@marmaro.de
parents:
117
diff
changeset
|
408 conf.max_msg_size = 0; /* no limit on msg size */ |
151 | 409 conf.spool_dir = SPOOL_DIR; |
152 | 410 conf.mail_dir = "/var/mail"; |
329
5ce2b1280679
Switched back from 127.0.0.1 to localhost
markus schnalke <meillo@marmaro.de>
parents:
319
diff
changeset
|
411 conf.listen_addresses = g_list_append(NULL, parse_interface("localhost", 25)); |
0 | 412 |
28 | 413 if ((in = fopen(filename, "r")) == NULL) { |
155 | 414 logwrite(LOG_ALERT, "could not open config file %s: %s\n", filename, strerror(errno)); |
28 | 415 return FALSE; |
416 } | |
0 | 417 |
28 | 418 gchar lval[256], rval[2048]; |
392
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
419 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
|
420 DEBUG(9) fprintf(stderr,"read_conf(): lval=%s\n", lval); |
28 | 421 if (strcmp(lval, "debug_level") == 0) |
422 conf.debug_level = atoi(rval); | |
423 else if (strcmp(lval, "run_as_user") == 0) { | |
424 if (!conf.run_as_user) /* you should not be able to reset that flag */ | |
425 conf.run_as_user = parse_boolean(rval); | |
426 } else if (strcmp(lval, "use_syslog") == 0) | |
427 conf.use_syslog = parse_boolean(rval); | |
428 else if (strcmp(lval, "mail_dir") == 0) | |
429 conf.mail_dir = g_strdup(rval); | |
430 else if (strcmp(lval, "lock_dir") == 0) | |
431 conf.lock_dir = g_strdup(rval); | |
432 else if (strcmp(lval, "spool_dir") == 0) | |
433 conf.spool_dir = g_strdup(rval); | |
434 else if (strcmp(lval, "log_dir") == 0) | |
435 conf.log_dir = g_strdup(rval); | |
436 else if (strcmp(lval, "host_name") == 0) { | |
437 if (rval[0] != '/') | |
438 conf.host_name = g_strdup(rval); | |
439 else { | |
440 char buf[256]; | |
441 FILE *fptr = fopen(rval, "rt"); | |
307 | 442 if (!fptr) { |
155 | 443 logwrite(LOG_ALERT, "could not open %s: %s\n", rval, strerror(errno)); |
28 | 444 return FALSE; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
445 } |
28 | 446 fgets(buf, 255, fptr); |
447 g_strchomp(buf); | |
448 conf.host_name = g_strdup(buf); | |
449 fclose(fptr); | |
450 } | |
451 } 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
|
452 conf.local_hosts = parse_list(rval, TRUE); |
28 | 453 else if (strcmp(lval, "local_addresses") == 0) |
454 conf.local_addresses = parse_list(rval, TRUE); | |
455 else if (strcmp(lval, "not_local_addresses") == 0) | |
456 conf.not_local_addresses = parse_list(rval, TRUE); | |
457 else if (strcmp(lval, "do_save_envelope_to") == 0) | |
458 conf.do_save_envelope_to = parse_boolean(rval); | |
459 else if (strcmp(lval, "defer_all") == 0) | |
460 conf.defer_all = parse_boolean(rval); | |
461 else if (strcmp(lval, "do_relay") == 0) | |
462 conf.do_relay = parse_boolean(rval); | |
463 else if (strcmp(lval, "alias_file") == 0) { | |
464 conf.alias_file = g_strdup(rval); | |
387
a408411ff8df
Added a glob-pattern aliasing facility.
markus schnalke <meillo@marmaro.de>
parents:
378
diff
changeset
|
465 } else if (strcmp(lval, "globalias_file") == 0) { |
a408411ff8df
Added a glob-pattern aliasing facility.
markus schnalke <meillo@marmaro.de>
parents:
378
diff
changeset
|
466 conf.globalias_file = g_strdup(rval); |
243
e758296de02d
renamed `alias_local_caseless' to `caseless_matching'
markus schnalke <meillo@marmaro.de>
parents:
234
diff
changeset
|
467 } else if (strcmp(lval, "caseless_matching") == 0) { |
244
7082044c05c6
renamed `alias_local_cmp' to `localpartcmp'
markus schnalke <meillo@marmaro.de>
parents:
243
diff
changeset
|
468 conf.localpartcmp = parse_boolean(rval) ? strcasecmp : strcmp; |
28 | 469 } else if (strcmp(lval, "mbox_default") == 0) { |
470 conf.mbox_default = g_strdup(rval); | |
471 } else if (strcmp(lval, "mbox_users") == 0) { | |
472 conf.mbox_users = parse_list(rval, TRUE); | |
473 } else if (strcmp(lval, "mda_users") == 0) { | |
474 conf.mda_users = parse_list(rval, TRUE); | |
475 } else if (strcmp(lval, "mda") == 0) { | |
476 conf.mda = g_strdup(rval); | |
477 } else if (strcmp(lval, "mda_fromline") == 0) { | |
478 conf.mda_fromline = parse_boolean(rval); | |
479 } else if (strcmp(lval, "mda_fromhack") == 0) { | |
480 conf.mda_fromhack = parse_boolean(rval); | |
481 } else if (strcmp(lval, "pipe_fromline") == 0) { | |
482 conf.pipe_fromline = parse_boolean(rval); | |
483 } else if (strcmp(lval, "pipe_fromhack") == 0) { | |
484 conf.pipe_fromhack = parse_boolean(rval); | |
485 } else if (strcmp(lval, "listen_addresses") == 0) { | |
486 GList *node; | |
392
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
487 GList *tmp_list = parse_list(rval, TRUE); |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
488 |
28 | 489 conf.listen_addresses = NULL; |
490 foreach(tmp_list, node) { | |
491 conf.listen_addresses = g_list_append(conf.listen_addresses, parse_interface((gchar *) (node-> data), 25)); | |
492 g_free(node->data); | |
493 } | |
494 g_list_free(tmp_list); | |
354
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
333
diff
changeset
|
495 } else if (strncmp(lval, "query_routes.", 13) == 0) { |
28 | 496 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
|
497 table_pair *pair = create_pair(lval+13, file_list); |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
333
diff
changeset
|
498 conf.query_routes = g_list_append(conf.query_routes, pair); |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
333
diff
changeset
|
499 } else if (strcmp(lval, "permanent_routes") == 0) { |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
333
diff
changeset
|
500 conf.perma_routes = parse_list(rval, FALSE); |
310
f10a56dc7481
reworked online_detect to the simpler online_query
meillo@marmaro.de
parents:
307
diff
changeset
|
501 } else if (strcmp(lval, "online_query") == 0) |
f10a56dc7481
reworked online_detect to the simpler online_query
meillo@marmaro.de
parents:
307
diff
changeset
|
502 conf.online_query = g_strdup(rval); |
28 | 503 else if (strcmp(lval, "do_queue") == 0) |
504 conf.do_queue = parse_boolean(rval); | |
192 | 505 else if (strcmp(lval, "errmsg_file") == 0) |
28 | 506 conf.errmsg_file = g_strdup(rval); |
507 else if (strcmp(lval, "warnmsg_file") == 0) | |
508 conf.warnmsg_file = g_strdup(rval); | |
509 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
|
510 conf.warn_intervals = parse_list(rval, TRUE); |
28 | 511 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
|
512 gint ival = time_interval(rval); |
28 | 513 if (ival < 0) |
155 | 514 logwrite(LOG_WARNING, "invalid time interval for 'max_defer_time': %s\n", rval); |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
515 else |
28 | 516 conf.max_defer_time = ival; |
517 } else if (strcmp(lval, "log_user") == 0) | |
518 conf.log_user = g_strdup(rval); | |
117
5ec5e6637049
added server-side SMTP SIZE support (patch by Paolo)
meillo@marmaro.de
parents:
115
diff
changeset
|
519 else if(strcmp(lval, "max_msg_size") == 0) { |
5ec5e6637049
added server-side SMTP SIZE support (patch by Paolo)
meillo@marmaro.de
parents:
115
diff
changeset
|
520 conf.max_msg_size = atol(rval); |
333
0bd27f603910
Added debug level 9 for msgs to stderr during reading config
markus schnalke <meillo@marmaro.de>
parents:
330
diff
changeset
|
521 DEBUG(9) fprintf(stderr,"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
|
522 rval, conf.max_msg_size); |
5ec5e6637049
added server-side SMTP SIZE support (patch by Paolo)
meillo@marmaro.de
parents:
115
diff
changeset
|
523 } |
28 | 524 else |
155 | 525 logwrite(LOG_WARNING, "var '%s' not (yet) known, ignored\n", lval); |
28 | 526 } |
527 fclose(in); | |
0 | 528 |
156
ee2afbf92428
require host_name to be set in config file
meillo@marmaro.de
parents:
155
diff
changeset
|
529 if (!conf.host_name) { |
ee2afbf92428
require host_name to be set in config file
meillo@marmaro.de
parents:
155
diff
changeset
|
530 logwrite(LOG_ALERT, "`host_name' MUST be set in masqmail.conf. See man page\n"); |
ee2afbf92428
require host_name to be set in config file
meillo@marmaro.de
parents:
155
diff
changeset
|
531 return FALSE; |
ee2afbf92428
require host_name to be set in config file
meillo@marmaro.de
parents:
155
diff
changeset
|
532 } |
ee2afbf92428
require host_name to be set in config file
meillo@marmaro.de
parents:
155
diff
changeset
|
533 |
28 | 534 if (conf.errmsg_file == NULL) |
535 conf.errmsg_file = g_strdup(DATA_DIR "/tpl/failmsg.tpl"); | |
536 if (conf.warnmsg_file == NULL) | |
537 conf.warnmsg_file = g_strdup(DATA_DIR "/tpl/warnmsg.tpl"); | |
0 | 538 |
28 | 539 if (conf.lock_dir == NULL) |
540 conf.lock_dir = g_strdup_printf("%s/lock/", conf.spool_dir); | |
0 | 541 |
28 | 542 if (conf.mbox_default == NULL) |
543 conf.mbox_default = g_strdup("mbox"); | |
0 | 544 |
28 | 545 if (conf.warn_intervals == NULL) |
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); |
28 | 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 } |
586f001f5bbd
local_hosts defaults to localhost;foo;foo.example.org now
meillo@marmaro.de
parents:
156
diff
changeset
|
561 |
586f001f5bbd
local_hosts defaults to localhost;foo;foo.example.org now
meillo@marmaro.de
parents:
156
diff
changeset
|
562 |
28 | 563 return TRUE; |
0 | 564 } |
565 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
566 connect_route* |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
359
diff
changeset
|
567 read_route(gchar *filename, gboolean is_perma) |
0 | 568 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
569 gboolean ok = FALSE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
570 FILE *in; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
571 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
572 connect_route *route = g_malloc(sizeof(connect_route)); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
573 memset(route, 0, sizeof(connect_route)); |
0 | 574 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
575 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
|
576 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
577 route->filename = g_strdup(filename); |
357 | 578 route->name = route->filename; /* quick hack */ |
0 | 579 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
580 route->expand_h_sender_address = TRUE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
581 |
354
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
333
diff
changeset
|
582 route->is_perma = is_perma; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
583 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
584 route->do_pipelining = TRUE; |
0 | 585 |
28 | 586 if ((in = fopen(route->filename, "r")) == NULL) { |
587 logwrite(LOG_ALERT, "could not open route file %s: %s\n", route->filename, strerror(errno)); | |
588 g_free(route); | |
589 return NULL; | |
590 } | |
0 | 591 |
28 | 592 gchar lval[256], rval[2048]; |
392
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
593 while (read_statement(in, lval, sizeof lval, rval, sizeof rval)) { |
311
e230bcd0f1c6
removed protocol option from route config
meillo@marmaro.de
parents:
310
diff
changeset
|
594 if (strcmp(lval, "mail_host") == 0) |
178 | 595 route->mail_host = parse_interface(rval, 25); |
28 | 596 else if (strcmp(lval, "helo_name") == 0) |
597 route->helo_name = g_strdup(rval); | |
598 else if (strcmp(lval, "wrapper") == 0) | |
599 route->wrapper = g_strdup(rval); | |
600 else if (strcmp(lval, "connect_error_fail") == 0) | |
601 route->connect_error_fail = parse_boolean(rval); | |
602 else if (strcmp(lval, "do_correct_helo") == 0) | |
603 route->do_correct_helo = parse_boolean(rval); | |
222 | 604 else if (strcmp(lval, "instant_helo") == 0) |
605 route->instant_helo = parse_boolean(rval); | |
28 | 606 else if (strcmp(lval, "do_pipelining") == 0) |
607 route->do_pipelining = parse_boolean(rval); | |
317
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
311
diff
changeset
|
608 |
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
311
diff
changeset
|
609 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
|
610 route->allowed_senders = parse_address_glob_list(rval); |
317
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
311
diff
changeset
|
611 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
|
612 route->denied_senders = parse_address_glob_list(rval); |
317
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
311
diff
changeset
|
613 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
|
614 route->allowed_recipients = parse_address_glob_list(rval); |
317
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
311
diff
changeset
|
615 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
|
616 route->denied_recipients = parse_address_glob_list(rval); |
317
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
311
diff
changeset
|
617 |
28 | 618 else if (strcmp(lval, "set_h_from_domain") == 0) |
619 route->set_h_from_domain = g_strdup(rval); | |
620 else if (strcmp(lval, "set_h_reply_to_domain") == 0) | |
621 route->set_h_reply_to_domain = g_strdup(rval); | |
622 else if (strcmp(lval, "set_return_path_domain") == 0) | |
623 route->set_return_path_domain = g_strdup(rval); | |
624 else if (strcmp(lval, "map_return_path_addresses") == 0) { | |
625 GList *node, *list; | |
0 | 626 |
28 | 627 list = parse_list(rval, TRUE); |
628 foreach(list, node) { | |
629 gchar *item = (gchar *) (node->data); | |
630 table_pair *pair = parse_table_pair(item, ':'); | |
631 address *addr = create_address((gchar *) (pair->value), TRUE); | |
632 g_free(pair->value); | |
633 pair->value = (gpointer *) addr; | |
634 route->map_return_path_addresses = g_list_append(route->map_return_path_addresses, pair); | |
635 g_free(item); | |
636 } | |
637 g_list_free(list); | |
638 } else if (strcmp(lval, "map_h_from_addresses") == 0) { | |
639 GList *list, *node; | |
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, ':'); | |
645 route->map_h_from_addresses = g_list_append(route->map_h_from_addresses, pair); | |
646 g_free(item); | |
647 } | |
648 g_list_free(list); | |
649 } else if (strcmp(lval, "map_h_reply_to_addresses") == 0) { | |
650 GList *list, *node; | |
0 | 651 |
28 | 652 list = parse_list(rval, TRUE); |
653 foreach(list, node) { | |
654 gchar *item = (gchar *) (node->data); | |
655 table_pair *pair = parse_table_pair(item, ':'); | |
656 route->map_h_reply_to_addresses = g_list_append(route->map_h_reply_to_addresses, pair); | |
657 g_free(item); | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
658 } |
28 | 659 g_list_free(list); |
660 } else if (strcmp(lval, "map_h_mail_followup_to_addresses") == 0) { | |
661 GList *list, *node; | |
662 | |
663 list = parse_list(rval, TRUE); | |
664 foreach(list, node) { | |
665 gchar *item = (gchar *) (node->data); | |
666 table_pair *pair = parse_table_pair(item, ':'); | |
667 route->map_h_mail_followup_to_addresses = g_list_append(route->map_h_mail_followup_to_addresses, pair); | |
668 g_free(item); | |
669 } | |
670 g_list_free(list); | |
671 } else if (strcmp(lval, "expand_h_sender_domain") == 0) { | |
672 route->expand_h_sender_domain = parse_boolean(rval); | |
673 } else if (strcmp(lval, "expand_h_sender_address") == 0) { | |
674 route->expand_h_sender_address = parse_boolean(rval); | |
675 } else if (strcmp(lval, "resolve_list") == 0) | |
676 route->resolve_list = parse_resolve_list(rval); | |
677 else if (strcmp(lval, "do_ssl") == 0) { | |
678 /* we ignore this. This option is used by sqilconf */ | |
679 ; | |
680 } | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
681 #ifdef ENABLE_AUTH |
28 | 682 else if (strcmp(lval, "auth_name") == 0) { |
683 route->auth_name = g_strdup(rval); | |
684 } else if (strcmp(lval, "auth_login") == 0) { | |
685 route->auth_login = g_strdup(rval); | |
686 } else if (strcmp(lval, "auth_secret") == 0) { | |
687 route->auth_secret = g_strdup(rval); | |
688 } | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
689 #else |
28 | 690 else if ((strcmp(lval, "auth_name") == 0) |
691 || (strcmp(lval, "auth_login") == 0) | |
692 || (strcmp(lval, "auth_secret") == 0)) { | |
693 logwrite(LOG_WARNING, "%s ignored: not compiled with auth support.\n", lval); | |
694 } | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
695 #endif |
190
6b4a101a2455
forgot to remove the pop3_login option in conf.c in the last commit
meillo@marmaro.de
parents:
178
diff
changeset
|
696 else if (strcmp(lval, "pipe") == 0) { |
28 | 697 route->pipe = g_strdup(rval); |
698 } else if (strcmp(lval, "pipe_fromline") == 0) { | |
699 route->pipe_fromline = parse_boolean(rval); | |
700 } else if (strcmp(lval, "pipe_fromhack") == 0) { | |
701 route->pipe_fromhack = parse_boolean(rval); | |
702 } else if (strcmp(lval, "last_route") == 0) { | |
703 route->last_route = parse_boolean(rval); | |
704 } else | |
705 logwrite(LOG_WARNING, "var '%s' not (yet) known, ignored\n", lval); | |
706 } | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
707 |
319 | 708 if (!route->resolve_list) { |
28 | 709 #ifdef ENABLE_RESOLVER |
354
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
333
diff
changeset
|
710 route->resolve_list = g_list_append(route->resolve_list, resolve_dns_mx); |
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
333
diff
changeset
|
711 route->resolve_list = g_list_append(route->resolve_list, resolve_dns_a); |
28 | 712 #endif |
319 | 713 route->resolve_list = g_list_append(route->resolve_list, resolve_byname); |
28 | 714 } |
715 fclose(in); | |
716 ok = TRUE; | |
717 | |
718 /* warn user about misconfigurations: */ | |
719 if ((route->map_h_from_addresses != NULL) && (route->set_h_from_domain != NULL)) { | |
720 logwrite(LOG_WARNING, "'map_h_from_addresses' overrides 'set_h_from_domain'\n"); | |
721 g_free(route->set_h_from_domain); | |
722 route->set_h_from_domain = NULL; | |
723 } | |
724 if ((route->map_h_reply_to_addresses != NULL) && (route->set_h_reply_to_domain != NULL)) { | |
725 logwrite(LOG_WARNING, "'map_h_reply_to_addresses' overrides 'set_h_reply_to_domain'\n"); | |
726 g_free(route->set_h_reply_to_domain); | |
727 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
|
728 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
729 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
730 if (!ok) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
731 g_free(route); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
732 route = NULL; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
733 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
734 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
735 return route; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
736 } |
0 | 737 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
738 static void |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
359
diff
changeset
|
739 _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
|
740 { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
741 GList *node; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
742 if (list) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
743 foreach(list, node) |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
744 g_free(node->data); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
745 g_list_free(list); |
0 | 746 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
747 } |
0 | 748 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
749 void |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
359
diff
changeset
|
750 destroy_route(connect_route *r) |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
751 { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
752 if (r->filename) |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
753 g_free(r->filename); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
754 if (r->mail_host) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
755 g_free(r->mail_host->address); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
756 g_free(r->mail_host); |
0 | 757 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
758 if (r->wrapper) |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
759 g_free(r->wrapper); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
760 if (r->helo_name) |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
761 g_free(r->helo_name); |
317
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
311
diff
changeset
|
762 _g_list_free_all(r->allowed_senders); |
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
311
diff
changeset
|
763 _g_list_free_all(r->denied_senders); |
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
311
diff
changeset
|
764 _g_list_free_all(r->allowed_recipients); |
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
311
diff
changeset
|
765 _g_list_free_all(r->denied_recipients); |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
766 if (r->set_h_from_domain) |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
767 g_free(r->set_h_from_domain); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
768 if (r->set_h_reply_to_domain) |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
769 g_free(r->set_h_reply_to_domain); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
770 if (r->set_return_path_domain) |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
771 g_free(r->set_return_path_domain); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
772 if (r->map_h_reply_to_addresses) |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
773 destroy_table(r->map_h_reply_to_addresses); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
774 if (r->resolve_list) |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
775 g_list_free(r->resolve_list); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
776 #ifdef ENABLE_AUTH |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
777 if (r->auth_name) |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
778 g_free(r->auth_name); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
779 if (r->auth_login) |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
780 g_free(r->auth_login); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
781 if (r->auth_secret) |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
782 g_free(r->auth_secret); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
783 #endif |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
784 if (r->pipe) |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
785 g_free(r->pipe); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
786 g_free(r); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
787 } |
0 | 788 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
789 GList* |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
359
diff
changeset
|
790 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
|
791 { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
792 GList *list = NULL; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
793 GList *node; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
794 uid_t saved_uid, saved_gid; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
795 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
796 if (!conf.run_as_user) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
797 set_euidgid(0, 0, &saved_uid, &saved_gid); |
0 | 798 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
799 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
800 foreach(rf_list, node) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
801 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
|
802 connect_route *route = read_route(fname, is_perma); |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
803 if (route) |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
804 list = g_list_append(list, route); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
805 else |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
806 logwrite(LOG_ALERT, "could not read route configuration %s\n", fname); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
807 } |
0 | 808 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
809 /* set uid and gid back */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
810 if (!conf.run_as_user) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
811 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
|
812 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
813 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
814 return list; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
815 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
816 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
817 void |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
359
diff
changeset
|
818 destroy_route_list(GList *list) |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
819 { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
820 GList *node; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
821 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
822 foreach(list, node) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
823 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
|
824 destroy_route(route); |
0 | 825 } |
826 g_list_free(list); | |
827 } |