masqmail-0.2

annotate src/conf.c @ 13:49dab67fe461

code beautifying
author meillo@marmaro.de
date Wed, 29 Oct 2008 21:10:18 +0100
parents 26e34ae9a3e3
children a8f3424347dc
rev   line source
meillo@0 1 /* MasqMail
meillo@0 2 Copyright (C) 1999-2001 Oliver Kurth
meillo@0 3
meillo@0 4 This program is free software; you can redistribute it and/or modify
meillo@0 5 it under the terms of the GNU General Public License as published by
meillo@0 6 the Free Software Foundation; either version 2 of the License, or
meillo@0 7 (at your option) any later version.
meillo@0 8
meillo@0 9 This program is distributed in the hope that it will be useful,
meillo@0 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
meillo@0 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
meillo@0 12 GNU General Public License for more details.
meillo@0 13
meillo@0 14 You should have received a copy of the GNU General Public License
meillo@0 15 along with this program; if not, write to the Free Software
meillo@0 16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
meillo@0 17 */
meillo@0 18
meillo@13 19 #include <pwd.h>
meillo@13 20 #include <grp.h>
meillo@13 21
meillo@0 22 #include "masqmail.h"
meillo@0 23
meillo@0 24 masqmail_conf conf;
meillo@0 25
meillo@10 26 void
meillo@10 27 init_conf()
meillo@0 28 {
meillo@10 29 struct passwd *passwd;
meillo@10 30 struct group *group;
meillo@0 31
meillo@10 32 memset(&conf, 0, sizeof(masqmail_conf));
meillo@0 33
meillo@10 34 conf.orig_uid = getuid();
meillo@10 35 conf.orig_gid = getgid();
meillo@0 36
meillo@10 37 if ((passwd = getpwnam(DEF_MAIL_USER)))
meillo@10 38 conf.mail_uid = passwd->pw_uid;
meillo@10 39 else {
meillo@10 40 fprintf(stderr, "user %s not found! (terminating)\n", DEF_MAIL_USER);
meillo@10 41 exit(EXIT_FAILURE);
meillo@10 42 }
meillo@10 43 if ((group = getgrnam(DEF_MAIL_GROUP)))
meillo@10 44 conf.mail_gid = group->gr_gid;
meillo@10 45 else {
meillo@10 46 fprintf(stderr, "group %s not found! (terminating)\n", DEF_MAIL_GROUP);
meillo@10 47 exit(EXIT_FAILURE);
meillo@10 48 }
meillo@0 49 }
meillo@0 50
meillo@10 51 static gchar* true_strings[] = {
meillo@10 52 "yes", "on", "true", NULL
meillo@0 53 };
meillo@0 54
meillo@10 55 static gchar *false_strings[] = {
meillo@10 56 "no", "off", "false", NULL
meillo@0 57 };
meillo@0 58
meillo@10 59 static gboolean
meillo@10 60 parse_boolean(gchar * rval)
meillo@0 61 {
meillo@10 62 gchar **str;
meillo@0 63
meillo@10 64 DEBUG(6) fprintf(stderr, "parse_boolean: %s\n", rval);
meillo@0 65
meillo@10 66 str = true_strings;
meillo@10 67 while (*str) {
meillo@10 68 if (strncasecmp(*str, rval, strlen(*str)) == 0)
meillo@10 69 return TRUE;
meillo@10 70 str++;
meillo@10 71 }
meillo@0 72
meillo@10 73 str = false_strings;
meillo@10 74 while (*str) {
meillo@10 75 if (strncasecmp(*str, rval, strlen(*str)) == 0)
meillo@10 76 return FALSE;
meillo@10 77 str++;
meillo@10 78 }
meillo@0 79
meillo@10 80 fprintf(stderr, "cannot parse value '%s'\n", rval);
meillo@10 81 exit(EXIT_FAILURE);
meillo@0 82 }
meillo@0 83
meillo@0 84 /* make a list from each line in a file */
meillo@10 85 static GList*
meillo@10 86 parse_list_file(gchar * fname)
meillo@0 87 {
meillo@10 88 GList *list = NULL;
meillo@10 89 FILE *fptr;
meillo@0 90
meillo@10 91 if ((fptr = fopen(fname, "rt"))) {
meillo@10 92 gchar buf[256];
meillo@0 93
meillo@10 94 while (!feof(fptr)) {
meillo@10 95 fgets(buf, 255, fptr);
meillo@10 96 if (buf[0] && (buf[0] != '#') && (buf[0] != '\n')) {
meillo@10 97 g_strchomp(buf);
meillo@10 98 list = g_list_append(list, g_strdup(buf));
meillo@10 99 }
meillo@10 100 }
meillo@10 101 fclose(fptr);
meillo@10 102 } else {
meillo@10 103 logwrite(LOG_ALERT, "could not open %s for reading: %s\n", fname, strerror(errno));
meillo@10 104 exit(EXIT_FAILURE);
meillo@10 105 }
meillo@0 106
meillo@10 107 return list;
meillo@0 108 }
meillo@0 109
meillo@13 110 /* given a semicolon separated string, this function makes a GList out of it. */
meillo@10 111 GList*
meillo@10 112 parse_list(gchar * line, gboolean read_file)
meillo@0 113 {
meillo@10 114 GList *list = NULL;
meillo@10 115 gchar buf[256];
meillo@10 116 gchar *p, *q;
meillo@0 117
meillo@10 118 DEBUG(6) fprintf(stderr, "parsing list %s\n", line);
meillo@0 119
meillo@10 120 p = line;
meillo@10 121 while (*p != 0) {
meillo@10 122 q = buf;
meillo@0 123
meillo@10 124 while (*p && (*p != ';') && (q < buf + 255))
meillo@10 125 *(q++) = *(p++);
meillo@10 126 *q = 0;
meillo@0 127
meillo@10 128 if ((buf[0] == '/') && (read_file))
meillo@10 129 /* item is a filename, include its contents */
meillo@10 130 list = g_list_concat(list, parse_list_file(buf));
meillo@10 131 else
meillo@10 132 /* just a normal item */
meillo@10 133 list = g_list_append(list, g_strdup(buf));
meillo@0 134
meillo@10 135 DEBUG(6) printf("item = %s\n", buf);
meillo@0 136
meillo@10 137 if (*p)
meillo@10 138 p++;
meillo@10 139 }
meillo@10 140 return list;
meillo@0 141 }
meillo@0 142
meillo@10 143 static GList*
meillo@10 144 parse_address_list(gchar * line, gboolean read_file)
meillo@0 145 {
meillo@10 146 GList *plain_list = parse_list(line, read_file);
meillo@10 147 GList *node;
meillo@10 148 GList *list = NULL;
meillo@0 149
meillo@10 150 foreach(plain_list, node) {
meillo@10 151 gchar *item = (gchar *) (node->data);
meillo@10 152 address *addr = create_address(item, TRUE);
meillo@10 153 if (addr)
meillo@10 154 list = g_list_append(list, addr);
meillo@10 155 g_free(item);
meillo@10 156 }
meillo@10 157 g_list_free(plain_list);
meillo@0 158
meillo@10 159 return list;
meillo@0 160 }
meillo@0 161
meillo@10 162 static GList*
meillo@10 163 parse_resolve_list(gchar * line)
meillo@0 164 {
meillo@10 165 GList *list;
meillo@10 166 GList *list_node;
meillo@10 167 GList *res_list = NULL;
meillo@0 168
meillo@10 169 list = parse_list(line, FALSE);
meillo@10 170 if (list) {
meillo@10 171 foreach(list, list_node) {
meillo@10 172 gchar *item = (gchar *) (list_node->data);
meillo@10 173 if (strcmp(item, "byname") == 0) {
meillo@10 174 res_list = g_list_append(res_list, resolve_byname);
meillo@0 175 #ifdef ENABLE_RESOLVER
meillo@10 176 } else if (strcmp(item, "dns_a") == 0) {
meillo@10 177 res_list = g_list_append(res_list, resolve_dns_a);
meillo@10 178 } else if (strcmp(item, "dns_mx") == 0) {
meillo@10 179 res_list = g_list_append(res_list, resolve_dns_mx);
meillo@0 180 #endif
meillo@10 181 } else {
meillo@10 182 logwrite(LOG_ALERT, "unknown resolver %s\n", item);
meillo@10 183 exit(EXIT_FAILURE);
meillo@10 184 }
meillo@10 185 g_free(item);
meillo@10 186 }
meillo@10 187 g_list_free(list);
meillo@10 188 }
meillo@10 189 return res_list;
meillo@0 190 }
meillo@0 191
meillo@10 192 static interface*
meillo@10 193 parse_interface(gchar * line, gint def_port)
meillo@0 194 {
meillo@10 195 gchar buf[256];
meillo@10 196 gchar *p, *q;
meillo@10 197 interface *iface;
meillo@0 198
meillo@10 199 DEBUG(6) fprintf(stderr, "parse_interface: %s\n", line);
meillo@0 200
meillo@10 201 p = line;
meillo@10 202 q = buf;
meillo@10 203 while ((*p != 0) && (*p != ':') && (q < buf + 255))
meillo@10 204 *(q++) = *(p++);
meillo@10 205 *q = 0;
meillo@0 206
meillo@10 207 iface = g_malloc(sizeof(interface));
meillo@10 208 iface->address = g_strdup(buf);
meillo@0 209
meillo@10 210 if (*p) {
meillo@10 211 p++;
meillo@10 212 iface->port = atoi(p);
meillo@10 213 } else
meillo@10 214 iface->port = def_port;
meillo@0 215
meillo@10 216 return iface;
meillo@0 217 }
meillo@0 218
meillo@10 219 #ifdef ENABLE_IDENT /* so far used for that only */
meillo@10 220 static struct in_addr*
meillo@10 221 parse_network(gchar * line, gint def_port)
meillo@0 222 {
meillo@10 223 gchar buf[256];
meillo@10 224 gchar *p, *q;
meillo@10 225 struct in_addr addr, mask_addr, net_addr, *p_net_addr;
meillo@10 226 guint n;
meillo@0 227
meillo@10 228 DEBUG(6) fprintf(stderr, "parse_network: %s\n", line);
meillo@0 229
meillo@10 230 p = line;
meillo@10 231 q = buf;
meillo@10 232 while ((*p != 0) && (*p != '/') && (q < buf + 255))
meillo@10 233 *(q++) = *(p++);
meillo@10 234 *q = 0;
meillo@0 235
meillo@10 236 if ((addr.s_addr = inet_addr(buf)) != INADDR_NONE) {
meillo@10 237 if (*p) {
meillo@10 238 guint i;
meillo@10 239 p++;
meillo@10 240 i = atoi(p);
meillo@10 241 if ((i >= 0) && (i <= 32))
meillo@10 242 n = i ? ~((1 << (32 - i)) - 1) : 0;
meillo@10 243 else {
meillo@10 244 fprintf(stderr, "'%d' is not a valid net mask (must be >= 0 and <= 32)\n", i);
meillo@10 245 exit(EXIT_FAILURE);
meillo@10 246 }
meillo@10 247 } else
meillo@10 248 n = 0;
meillo@0 249
meillo@10 250 mask_addr.s_addr = htonl(n);
meillo@10 251 net_addr.s_addr = mask_addr.s_addr & addr.s_addr;
meillo@10 252 } else {
meillo@10 253 fprintf(stderr, "'%s' is not a valid address (must be ip)\n", buf);
meillo@10 254 exit(EXIT_FAILURE);
meillo@10 255 }
meillo@10 256
meillo@10 257 p_net_addr = g_malloc(sizeof(struct in_addr));
meillo@10 258 p_net_addr->s_addr = net_addr.s_addr;
meillo@10 259 return p_net_addr;
meillo@0 260 }
meillo@0 261 #endif
meillo@0 262
meillo@10 263 static gboolean
meillo@10 264 eat_comments(FILE * in)
meillo@0 265 {
meillo@10 266 gint c;
meillo@0 267
meillo@10 268 for (c = fgetc(in); (c == '#' || isspace(c)) && c != EOF;
meillo@10 269 c = fgetc(in)) {
meillo@10 270 if (c == '#') {
meillo@10 271 gint c;
meillo@10 272 for (c = fgetc(in); (c != '\n') && (c != EOF); c = fgetc(in));
meillo@10 273 }
meillo@10 274 }
meillo@10 275 if (c == EOF)
meillo@10 276 return FALSE;
meillo@10 277 ungetc(c, in);
meillo@10 278 return TRUE;
meillo@0 279 }
meillo@0 280
meillo@0 281 /* after parsing, eat trailing character until LF */
meillo@10 282 static gboolean
meillo@10 283 eat_line_trailing(FILE * in)
meillo@0 284 {
meillo@10 285 gint c;
meillo@0 286
meillo@10 287 for (c = fgetc(in); c != EOF && c != '\n'; c = fgetc(in));
meillo@10 288 if (c == EOF)
meillo@10 289 return FALSE;
meillo@10 290 return TRUE;
meillo@0 291 }
meillo@0 292
meillo@10 293 static gboolean
meillo@10 294 eat_spaces(FILE * in)
meillo@0 295 {
meillo@10 296 gint c;
meillo@10 297
meillo@10 298 for (c = fgetc(in); c != EOF && isspace(c); c = fgetc(in));
meillo@10 299 if (c == EOF)
meillo@10 300 return FALSE;
meillo@10 301 ungetc(c, in);
meillo@10 302 return TRUE;
meillo@0 303 }
meillo@0 304
meillo@10 305 static gboolean
meillo@10 306 read_lval(FILE * in, gchar * buf, gint size)
meillo@0 307 {
meillo@10 308 gint c;
meillo@10 309 gchar *ptr = buf;
meillo@0 310
meillo@10 311 DEBUG(6) fprintf(stderr, "read_lval()\n");
meillo@0 312
meillo@10 313 if (!eat_spaces(in))
meillo@10 314 return FALSE;
meillo@0 315
meillo@10 316 c = fgetc(in);
meillo@10 317 DEBUG(6) fprintf(stderr, "read_lval() 2\n");
meillo@10 318 while ((isalnum(c) || c == '_' || c == '-' || c == '.')
meillo@10 319 && (ptr < buf + size - 1)
meillo@10 320 && (c != EOF)) {
meillo@10 321 *ptr = c;
meillo@10 322 ptr++;
meillo@10 323 c = fgetc(in);
meillo@10 324 }
meillo@10 325 *ptr = 0;
meillo@10 326 ungetc(c, in);
meillo@0 327
meillo@10 328 if (c == EOF) {
meillo@10 329 fprintf(stderr, "unexpected EOF after %s\n", buf);
meillo@10 330 return FALSE;
meillo@10 331 } else if (ptr >= buf + size - 1) {
meillo@10 332 fprintf(stderr, "lval too long\n");
meillo@10 333 }
meillo@0 334
meillo@10 335 eat_spaces(in);
meillo@0 336
meillo@10 337 DEBUG(6) fprintf(stderr, "lval = %s\n", buf);
meillo@10 338
meillo@10 339 return buf[0] != 0;
meillo@0 340 }
meillo@0 341
meillo@10 342 static gboolean
meillo@10 343 read_rval(FILE * in, gchar * buf, gint size)
meillo@0 344 {
meillo@10 345 gint c;
meillo@10 346 gchar *ptr = buf;
meillo@0 347
meillo@10 348 DEBUG(6) fprintf(stderr, "read_rval()\n");
meillo@0 349
meillo@10 350 if (!eat_spaces(in))
meillo@10 351 return FALSE;
meillo@10 352
meillo@10 353 c = fgetc(in);
meillo@10 354 if (c != '\"') {
meillo@13 355 while ((isalnum(c) || c == '_' || c == '-' || c == '.' || c == '/' || c == '@' || c == ';')
meillo@10 356 && (ptr < buf + size - 1)
meillo@10 357 && (c != EOF)) {
meillo@10 358 *ptr = c;
meillo@10 359 ptr++;
meillo@10 360 c = fgetc(in);
meillo@10 361 }
meillo@10 362 *ptr = 0;
meillo@10 363 ungetc(c, in);
meillo@10 364 } else {
meillo@10 365 gboolean escape = FALSE;
meillo@10 366 c = fgetc(in);
meillo@10 367 while (((c != '\"') || escape) && (ptr < buf + size - 1)) {
meillo@13 368 if (c != '\n') { /* ignore line breaks */
meillo@10 369 if ((c == '\\') && (!escape)) {
meillo@10 370 escape = TRUE;
meillo@10 371 } else {
meillo@10 372 *ptr = c;
meillo@10 373 ptr++;
meillo@10 374 escape = FALSE;
meillo@10 375 }
meillo@10 376 }
meillo@10 377 c = fgetc(in);
meillo@10 378 }
meillo@10 379 *ptr = 0;
meillo@0 380 }
meillo@0 381
meillo@10 382 eat_line_trailing(in);
meillo@0 383
meillo@10 384 DEBUG(6) fprintf(stderr, "rval = %s\n", buf);
meillo@10 385
meillo@10 386 return TRUE;
meillo@0 387 }
meillo@0 388
meillo@10 389 static gboolean
meillo@10 390 read_statement(FILE * in, gchar * lval, gint lsize, gchar * rval, gint rsize)
meillo@0 391 {
meillo@10 392 gint c;
meillo@0 393
meillo@10 394 DEBUG(6) fprintf(stderr, "read_statement()\n");
meillo@0 395
meillo@10 396 /* eat comments and empty lines: */
meillo@10 397 if (!eat_comments(in))
meillo@10 398 return FALSE;
meillo@0 399
meillo@10 400 DEBUG(6) fprintf(stderr, "read_statement() 1\n");
meillo@0 401
meillo@10 402 if (read_lval(in, lval, lsize)) {
meillo@10 403 DEBUG(6) fprintf(stderr, "lval = %s\n", lval);
meillo@10 404 if ((c = fgetc(in) == '=')) {
meillo@10 405 if (read_rval(in, rval, rsize)) {
meillo@10 406 DEBUG(6) fprintf(stderr, "rval = %s\n", rval);
meillo@10 407 return TRUE;
meillo@10 408 }
meillo@10 409 } else {
meillo@13 410 fprintf(stderr, "'=' expected after %s, char was '%c'\n", lval, c);
meillo@10 411 }
meillo@10 412 }
meillo@10 413 return FALSE;
meillo@0 414 }
meillo@0 415
meillo@10 416 gboolean
meillo@10 417 read_conf(gchar * filename)
meillo@0 418 {
meillo@10 419 FILE *in;
meillo@0 420
meillo@10 421 conf.log_max_pri = 7;
meillo@10 422 conf.remote_port = 25;
meillo@10 423 conf.do_relay = TRUE;
meillo@10 424 conf.alias_local_cmp = strcmp;
meillo@10 425 conf.max_defer_time = 86400 * 4; /* 4 days */
meillo@0 426
meillo@10 427 if ((in = fopen(filename, "r"))) {
meillo@10 428 gchar lval[256], rval[2048];
meillo@10 429 while (read_statement(in, lval, 256, rval, 2048)) {
meillo@10 430 if (strcmp(lval, "debug_level") == 0)
meillo@10 431 conf.debug_level = atoi(rval);
meillo@10 432 else if (strcmp(lval, "run_as_user") == 0) {
meillo@10 433 if (!conf.run_as_user) /* you should not be able to reset that flag */
meillo@10 434 conf.run_as_user = parse_boolean(rval);
meillo@10 435 } else if (strcmp(lval, "use_syslog") == 0)
meillo@10 436 conf.use_syslog = parse_boolean(rval);
meillo@10 437 else if (strcmp(lval, "mail_dir") == 0)
meillo@10 438 conf.mail_dir = g_strdup(rval);
meillo@10 439 else if (strcmp(lval, "lock_dir") == 0)
meillo@10 440 conf.lock_dir = g_strdup(rval);
meillo@10 441 else if (strcmp(lval, "spool_dir") == 0)
meillo@10 442 conf.spool_dir = g_strdup(rval);
meillo@10 443 else if (strcmp(lval, "log_dir") == 0)
meillo@10 444 conf.log_dir = g_strdup(rval);
meillo@10 445 else if (strcmp(lval, "host_name") == 0) {
meillo@10 446 if (rval[0] != '/')
meillo@10 447 conf.host_name = g_strdup(rval);
meillo@10 448 else {
meillo@10 449 char buf[256];
meillo@10 450 FILE *fptr = fopen(rval, "rt");
meillo@10 451 if (fptr) {
meillo@10 452 fgets(buf, 255, fptr);
meillo@10 453 g_strchomp(buf);
meillo@10 454 conf.host_name = g_strdup(buf);
meillo@10 455 fclose(fptr);
meillo@10 456 } else {
meillo@10 457 fprintf(stderr, "could not open %s: %s\n", rval,
meillo@10 458 strerror(errno));
meillo@10 459 return FALSE;
meillo@10 460 }
meillo@10 461 }
meillo@10 462 } else if (strcmp(lval, "remote_port") == 0) {
meillo@10 463 fprintf(stderr, "the remote_port option is now deprecated. Use 'mail_host' in the\n"
meillo@10 464 "route configuration instead. See man masqmail.route\n");
meillo@10 465 conf.remote_port = atoi(rval);
meillo@10 466 } else if (strcmp(lval, "local_hosts") == 0)
meillo@10 467 conf.local_hosts = parse_list(rval, FALSE);
meillo@10 468 else if (strcmp(lval, "local_addresses") == 0)
meillo@10 469 conf.local_addresses = parse_list(rval, TRUE);
meillo@10 470 else if (strcmp(lval, "not_local_addresses") == 0)
meillo@10 471 conf.not_local_addresses = parse_list(rval, TRUE);
meillo@10 472 else if (strcmp(lval, "local_nets") == 0)
meillo@10 473 conf.local_nets = parse_list(rval, FALSE);
meillo@10 474 else if (strcmp(lval, "do_save_envelope_to") == 0)
meillo@10 475 conf.do_save_envelope_to = parse_boolean(rval);
meillo@10 476 else if (strcmp(lval, "defer_all") == 0)
meillo@10 477 conf.defer_all = parse_boolean(rval);
meillo@10 478 else if (strcmp(lval, "do_relay") == 0)
meillo@10 479 conf.do_relay = parse_boolean(rval);
meillo@10 480 else if (strcmp(lval, "alias_file") == 0) {
meillo@10 481 conf.alias_file = g_strdup(rval);
meillo@10 482 } else if (strcmp(lval, "alias_local_caseless") == 0) {
meillo@10 483 conf.alias_local_cmp = parse_boolean(rval) ? strcasecmp : strcmp;
meillo@10 484 } else if (strcmp(lval, "mbox_default") == 0) {
meillo@10 485 conf.mbox_default = g_strdup(rval);
meillo@10 486 } else if (strcmp(lval, "mbox_users") == 0) {
meillo@10 487 conf.mbox_users = parse_list(rval, TRUE);
meillo@10 488 } else if (strcmp(lval, "mda_users") == 0) {
meillo@10 489 conf.mda_users = parse_list(rval, TRUE);
meillo@10 490 } else if (strcmp(lval, "maildir_users") == 0) {
meillo@10 491 conf.maildir_users = parse_list(rval, TRUE);
meillo@10 492 } else if (strcmp(lval, "mda") == 0) {
meillo@10 493 conf.mda = g_strdup(rval);
meillo@10 494 } else if (strcmp(lval, "mda_fromline") == 0) {
meillo@10 495 conf.mda_fromline = parse_boolean(rval);
meillo@10 496 } else if (strcmp(lval, "mda_fromhack") == 0) {
meillo@10 497 conf.mda_fromhack = parse_boolean(rval);
meillo@10 498 } else if (strcmp(lval, "pipe_fromline") == 0) {
meillo@10 499 conf.pipe_fromline = parse_boolean(rval);
meillo@10 500 } else if (strcmp(lval, "pipe_fromhack") == 0) {
meillo@10 501 conf.pipe_fromhack = parse_boolean(rval);
meillo@10 502 } else if (strcmp(lval, "listen_addresses") == 0) {
meillo@10 503 GList *node;
meillo@10 504 GList *tmp_list = parse_list(rval, FALSE);
meillo@0 505
meillo@10 506 conf.listen_addresses = NULL;
meillo@10 507 foreach(tmp_list, node) {
meillo@10 508 conf.listen_addresses = g_list_append(conf.listen_addresses, parse_interface((gchar *) (node-> data), 25));
meillo@10 509 g_free(node->data);
meillo@10 510 }
meillo@10 511 g_list_free(tmp_list);
meillo@10 512 } else if (strcmp(lval, "ident_trusted_nets") == 0) {
meillo@10 513 #ifdef ENABLE_IDENT
meillo@10 514 GList *node;
meillo@10 515 GList *tmp_list = parse_list(rval, FALSE);
meillo@0 516
meillo@10 517 conf.ident_trusted_nets = NULL;
meillo@10 518 foreach(tmp_list, node) {
meillo@10 519 conf.ident_trusted_nets = g_list_append(conf.ident_trusted_nets, parse_network((gchar *) (node->data), 25));
meillo@10 520 g_free(node->data);
meillo@10 521 }
meillo@10 522 g_list_free(tmp_list);
meillo@10 523 #else
meillo@10 524 fprintf(stderr, "%s ignored: not compiled with ident support\n", lval);
meillo@10 525 #endif
meillo@10 526 } else if ((strncmp(lval, "connect_route.", 14) == 0)
meillo@10 527 || (strncmp(lval, "online_routes.", 14) == 0)) {
meillo@10 528 GList *file_list = parse_list(rval, FALSE);
meillo@10 529 table_pair *pair = create_pair(&(lval[14]), file_list);
meillo@10 530 conf.connect_routes = g_list_append(conf.connect_routes, pair);
meillo@10 531 } else if (strcmp(lval, "local_net_route") == 0) {
meillo@10 532 conf.local_net_routes = parse_list(rval, FALSE);
meillo@10 533 } else if (strcmp(lval, "online_detect") == 0)
meillo@10 534 conf.online_detect = g_strdup(rval);
meillo@10 535 else if (strcmp(lval, "online_file") == 0)
meillo@10 536 conf.online_file = g_strdup(rval);
meillo@10 537 else if (strcmp(lval, "online_pipe") == 0)
meillo@10 538 conf.online_pipe = g_strdup(rval);
meillo@10 539 else if (strcmp(lval, "mserver_iface") == 0)
meillo@10 540 conf.mserver_iface = parse_interface(rval, 224);
meillo@10 541 else if (strcmp(lval, "do_queue") == 0)
meillo@10 542 conf.do_queue = parse_boolean(rval);
meillo@10 543 else if (strncmp(lval, "get.", 4) == 0) {
meillo@10 544 #ifdef ENABLE_POP3
meillo@10 545 table_pair *pair = create_pair_string(&(lval[4]), rval);
meillo@10 546 conf.get_names = g_list_append(conf.get_names, pair);
meillo@10 547 #else
meillo@10 548 fprintf(stderr, "get.<name> ignored: not compiled with pop support\n");
meillo@10 549 #endif
meillo@10 550 } else if (strncmp(lval, "online_gets.", 12) == 0) {
meillo@10 551 #ifdef ENABLE_POP3
meillo@10 552 GList *file_list = parse_list(rval, FALSE);
meillo@10 553 table_pair *pair = create_pair(&(lval[12]), file_list);
meillo@10 554 conf.online_gets = g_list_append(conf.online_gets, pair);
meillo@10 555 #else
meillo@10 556 fprintf(stderr, "online_gets.<name> ignored: not compiled with pop support\n");
meillo@10 557 #endif
meillo@10 558 } else if (strcmp(lval, "errmsg_file") == 0)
meillo@10 559 conf.errmsg_file = g_strdup(rval);
meillo@10 560 else if (strcmp(lval, "warnmsg_file") == 0)
meillo@10 561 conf.warnmsg_file = g_strdup(rval);
meillo@10 562 else if (strcmp(lval, "warn_intervals") == 0)
meillo@10 563 conf.warn_intervals = parse_list(rval, FALSE);
meillo@10 564 else if (strcmp(lval, "max_defer_time") == 0) {
meillo@10 565 gint dummy;
meillo@10 566 gint ival = time_interval(rval, &dummy);
meillo@10 567 if (ival < 0)
meillo@10 568 fprintf(stderr, "invalid time interval for 'max_defer_time': %s\n", rval);
meillo@10 569 else
meillo@10 570 conf.max_defer_time = ival;
meillo@10 571 } else if (strcmp(lval, "log_user") == 0)
meillo@10 572 conf.log_user = g_strdup(rval);
meillo@0 573
meillo@10 574 else
meillo@10 575 fprintf(stderr, "var '%s' not (yet) known, ignored\n", lval);
meillo@10 576 }
meillo@10 577 fclose(in);
meillo@0 578
meillo@10 579 if (conf.errmsg_file == NULL)
meillo@10 580 conf.errmsg_file = g_strdup(DATA_DIR "/tpl/failmsg.tpl");
meillo@10 581 if (conf.warnmsg_file == NULL)
meillo@10 582 conf.warnmsg_file = g_strdup(DATA_DIR "/tpl/warnmsg.tpl");
meillo@0 583
meillo@10 584 if (conf.lock_dir == NULL)
meillo@10 585 conf.lock_dir = g_strdup_printf("%s/lock/", conf.spool_dir);
meillo@0 586
meillo@10 587 if (conf.mbox_default == NULL)
meillo@10 588 conf.mbox_default = g_strdup("mbox");
meillo@0 589
meillo@10 590 if (conf.warn_intervals == NULL)
meillo@10 591 conf.warn_intervals = parse_list("1h;4h;8h;1d;2d;3d", FALSE);
meillo@0 592
meillo@10 593 return TRUE;
meillo@10 594 } else
meillo@10 595 fprintf(stderr, "could not open config file %s: %s\n", filename, strerror(errno));
meillo@10 596 return FALSE;
meillo@0 597 }
meillo@0 598
meillo@10 599 connect_route*
meillo@10 600 read_route(gchar * filename, gboolean is_local_net)
meillo@0 601 {
meillo@10 602 gboolean ok = FALSE;
meillo@10 603 FILE *in;
meillo@0 604
meillo@10 605 connect_route *route = g_malloc(sizeof(connect_route));
meillo@10 606 memset(route, 0, sizeof(connect_route));
meillo@0 607
meillo@10 608 DEBUG(5) debugf("read_route, filename = %s\n", filename);
meillo@0 609
meillo@10 610 route->filename = g_strdup(filename);
meillo@10 611 route->name = g_strdup(filename); /* quick hack */
meillo@0 612
meillo@10 613 route->protocol = g_strdup("smtp");
meillo@10 614 route->expand_h_sender_address = TRUE;
meillo@0 615
meillo@10 616 route->is_local_net = is_local_net;
meillo@0 617
meillo@10 618 route->do_pipelining = TRUE;
meillo@0 619
meillo@10 620 if ((in = fopen(route->filename, "r"))) {
meillo@10 621 gchar lval[256], rval[2048];
meillo@10 622 while (read_statement(in, lval, 256, rval, 2048)) {
meillo@10 623 if (strcmp(lval, "protocol") == 0)
meillo@10 624 route->protocol = g_strdup(rval);
meillo@10 625 else if (strcmp(lval, "mail_host") == 0)
meillo@10 626 route->mail_host = parse_interface(rval, conf.remote_port);
meillo@10 627 else if (strcmp(lval, "helo_name") == 0)
meillo@10 628 route->helo_name = g_strdup(rval);
meillo@10 629 else if (strcmp(lval, "wrapper") == 0)
meillo@10 630 route->wrapper = g_strdup(rval);
meillo@10 631 else if (strcmp(lval, "connect_error_fail") == 0)
meillo@10 632 route->connect_error_fail = parse_boolean(rval);
meillo@10 633 else if (strcmp(lval, "do_correct_helo") == 0)
meillo@10 634 route->do_correct_helo = parse_boolean(rval);
meillo@10 635 else if (strcmp(lval, "do_pipelining") == 0)
meillo@10 636 route->do_pipelining = parse_boolean(rval);
meillo@10 637 else if (strcmp(lval, "allowed_return_paths") == 0)
meillo@10 638 route->allowed_return_paths = parse_address_list(rval, TRUE);
meillo@10 639 else if (strcmp(lval, "allowed_mail_locals") == 0)
meillo@10 640 route->allowed_mail_locals = parse_list(rval, TRUE);
meillo@10 641 else if (strcmp(lval, "not_allowed_return_paths") == 0)
meillo@10 642 route->not_allowed_return_paths = parse_address_list(rval, TRUE);
meillo@10 643 else if (strcmp(lval, "not_allowed_mail_locals") == 0)
meillo@10 644 route->not_allowed_mail_locals = parse_list(rval, TRUE);
meillo@10 645 else if (strcmp(lval, "allowed_rcpt_domains") == 0)
meillo@10 646 route->allowed_rcpt_domains = parse_list(rval, TRUE);
meillo@10 647 else if (strcmp(lval, "not_allowed_rcpt_domains") == 0)
meillo@10 648 route->not_allowed_rcpt_domains = parse_list(rval, TRUE);
meillo@10 649 else if (strcmp(lval, "set_h_from_domain") == 0)
meillo@10 650 route->set_h_from_domain = g_strdup(rval);
meillo@10 651 else if (strcmp(lval, "set_h_reply_to_domain") == 0)
meillo@10 652 route->set_h_reply_to_domain = g_strdup(rval);
meillo@10 653 else if (strcmp(lval, "set_return_path_domain") == 0)
meillo@10 654 route->set_return_path_domain = g_strdup(rval);
meillo@10 655 else if (strcmp(lval, "map_return_path_addresses") == 0) {
meillo@10 656 GList *node, *list;
meillo@0 657
meillo@10 658 list = parse_list(rval, TRUE);
meillo@10 659 foreach(list, node) {
meillo@10 660 gchar *item = (gchar *) (node->data);
meillo@10 661 table_pair *pair = parse_table_pair(item, ':');
meillo@10 662 address *addr = create_address((gchar *) (pair->value), TRUE);
meillo@10 663 g_free(pair->value);
meillo@10 664 pair->value = (gpointer *) addr;
meillo@10 665 route->map_return_path_addresses = g_list_append(route->map_return_path_addresses, pair);
meillo@10 666 g_free(item);
meillo@10 667 }
meillo@10 668 g_list_free(list);
meillo@10 669 } else if (strcmp(lval, "map_h_from_addresses") == 0) {
meillo@10 670 GList *list, *node;
meillo@10 671
meillo@10 672 list = parse_list(rval, TRUE);
meillo@10 673 foreach(list, node) {
meillo@10 674 gchar *item = (gchar *) (node->data);
meillo@10 675 table_pair *pair = parse_table_pair(item, ':');
meillo@10 676 route->map_h_from_addresses = g_list_append(route->map_h_from_addresses, pair);
meillo@10 677 g_free(item);
meillo@10 678 }
meillo@10 679 g_list_free(list);
meillo@10 680 } else if (strcmp(lval, "map_h_reply_to_addresses") == 0) {
meillo@10 681 GList *list, *node;
meillo@10 682
meillo@10 683 list = parse_list(rval, TRUE);
meillo@10 684 foreach(list, node) {
meillo@10 685 gchar *item = (gchar *) (node->data);
meillo@10 686 table_pair *pair = parse_table_pair(item, ':');
meillo@10 687 route->map_h_reply_to_addresses = g_list_append(route->map_h_reply_to_addresses, pair);
meillo@10 688 g_free(item);
meillo@10 689 }
meillo@10 690 g_list_free(list);
meillo@10 691 } else if (strcmp(lval, "map_h_mail_followup_to_addresses") == 0) {
meillo@10 692 GList *list, *node;
meillo@10 693
meillo@10 694 list = parse_list(rval, TRUE);
meillo@10 695 foreach(list, node) {
meillo@10 696 gchar *item = (gchar *) (node->data);
meillo@10 697 table_pair *pair = parse_table_pair(item, ':');
meillo@10 698 route->map_h_mail_followup_to_addresses = g_list_append(route->map_h_mail_followup_to_addresses, pair);
meillo@10 699 g_free(item);
meillo@10 700 }
meillo@10 701 g_list_free(list);
meillo@10 702 } else if (strcmp(lval, "expand_h_sender_domain") == 0) {
meillo@10 703 route->expand_h_sender_domain = parse_boolean(rval);
meillo@10 704 } else if (strcmp(lval, "expand_h_sender_address") == 0) {
meillo@10 705 route->expand_h_sender_address = parse_boolean(rval);
meillo@10 706 } else if (strcmp(lval, "resolve_list") == 0)
meillo@10 707 route->resolve_list = parse_resolve_list(rval);
meillo@10 708 else if (strcmp(lval, "do_ssl") == 0) {
meillo@10 709 /* we ignore this. This option is used by sqilconf */
meillo@10 710 ;
meillo@10 711 }
meillo@10 712 #ifdef ENABLE_AUTH
meillo@10 713 else if (strcmp(lval, "auth_name") == 0) {
meillo@10 714 route->auth_name = g_strdup(rval);
meillo@10 715 } else if (strcmp(lval, "auth_login") == 0) {
meillo@10 716 route->auth_login = g_strdup(rval);
meillo@10 717 } else if (strcmp(lval, "auth_secret") == 0) {
meillo@10 718 route->auth_secret = g_strdup(rval);
meillo@10 719 }
meillo@10 720 #else
meillo@10 721 else if ((strcmp(lval, "auth_name") == 0)
meillo@10 722 || (strcmp(lval, "auth_login") == 0)
meillo@10 723 || (strcmp(lval, "auth_secret") == 0)) {
meillo@10 724 logwrite(LOG_WARNING, "%s ignored: not compiled with auth support.\n", lval);
meillo@10 725 }
meillo@10 726 #endif
meillo@10 727 else if (strcmp(lval, "pop3_login") == 0) {
meillo@10 728 #ifdef ENABLE_POP3
meillo@10 729 route->pop3_login = g_strdup(rval);
meillo@10 730 #else
meillo@10 731 logwrite(LOG_WARNING, "pop3_login ignored: not compiled with pop support.\n");
meillo@10 732 #endif
meillo@10 733 } else if (strcmp(lval, "pipe") == 0) {
meillo@10 734 route->pipe = g_strdup(rval);
meillo@10 735 } else if (strcmp(lval, "pipe_fromline") == 0) {
meillo@10 736 route->pipe_fromline = parse_boolean(rval);
meillo@10 737 } else if (strcmp(lval, "pipe_fromhack") == 0) {
meillo@10 738 route->pipe_fromhack = parse_boolean(rval);
meillo@10 739 } else if (strcmp(lval, "last_route") == 0) {
meillo@10 740 route->last_route = parse_boolean(rval);
meillo@10 741 } else
meillo@10 742 logwrite(LOG_WARNING, "var '%s' not (yet) known, ignored\n", lval);
meillo@10 743 }
meillo@10 744
meillo@10 745 if (route->resolve_list == NULL) {
meillo@10 746 if (is_local_net) {
meillo@10 747 route->resolve_list = g_list_append(NULL, resolve_byname);
meillo@10 748 } else {
meillo@10 749 #ifdef ENABLE_RESOLVER
meillo@10 750 route->resolve_list = g_list_append(route->resolve_list, resolve_dns_mx);
meillo@10 751 route->resolve_list = g_list_append(route->resolve_list, resolve_dns_a);
meillo@10 752 #endif
meillo@10 753 route->resolve_list = g_list_append(route->resolve_list, resolve_byname);
meillo@10 754 }
meillo@10 755 }
meillo@10 756 fclose(in);
meillo@10 757 ok = TRUE;
meillo@10 758
meillo@10 759 /* warn user about misconfigurations: */
meillo@10 760 if ((route->map_h_from_addresses != NULL)
meillo@10 761 && (route->set_h_from_domain != NULL)) {
meillo@10 762 logwrite(LOG_WARNING, "'map_h_from_addresses' overrides 'set_h_from_domain'\n");
meillo@10 763 g_free(route->set_h_from_domain);
meillo@10 764 route->set_h_from_domain = NULL;
meillo@10 765 }
meillo@10 766 if ((route->map_h_reply_to_addresses != NULL)
meillo@10 767 && (route->set_h_reply_to_domain != NULL)) {
meillo@10 768 logwrite(LOG_WARNING, "'map_h_reply_to_addresses' overrides 'set_h_reply_to_domain'\n");
meillo@10 769 g_free(route->set_h_reply_to_domain);
meillo@10 770 route->set_h_reply_to_domain = NULL;
meillo@10 771 }
meillo@10 772 } else {
meillo@10 773 logwrite(LOG_ALERT, "could not open route file %s: %s\n", route->filename, strerror(errno));
meillo@10 774 }
meillo@10 775
meillo@10 776 if (!ok) {
meillo@10 777 g_free(route);
meillo@10 778 route = NULL;
meillo@10 779 }
meillo@10 780
meillo@10 781 return route;
meillo@10 782 }
meillo@10 783
meillo@10 784 static void
meillo@10 785 _g_list_free_all(GList * list)
meillo@10 786 {
meillo@10 787 GList *node;
meillo@10 788 if (list) {
meillo@10 789 foreach(list, node)
meillo@10 790 g_free(node->data);
meillo@10 791 g_list_free(list);
meillo@10 792 }
meillo@10 793 }
meillo@10 794
meillo@10 795 void
meillo@10 796 destroy_route(connect_route * r)
meillo@10 797 {
meillo@10 798 if (r->filename)
meillo@10 799 g_free(r->filename);
meillo@10 800 if (r->protocol)
meillo@10 801 g_free(r->protocol);
meillo@10 802 if (r->mail_host) {
meillo@10 803 g_free(r->mail_host->address);
meillo@10 804 g_free(r->mail_host);
meillo@10 805 }
meillo@10 806 if (r->wrapper)
meillo@10 807 g_free(r->wrapper);
meillo@10 808 if (r->helo_name)
meillo@10 809 g_free(r->helo_name);
meillo@10 810 _g_list_free_all(r->allowed_mail_locals);
meillo@10 811 _g_list_free_all(r->not_allowed_mail_locals);
meillo@10 812 _g_list_free_all(r->allowed_rcpt_domains);
meillo@10 813 _g_list_free_all(r->not_allowed_rcpt_domains);
meillo@10 814 if (r->set_h_from_domain)
meillo@10 815 g_free(r->set_h_from_domain);
meillo@10 816 if (r->set_h_reply_to_domain)
meillo@10 817 g_free(r->set_h_reply_to_domain);
meillo@10 818 if (r->set_return_path_domain)
meillo@10 819 g_free(r->set_return_path_domain);
meillo@10 820 if (r->map_h_reply_to_addresses)
meillo@10 821 destroy_table(r->map_h_reply_to_addresses);
meillo@10 822 if (r->resolve_list)
meillo@10 823 g_list_free(r->resolve_list);
meillo@10 824 #ifdef ENABLE_AUTH
meillo@10 825 if (r->auth_name)
meillo@10 826 g_free(r->auth_name);
meillo@10 827 if (r->auth_login)
meillo@10 828 g_free(r->auth_login);
meillo@10 829 if (r->auth_secret)
meillo@10 830 g_free(r->auth_secret);
meillo@10 831 #endif
meillo@10 832 #ifdef ENABLE_POP3
meillo@10 833 if (r->pop3_login)
meillo@10 834 g_free(r->pop3_login);
meillo@10 835 #endif
meillo@10 836 if (r->pipe)
meillo@10 837 g_free(r->pipe);
meillo@10 838 g_free(r);
meillo@10 839 }
meillo@10 840
meillo@10 841 GList*
meillo@10 842 read_route_list(GList * rf_list, gboolean is_local_net)
meillo@10 843 {
meillo@10 844 GList *list = NULL;
meillo@10 845 GList *node;
meillo@10 846 uid_t saved_uid, saved_gid;
meillo@10 847
meillo@10 848 if (!conf.run_as_user) {
meillo@10 849 set_euidgid(0, 0, &saved_uid, &saved_gid);
meillo@10 850 }
meillo@10 851
meillo@10 852 foreach(rf_list, node) {
meillo@10 853 gchar *fname = (gchar *) (node->data);
meillo@10 854 connect_route *route = read_route(fname, is_local_net);
meillo@10 855 if (route)
meillo@10 856 list = g_list_append(list, route);
meillo@10 857 else
meillo@10 858 logwrite(LOG_ALERT, "could not read route configuration %s\n", fname);
meillo@10 859 }
meillo@10 860
meillo@10 861 /* set uid and gid back */
meillo@10 862 if (!conf.run_as_user) {
meillo@10 863 set_euidgid(saved_uid, saved_gid, NULL, NULL);
meillo@10 864 }
meillo@10 865
meillo@10 866 return list;
meillo@10 867 }
meillo@10 868
meillo@10 869 void
meillo@10 870 destroy_route_list(GList * list)
meillo@10 871 {
meillo@10 872 GList *node;
meillo@10 873
meillo@10 874 foreach(list, node) {
meillo@10 875 connect_route *route = (connect_route *) (node->data);
meillo@10 876 destroy_route(route);
meillo@0 877 }
meillo@0 878 g_list_free(list);
meillo@0 879 }
meillo@0 880
meillo@0 881 #ifdef ENABLE_POP3
meillo@0 882
meillo@10 883 get_conf*
meillo@10 884 read_get_conf(gchar * filename)
meillo@0 885 {
meillo@10 886 FILE *in;
meillo@0 887
meillo@10 888 get_conf *gc = g_malloc(sizeof(get_conf));
meillo@10 889 memset(gc, 0, sizeof(get_conf));
meillo@0 890
meillo@10 891 gc->server_port = 110;
meillo@0 892
meillo@10 893 if ((in = fopen(filename, "r"))) {
meillo@10 894 gchar lval[256], rval[2048];
meillo@10 895 while (read_statement(in, lval, 256, rval, 2048)) {
meillo@10 896 if (strcmp(lval, "protocol") == 0)
meillo@10 897 gc->protocol = g_strdup(rval);
meillo@10 898 else if (strcmp(lval, "server") == 0)
meillo@10 899 gc->server_name = g_strdup(rval);
meillo@10 900 else if (strcmp(lval, "port") == 0)
meillo@10 901 gc->server_port = atoi(rval);
meillo@10 902 else if (strcmp(lval, "wrapper") == 0)
meillo@10 903 gc->wrapper = g_strdup(rval);
meillo@10 904 else if (strcmp(lval, "user") == 0)
meillo@10 905 gc->login_user = g_strdup(rval);
meillo@10 906 else if (strcmp(lval, "pass") == 0)
meillo@10 907 gc->login_pass = g_strdup(rval);
meillo@10 908 else if (strcmp(lval, "address") == 0)
meillo@10 909 gc->address = create_address_qualified(rval, TRUE, conf.host_name);
meillo@10 910 else if (strcmp(lval, "return_path") == 0)
meillo@10 911 gc->return_path = create_address_qualified(rval, TRUE, conf.host_name);
meillo@10 912 else if (strcmp(lval, "do_ssl") == 0)
meillo@10 913 /* we ignore this. This option is used by sqilconf */
meillo@10 914 ;
meillo@10 915 else if (strcmp(lval, "do_keep") == 0)
meillo@10 916 gc->do_keep = parse_boolean(rval);
meillo@10 917 else if (strcmp(lval, "do_uidl") == 0)
meillo@10 918 gc->do_uidl = parse_boolean(rval);
meillo@10 919 else if (strcmp(lval, "do_uidl_dele") == 0)
meillo@10 920 gc->do_uidl_dele = parse_boolean(rval);
meillo@10 921 else if (strcmp(lval, "max_size") == 0)
meillo@10 922 gc->max_size = atoi(rval);
meillo@10 923 else if (strcmp(lval, "max_size_delete") == 0)
meillo@10 924 gc->max_size = parse_boolean(rval);
meillo@10 925 else if (strcmp(lval, "max_count") == 0)
meillo@10 926 gc->max_count = atoi(rval);
meillo@10 927 else if (strcmp(lval, "resolve_list") == 0)
meillo@10 928 gc->resolve_list = parse_resolve_list(rval);
meillo@10 929 else
meillo@10 930 logwrite(LOG_WARNING, "var '%s' not (yet) known, ignored\n", lval);
meillo@10 931 }
meillo@10 932 fclose(in);
meillo@0 933
meillo@10 934 if (gc->resolve_list == NULL) {
meillo@0 935 #ifdef ENABLE_RESOLVER
meillo@10 936 gc->resolve_list = g_list_append(NULL, resolve_dns_a);
meillo@0 937 #endif
meillo@10 938 gc->resolve_list = g_list_append(NULL, resolve_byname);
meillo@10 939 }
meillo@0 940
meillo@10 941 if (gc->protocol == NULL)
meillo@10 942 gc->protocol = g_strdup("pop3");
meillo@10 943 return gc;
meillo@10 944 }
meillo@10 945 logwrite(LOG_ALERT, "could not open get file %s: %s\n", filename, strerror(errno));
meillo@10 946
meillo@10 947 g_free(gc);
meillo@10 948 return NULL;
meillo@0 949 }
meillo@0 950
meillo@10 951 void
meillo@10 952 destroy_get_conf(get_conf * gc)
meillo@0 953 {
meillo@10 954 if (gc->protocol)
meillo@10 955 g_free(gc->protocol);
meillo@10 956 if (gc->server_name)
meillo@10 957 g_free(gc->server_name);
meillo@10 958 if (gc->login_user)
meillo@10 959 g_free(gc->login_user);
meillo@10 960 if (gc->login_pass)
meillo@10 961 g_free(gc->login_pass);
meillo@10 962 if (gc->wrapper)
meillo@10 963 g_free(gc->wrapper);
meillo@10 964 if (gc->address)
meillo@10 965 destroy_address(gc->address);
meillo@10 966 if (gc->return_path)
meillo@10 967 destroy_address(gc->return_path);
meillo@10 968 if (gc->resolve_list)
meillo@10 969 g_list_free(gc->resolve_list);
meillo@10 970 g_free(gc);
meillo@0 971 }
meillo@0 972
meillo@0 973 #endif
meillo@0 974
meillo@10 975 connect_route*
meillo@10 976 create_local_route()
meillo@0 977 {
meillo@10 978 connect_route *route;
meillo@0 979
meillo@10 980 route = g_malloc(sizeof(connect_route));
meillo@10 981 if (route) {
meillo@10 982 memset(route, 0, sizeof(connect_route));
meillo@10 983 route->protocol = g_strdup("smtp");
meillo@10 984 route->is_local_net = TRUE;
meillo@10 985 route->name = g_strdup("local_net (default)");
meillo@10 986 route->expand_h_sender_address = TRUE;
meillo@10 987 route->resolve_list = g_list_append(NULL, resolve_byname);
meillo@10 988 route->connect_error_fail = TRUE;
meillo@10 989 }
meillo@10 990 return route;
meillo@0 991 }