masqmail-0.2

annotate src/conf.c @ 10:26e34ae9a3e3

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