masqmail-0.2

annotate src/conf.c @ 48:f3bdb5b382ec

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