Mercurial > masqmail
annotate src/conf.c @ 399:c7cc3c03193c
Minor refactoring.
author | markus schnalke <meillo@marmaro.de> |
---|---|
date | Tue, 21 Feb 2012 15:02:07 +0100 |
parents | 6f2a8113a79e |
children | eedc23877cd5 |
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 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
259 static gboolean |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
359
diff
changeset
|
260 eat_spaces(FILE *in) |
0 | 261 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
262 gint c; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
263 |
392
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
264 while ((c = fgetc(in)) != EOF) { |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
265 if (!isspace(c)) { |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
266 ungetc(c, in); |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
267 return TRUE; |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
268 } |
28 | 269 } |
392
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
270 return FALSE; |
0 | 271 } |
272 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
273 static gboolean |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
359
diff
changeset
|
274 read_lval(FILE *in, gchar *buf, gint size) |
0 | 275 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
276 gint c; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
277 gchar *ptr = buf; |
0 | 278 |
333
0bd27f603910
Added debug level 9 for msgs to stderr during reading config
markus schnalke <meillo@marmaro.de>
parents:
330
diff
changeset
|
279 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
|
280 if (!eat_spaces(in)) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
281 return FALSE; |
392
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
282 } |
0 | 283 |
333
0bd27f603910
Added debug level 9 for msgs to stderr during reading config
markus schnalke <meillo@marmaro.de>
parents:
330
diff
changeset
|
284 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
|
285 while (1) { |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
286 if ((c = fgetc(in)) == EOF) { |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
287 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
|
288 return FALSE; |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
289 } |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
290 if (ptr >= buf+size-1) { |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
291 fprintf(stderr, "lval too long\n"); |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
292 break; |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
293 } |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
294 if (!isalnum(c) && c != '_' && c != '-' && c != '.') { |
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 *ptr++ = c; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
298 } |
14
a8f3424347dc
replaced number 0 with character \0 where appropriate
meillo@marmaro.de
parents:
13
diff
changeset
|
299 *ptr = '\0'; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
300 ungetc(c, in); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
301 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
|
302 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
|
303 return *buf != '\0'; |
0 | 304 } |
305 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
306 static gboolean |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
359
diff
changeset
|
307 read_rval(FILE *in, gchar *buf, gint size) |
0 | 308 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
309 gint c; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
310 gchar *ptr = buf; |
0 | 311 |
333
0bd27f603910
Added debug level 9 for msgs to stderr during reading config
markus schnalke <meillo@marmaro.de>
parents:
330
diff
changeset
|
312 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
|
313 if (!eat_spaces(in)) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
314 return FALSE; |
392
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
315 } |
0 | 316 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
317 c = fgetc(in); |
394
c8e3d1a79313
Refactoring in conf.c: read_rval().
markus schnalke <meillo@marmaro.de>
parents:
393
diff
changeset
|
318 if (c != '"') { |
c8e3d1a79313
Refactoring in conf.c: read_rval().
markus schnalke <meillo@marmaro.de>
parents:
393
diff
changeset
|
319 /* unquoted rval */ |
c8e3d1a79313
Refactoring in conf.c: read_rval().
markus schnalke <meillo@marmaro.de>
parents:
393
diff
changeset
|
320 ungetc(c, in); |
c8e3d1a79313
Refactoring in conf.c: read_rval().
markus schnalke <meillo@marmaro.de>
parents:
393
diff
changeset
|
321 while ((c = fgetc(in)) != EOF) { |
c8e3d1a79313
Refactoring in conf.c: read_rval().
markus schnalke <meillo@marmaro.de>
parents:
393
diff
changeset
|
322 if (ptr >= buf+size-1) { |
c8e3d1a79313
Refactoring in conf.c: read_rval().
markus schnalke <meillo@marmaro.de>
parents:
393
diff
changeset
|
323 /* rval too long */ |
c8e3d1a79313
Refactoring in conf.c: read_rval().
markus schnalke <meillo@marmaro.de>
parents:
393
diff
changeset
|
324 break; |
c8e3d1a79313
Refactoring in conf.c: read_rval().
markus schnalke <meillo@marmaro.de>
parents:
393
diff
changeset
|
325 } |
c8e3d1a79313
Refactoring in conf.c: read_rval().
markus schnalke <meillo@marmaro.de>
parents:
393
diff
changeset
|
326 if (!isalnum(c) && c != '_' && c != '-' && |
c8e3d1a79313
Refactoring in conf.c: read_rval().
markus schnalke <meillo@marmaro.de>
parents:
393
diff
changeset
|
327 c != '.' && c != '/' && c != '@' && |
c8e3d1a79313
Refactoring in conf.c: read_rval().
markus schnalke <meillo@marmaro.de>
parents:
393
diff
changeset
|
328 c != ';' && c != ':') { |
c8e3d1a79313
Refactoring in conf.c: read_rval().
markus schnalke <meillo@marmaro.de>
parents:
393
diff
changeset
|
329 break; |
c8e3d1a79313
Refactoring in conf.c: read_rval().
markus schnalke <meillo@marmaro.de>
parents:
393
diff
changeset
|
330 } |
c8e3d1a79313
Refactoring in conf.c: read_rval().
markus schnalke <meillo@marmaro.de>
parents:
393
diff
changeset
|
331 *ptr++ = c; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
332 } |
14
a8f3424347dc
replaced number 0 with character \0 where appropriate
meillo@marmaro.de
parents:
13
diff
changeset
|
333 *ptr = '\0'; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
334 ungetc(c, in); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
335 } else { |
394
c8e3d1a79313
Refactoring in conf.c: read_rval().
markus schnalke <meillo@marmaro.de>
parents:
393
diff
changeset
|
336 /* quoted rval */ |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
337 gboolean escape = FALSE; |
394
c8e3d1a79313
Refactoring in conf.c: read_rval().
markus schnalke <meillo@marmaro.de>
parents:
393
diff
changeset
|
338 while ((c = fgetc(in)) != EOF) { |
c8e3d1a79313
Refactoring in conf.c: read_rval().
markus schnalke <meillo@marmaro.de>
parents:
393
diff
changeset
|
339 if (ptr >= buf+size-1) { |
c8e3d1a79313
Refactoring in conf.c: read_rval().
markus schnalke <meillo@marmaro.de>
parents:
393
diff
changeset
|
340 /* rval too long */ |
c8e3d1a79313
Refactoring in conf.c: read_rval().
markus schnalke <meillo@marmaro.de>
parents:
393
diff
changeset
|
341 break; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
342 } |
394
c8e3d1a79313
Refactoring in conf.c: read_rval().
markus schnalke <meillo@marmaro.de>
parents:
393
diff
changeset
|
343 if (!escape && c == '"') { |
c8e3d1a79313
Refactoring in conf.c: read_rval().
markus schnalke <meillo@marmaro.de>
parents:
393
diff
changeset
|
344 break; |
c8e3d1a79313
Refactoring in conf.c: read_rval().
markus schnalke <meillo@marmaro.de>
parents:
393
diff
changeset
|
345 } |
c8e3d1a79313
Refactoring in conf.c: read_rval().
markus schnalke <meillo@marmaro.de>
parents:
393
diff
changeset
|
346 if (!escape && c == '\\') { |
c8e3d1a79313
Refactoring in conf.c: read_rval().
markus schnalke <meillo@marmaro.de>
parents:
393
diff
changeset
|
347 escape = TRUE; |
c8e3d1a79313
Refactoring in conf.c: read_rval().
markus schnalke <meillo@marmaro.de>
parents:
393
diff
changeset
|
348 continue; |
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 *ptr++ = c; |
c8e3d1a79313
Refactoring in conf.c: read_rval().
markus schnalke <meillo@marmaro.de>
parents:
393
diff
changeset
|
351 escape = FALSE; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
352 } |
14
a8f3424347dc
replaced number 0 with character \0 where appropriate
meillo@marmaro.de
parents:
13
diff
changeset
|
353 *ptr = '\0'; |
0 | 354 } |
333
0bd27f603910
Added debug level 9 for msgs to stderr during reading config
markus schnalke <meillo@marmaro.de>
parents:
330
diff
changeset
|
355 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
|
356 /* eat trailing of line */ |
c8e3d1a79313
Refactoring in conf.c: read_rval().
markus schnalke <meillo@marmaro.de>
parents:
393
diff
changeset
|
357 while ((c = fgetc(in)) != EOF && c != '\n') { |
c8e3d1a79313
Refactoring in conf.c: read_rval().
markus schnalke <meillo@marmaro.de>
parents:
393
diff
changeset
|
358 continue; |
c8e3d1a79313
Refactoring in conf.c: read_rval().
markus schnalke <meillo@marmaro.de>
parents:
393
diff
changeset
|
359 } |
0 | 360 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
361 return TRUE; |
0 | 362 } |
363 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
364 static gboolean |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
359
diff
changeset
|
365 read_statement(FILE *in, gchar *lval, gint lsize, gchar *rval, gint rsize) |
0 | 366 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
367 gint c; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
368 |
333
0bd27f603910
Added debug level 9 for msgs to stderr during reading config
markus schnalke <meillo@marmaro.de>
parents:
330
diff
changeset
|
369 DEBUG(9) fprintf(stderr, "read_statement()\n"); |
0 | 370 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
371 /* 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
|
372 if (!eat_comments(in)) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
373 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
|
374 } |
28 | 375 if (!read_lval(in, lval, lsize)) { |
376 return FALSE; | |
377 } | |
378 | |
333
0bd27f603910
Added debug level 9 for msgs to stderr during reading config
markus schnalke <meillo@marmaro.de>
parents:
330
diff
changeset
|
379 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
|
380 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
|
381 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
|
382 lval, c); |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
383 } |
393
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
384 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
|
385 return FALSE; |
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
386 } |
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
387 DEBUG(9) fprintf(stderr, " rval = %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
|
388 return TRUE; |
0 | 389 } |
390 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
391 gboolean |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
359
diff
changeset
|
392 read_conf(gchar *filename) |
0 | 393 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
394 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
|
395 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
|
396 GList *listen_addrs_tmp = NULL; |
0 | 397 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
398 conf.do_relay = TRUE; |
244
7082044c05c6
renamed `alias_local_cmp' to `localpartcmp'
markus schnalke <meillo@marmaro.de>
parents:
243
diff
changeset
|
399 conf.localpartcmp = strcmp; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
400 conf.max_defer_time = 86400 * 4; /* 4 days */ |
120
cd59a5b4d3dd
added support for SMTP SIZE 0 (unlimited)
meillo@marmaro.de
parents:
117
diff
changeset
|
401 conf.max_msg_size = 0; /* no limit on msg size */ |
151 | 402 conf.spool_dir = SPOOL_DIR; |
152 | 403 conf.mail_dir = "/var/mail"; |
0 | 404 |
393
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
405 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
|
406 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
|
407 filename, strerror(errno)); |
28 | 408 return FALSE; |
409 } | |
0 | 410 |
392
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
411 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
|
412 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
|
413 if (strcmp(lval, "debug_level")==0) { |
28 | 414 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
|
415 } 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
|
416 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
|
417 /* you should not be able to reset that flag */ |
28 | 418 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
|
419 } |
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
420 } else if (strcmp(lval, "use_syslog")==0) { |
28 | 421 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
|
422 } else if (strcmp(lval, "mail_dir")==0) { |
28 | 423 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
|
424 } else if (strcmp(lval, "lock_dir")==0) { |
28 | 425 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
|
426 } else if (strcmp(lval, "spool_dir")==0) { |
28 | 427 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
|
428 } else if (strcmp(lval, "log_dir")==0) { |
28 | 429 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
|
430 } 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
|
431 if (rval[0] != '/') { |
28 | 432 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
|
433 } else { |
28 | 434 char buf[256]; |
435 FILE *fptr = fopen(rval, "rt"); | |
307 | 436 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
|
437 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
|
438 "%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
|
439 strerror(errno)); |
28 | 440 return FALSE; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
441 } |
393
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
442 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
|
443 g_strstrip(buf); |
28 | 444 conf.host_name = g_strdup(buf); |
445 fclose(fptr); | |
446 } | |
393
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
447 } 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
|
448 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
|
449 } else if (strcmp(lval, "local_addresses")==0) { |
28 | 450 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
|
451 } else if (strcmp(lval, "not_local_addresses")==0) { |
28 | 452 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
|
453 } else if (strcmp(lval, "do_save_envelope_to")==0) { |
28 | 454 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
|
455 } else if (strcmp(lval, "defer_all")==0) { |
28 | 456 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
|
457 } else if (strcmp(lval, "do_relay")==0) { |
28 | 458 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
|
459 } else if (strcmp(lval, "alias_file")==0) { |
28 | 460 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
|
461 } else if (strcmp(lval, "globalias_file")==0) { |
387
a408411ff8df
Added a glob-pattern aliasing facility.
markus schnalke <meillo@marmaro.de>
parents:
378
diff
changeset
|
462 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
|
463 } 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
|
464 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
|
465 strcasecmp : strcmp; |
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, "mbox_default")==0) { |
28 | 467 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
|
468 } else if (strcmp(lval, "mbox_users")==0) { |
28 | 469 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
|
470 } else if (strcmp(lval, "mda_users")==0) { |
28 | 471 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
|
472 } else if (strcmp(lval, "mda")==0) { |
28 | 473 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
|
474 } else if (strcmp(lval, "mda_fromline")==0) { |
28 | 475 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
|
476 } else if (strcmp(lval, "mda_fromhack")==0) { |
28 | 477 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
|
478 } else if (strcmp(lval, "pipe_fromline")==0) { |
28 | 479 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
|
480 } else if (strcmp(lval, "pipe_fromhack")==0) { |
28 | 481 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
|
482 } 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
|
483 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
|
484 } else if (strncmp(lval, "query_routes.", 13)==0) { |
28 | 485 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
|
486 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
|
487 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
|
488 pair); |
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, "permanent_routes")==0) { |
354
08932c629849
reworked the route concept; removed the idea of the localnet
markus schnalke <meillo@marmaro.de>
parents:
333
diff
changeset
|
490 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
|
491 } else if (strcmp(lval, "online_query")==0) { |
310
f10a56dc7481
reworked online_detect to the simpler online_query
meillo@marmaro.de
parents:
307
diff
changeset
|
492 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
|
493 } else if (strcmp(lval, "do_queue")==0) { |
28 | 494 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
|
495 } else if (strcmp(lval, "errmsg_file")==0) { |
28 | 496 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
|
497 } else if (strcmp(lval, "warnmsg_file")==0) { |
28 | 498 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
|
499 } 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
|
500 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
|
501 } 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
|
502 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
|
503 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
|
504 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
|
505 "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
|
506 rval); |
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
507 } else { |
28 | 508 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
|
509 } |
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
510 } else if (strcmp(lval, "log_user")==0) { |
28 | 511 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
|
512 } 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
|
513 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
|
514 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
|
515 "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
|
516 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
|
517 } else { |
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
518 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
|
519 lval); |
117
5ec5e6637049
added server-side SMTP SIZE support (patch by Paolo)
meillo@marmaro.de
parents:
115
diff
changeset
|
520 } |
28 | 521 } |
522 fclose(in); | |
0 | 523 |
156
ee2afbf92428
require host_name to be set in config file
meillo@marmaro.de
parents:
155
diff
changeset
|
524 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
|
525 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
|
526 "masqmail.conf. See man page\n"); |
156
ee2afbf92428
require host_name to be set in config file
meillo@marmaro.de
parents:
155
diff
changeset
|
527 return FALSE; |
ee2afbf92428
require host_name to be set in config file
meillo@marmaro.de
parents:
155
diff
changeset
|
528 } |
393
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
529 if (!conf.errmsg_file) { |
28 | 530 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
|
531 } |
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
532 if (!conf.warnmsg_file) { |
28 | 533 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
|
534 } |
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
535 if (!conf.lock_dir) { |
28 | 536 conf.lock_dir = g_strdup_printf("%s/lock/", conf.spool_dir); |
393
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
537 } |
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
538 if (!conf.mbox_default) { |
28 | 539 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
|
540 } |
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
541 if (!conf.warn_intervals) { |
392
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
542 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
|
543 } |
157
586f001f5bbd
local_hosts defaults to localhost;foo;foo.example.org now
meillo@marmaro.de
parents:
156
diff
changeset
|
544 if (!conf.local_hosts) { |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
359
diff
changeset
|
545 char *shortname = strdup(conf.host_name); |
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
359
diff
changeset
|
546 char *p = strchr(shortname, '.'); |
157
586f001f5bbd
local_hosts defaults to localhost;foo;foo.example.org now
meillo@marmaro.de
parents:
156
diff
changeset
|
547 if (p) { |
586f001f5bbd
local_hosts defaults to localhost;foo;foo.example.org now
meillo@marmaro.de
parents:
156
diff
changeset
|
548 *p = '\0'; |
586f001f5bbd
local_hosts defaults to localhost;foo;foo.example.org now
meillo@marmaro.de
parents:
156
diff
changeset
|
549 } |
392
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
550 /* 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
|
551 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
|
552 shortname, conf.host_name); |
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
553 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
|
554 free(shortname); |
586f001f5bbd
local_hosts defaults to localhost;foo;foo.example.org now
meillo@marmaro.de
parents:
156
diff
changeset
|
555 free(local_hosts_str); |
586f001f5bbd
local_hosts defaults to localhost;foo;foo.example.org now
meillo@marmaro.de
parents:
156
diff
changeset
|
556 } |
393
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
557 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
|
558 conf.listen_addresses = g_list_append(NULL, |
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
559 parse_interface("localhost", 25)); |
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
560 } else { |
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
561 GList *node; |
157
586f001f5bbd
local_hosts defaults to localhost;foo;foo.example.org now
meillo@marmaro.de
parents:
156
diff
changeset
|
562 |
393
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
563 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
|
564 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
|
565 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
|
566 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
|
567 25)); |
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
568 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
|
569 } |
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
570 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
|
571 } |
157
586f001f5bbd
local_hosts defaults to localhost;foo;foo.example.org now
meillo@marmaro.de
parents:
156
diff
changeset
|
572 |
28 | 573 return TRUE; |
0 | 574 } |
575 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
576 connect_route* |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
359
diff
changeset
|
577 read_route(gchar *filename, gboolean is_perma) |
0 | 578 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
579 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
|
580 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
|
581 gchar lval[256], rval[2048]; |
0 | 582 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
583 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
|
584 |
393
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
585 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
|
586 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
|
587 filename, strerror(errno)); |
28 | 588 return NULL; |
589 } | |
0 | 590 |
393
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
591 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
|
592 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
|
593 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
|
594 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
|
595 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
|
596 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
|
597 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
|
598 |
392
c5fd796ea06e
Heavy refactoring in parts of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
387
diff
changeset
|
599 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
|
600 if (strcmp(lval, "mail_host")==0) { |
178 | 601 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
|
602 } else if (strcmp(lval, "helo_name")==0) { |
28 | 603 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
|
604 } else if (strcmp(lval, "wrapper")==0) { |
28 | 605 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
|
606 } else if (strcmp(lval, "connect_error_fail")==0) { |
28 | 607 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
|
608 } else if (strcmp(lval, "do_correct_helo")==0) { |
28 | 609 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
|
610 } else if (strcmp(lval, "instant_helo")==0) { |
222 | 611 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
|
612 } else if (strcmp(lval, "do_pipelining")==0) { |
28 | 613 route->do_pipelining = parse_boolean(rval); |
317
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
311
diff
changeset
|
614 |
393
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
615 } 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
|
616 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
|
617 } 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
|
618 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
|
619 } 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
|
620 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
|
621 } 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
|
622 route->denied_recipients = parse_address_glob_list(rval); |
317
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
311
diff
changeset
|
623 |
393
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
624 } else if (strcmp(lval, "set_h_from_domain")==0) { |
28 | 625 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
|
626 } else if (strcmp(lval, "set_h_reply_to_domain")==0) { |
28 | 627 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
|
628 } else if (strcmp(lval, "set_return_path_domain")==0) { |
28 | 629 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
|
630 } else if (strcmp(lval, "map_return_path_addresses")==0) { |
28 | 631 GList *node, *list; |
0 | 632 |
28 | 633 list = parse_list(rval, TRUE); |
634 foreach(list, node) { | |
635 gchar *item = (gchar *) (node->data); | |
636 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
|
637 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
|
638 (gchar *) (pair->value), TRUE); |
28 | 639 g_free(pair->value); |
640 pair->value = (gpointer *) addr; | |
393
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
641 route->map_return_path_addresses = g_list_append( route->map_return_path_addresses, pair); |
28 | 642 g_free(item); |
643 } | |
644 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
|
645 } else if (strcmp(lval, "map_h_from_addresses")==0) { |
28 | 646 GList *list, *node; |
0 | 647 |
28 | 648 list = parse_list(rval, TRUE); |
649 foreach(list, node) { | |
650 gchar *item = (gchar *) (node->data); | |
651 table_pair *pair = parse_table_pair(item, ':'); | |
652 route->map_h_from_addresses = g_list_append(route->map_h_from_addresses, pair); | |
653 g_free(item); | |
654 } | |
655 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
|
656 } else if (strcmp(lval, "map_h_reply_to_addresses")==0) { |
28 | 657 GList *list, *node; |
0 | 658 |
28 | 659 list = parse_list(rval, TRUE); |
660 foreach(list, node) { | |
661 gchar *item = (gchar *) (node->data); | |
662 table_pair *pair = parse_table_pair(item, ':'); | |
663 route->map_h_reply_to_addresses = g_list_append(route->map_h_reply_to_addresses, pair); | |
664 g_free(item); | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
665 } |
28 | 666 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
|
667 } else if (strcmp(lval, "map_h_mail_followup_to_addresses")==0) { |
28 | 668 GList *list, *node; |
669 | |
670 list = parse_list(rval, TRUE); | |
671 foreach(list, node) { | |
672 gchar *item = (gchar *) (node->data); | |
673 table_pair *pair = parse_table_pair(item, ':'); | |
674 route->map_h_mail_followup_to_addresses = g_list_append(route->map_h_mail_followup_to_addresses, pair); | |
675 g_free(item); | |
676 } | |
677 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
|
678 } else if (strcmp(lval, "expand_h_sender_domain")==0) { |
28 | 679 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
|
680 } else if (strcmp(lval, "expand_h_sender_address")==0) { |
28 | 681 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
|
682 } else if (strcmp(lval, "resolve_list")==0) { |
28 | 683 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
|
684 } else if (strcmp(lval, "do_ssl")==0) { |
28 | 685 /* we ignore this. This option is used by sqilconf */ |
686 ; | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
687 #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
|
688 } else if (strcmp(lval, "auth_name")==0) { |
28 | 689 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
|
690 } else if (strcmp(lval, "auth_login")==0) { |
28 | 691 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
|
692 } else if (strcmp(lval, "auth_secret")==0) { |
28 | 693 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
|
694 #else |
393
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
695 } 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
|
696 (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
|
697 (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
|
698 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
|
699 "auth support.\n", lval); |
28 | 700 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
701 #endif |
393
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
702 } else if (strcmp(lval, "pipe")==0) { |
28 | 703 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
|
704 } else if (strcmp(lval, "pipe_fromline")==0) { |
28 | 705 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
|
706 } else if (strcmp(lval, "pipe_fromhack")==0) { |
28 | 707 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
|
708 } else if (strcmp(lval, "last_route")==0) { |
28 | 709 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
|
710 } else { |
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
711 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
|
712 lval); |
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
713 } |
28 | 714 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
715 |
319 | 716 if (!route->resolve_list) { |
28 | 717 #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
|
718 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
|
719 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
|
720 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
|
721 resolve_dns_a); |
28 | 722 #endif |
393
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
723 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
|
724 resolve_byname); |
28 | 725 } |
726 fclose(in); | |
727 | |
393
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
728 /* 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
|
729 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
|
730 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
|
731 "'set_h_from_domain'\n"); |
28 | 732 g_free(route->set_h_from_domain); |
733 route->set_h_from_domain = NULL; | |
734 } | |
393
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
735 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
|
736 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
|
737 "'set_h_reply_to_domain'\n"); |
28 | 738 g_free(route->set_h_reply_to_domain); |
739 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
|
740 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
741 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
742 return route; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
743 } |
0 | 744 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
745 static void |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
359
diff
changeset
|
746 _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
|
747 { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
748 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
|
749 if (!list) { |
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
750 return; |
0 | 751 } |
393
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
752 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
|
753 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
|
754 } |
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
755 g_list_free(list); |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
756 } |
0 | 757 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
758 void |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
359
diff
changeset
|
759 destroy_route(connect_route *r) |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
760 { |
393
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
761 if (r->filename) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
762 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
|
763 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
764 if (r->mail_host) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
765 g_free(r->mail_host->address); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
766 g_free(r->mail_host); |
0 | 767 } |
393
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
768 if (r->wrapper) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
769 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
|
770 } |
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
771 if (r->helo_name) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
772 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
|
773 } |
317
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
311
diff
changeset
|
774 _g_list_free_all(r->allowed_senders); |
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
311
diff
changeset
|
775 _g_list_free_all(r->denied_senders); |
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
311
diff
changeset
|
776 _g_list_free_all(r->allowed_recipients); |
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
311
diff
changeset
|
777 _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
|
778 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
|
779 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
|
780 } |
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
781 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
|
782 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
|
783 } |
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
784 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
|
785 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
|
786 } |
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
787 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
|
788 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
|
789 } |
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
790 if (r->resolve_list) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
791 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
|
792 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
793 #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
|
794 if (r->auth_name) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
795 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
|
796 } |
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
797 if (r->auth_login) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
798 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
|
799 } |
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
800 if (r->auth_secret) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
801 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
|
802 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
803 #endif |
393
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
804 if (r->pipe) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
805 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
|
806 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
807 g_free(r); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
808 } |
0 | 809 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
810 GList* |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
359
diff
changeset
|
811 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
|
812 { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
813 GList *list = NULL; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
814 GList *node; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
815 uid_t saved_uid, saved_gid; |
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 if (!conf.run_as_user) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
818 set_euidgid(0, 0, &saved_uid, &saved_gid); |
0 | 819 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
820 foreach(rf_list, node) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
821 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
|
822 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
|
823 if (route) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
824 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
|
825 } else { |
5e728dd64c1b
Various refactoring and code layouting in the second half of conf.c.
markus schnalke <meillo@marmaro.de>
parents:
392
diff
changeset
|
826 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
|
827 "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
|
828 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
829 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
830 /* set uid and gid back */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
831 if (!conf.run_as_user) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
832 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
|
833 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
834 return list; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
835 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
836 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
837 void |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
359
diff
changeset
|
838 destroy_route_list(GList *list) |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
839 { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
840 GList *node; |
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 foreach(list, node) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
843 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
|
844 destroy_route(route); |
0 | 845 } |
846 g_list_free(list); | |
847 } |