Mercurial > masqmail
comparison src/conf.c @ 155:b5ab9cb2f18a
shut down on errors reading config file
while reading config file, log to log file
note: this breaks after SIGHUP
author | meillo@marmaro.de |
---|---|
date | Thu, 08 Jul 2010 09:43:27 +0200 |
parents | 51d8eadf3c79 |
children | ee2afbf92428 |
comparison
equal
deleted
inserted
replaced
154:fc1e5aa286ed | 155:b5ab9cb2f18a |
---|---|
431 conf.do_relay = TRUE; | 431 conf.do_relay = TRUE; |
432 conf.alias_local_cmp = strcmp; | 432 conf.alias_local_cmp = strcmp; |
433 conf.max_defer_time = 86400 * 4; /* 4 days */ | 433 conf.max_defer_time = 86400 * 4; /* 4 days */ |
434 conf.max_msg_size = 0; /* no limit on msg size */ | 434 conf.max_msg_size = 0; /* no limit on msg size */ |
435 conf.spool_dir = SPOOL_DIR; | 435 conf.spool_dir = SPOOL_DIR; |
436 conf.log_dir = LOG_DIR; | |
437 conf.local_hosts = parse_list("localhost", FALSE); | 436 conf.local_hosts = parse_list("localhost", FALSE); |
438 conf.mail_dir = "/var/mail"; | 437 conf.mail_dir = "/var/mail"; |
439 | 438 |
440 if ((in = fopen(filename, "r")) == NULL) { | 439 if ((in = fopen(filename, "r")) == NULL) { |
441 fprintf(stderr, "could not open config file %s: %s\n", filename, strerror(errno)); | 440 logwrite(LOG_ALERT, "could not open config file %s: %s\n", filename, strerror(errno)); |
442 return FALSE; | 441 return FALSE; |
443 } | 442 } |
444 | 443 |
445 gchar lval[256], rval[2048]; | 444 gchar lval[256], rval[2048]; |
446 while (read_statement(in, lval, 256, rval, 2048)) { | 445 while (read_statement(in, lval, 256, rval, 2048)) { |
465 conf.host_name = g_strdup(rval); | 464 conf.host_name = g_strdup(rval); |
466 else { | 465 else { |
467 char buf[256]; | 466 char buf[256]; |
468 FILE *fptr = fopen(rval, "rt"); | 467 FILE *fptr = fopen(rval, "rt"); |
469 if (fptr) { | 468 if (fptr) { |
470 fprintf(stderr, "could not open %s: %s\n", rval, strerror(errno)); | 469 logwrite(LOG_ALERT, "could not open %s: %s\n", rval, strerror(errno)); |
471 return FALSE; | 470 return FALSE; |
472 } | 471 } |
473 fgets(buf, 255, fptr); | 472 fgets(buf, 255, fptr); |
474 g_strchomp(buf); | 473 g_strchomp(buf); |
475 conf.host_name = g_strdup(buf); | 474 conf.host_name = g_strdup(buf); |
476 fclose(fptr); | 475 fclose(fptr); |
477 } | 476 } |
478 } else if (strcmp(lval, "remote_port") == 0) { | 477 } else if (strcmp(lval, "remote_port") == 0) { |
479 fprintf(stderr, "the remote_port option is now deprecated. Use 'mail_host' in the\n" | 478 logwrite(LOG_WARNING, "the remote_port option is now deprecated. Use 'mail_host' in the\n" |
480 "route configuration instead. See man masqmail.route\n"); | 479 "route configuration instead. See man masqmail.route\n"); |
481 conf.remote_port = atoi(rval); | 480 conf.remote_port = atoi(rval); |
482 } else if (strcmp(lval, "local_hosts") == 0) | 481 } else if (strcmp(lval, "local_hosts") == 0) |
483 conf.local_hosts = parse_list(rval, FALSE); | 482 conf.local_hosts = parse_list(rval, FALSE); |
484 else if (strcmp(lval, "local_addresses") == 0) | 483 else if (strcmp(lval, "local_addresses") == 0) |
535 conf.ident_trusted_nets = g_list_append(conf.ident_trusted_nets, parse_network((gchar *) (node->data), 25)); | 534 conf.ident_trusted_nets = g_list_append(conf.ident_trusted_nets, parse_network((gchar *) (node->data), 25)); |
536 g_free(node->data); | 535 g_free(node->data); |
537 } | 536 } |
538 g_list_free(tmp_list); | 537 g_list_free(tmp_list); |
539 #else | 538 #else |
540 fprintf(stderr, "%s ignored: not compiled with ident support\n", lval); | 539 logwrite(LOG_WARNING, "%s ignored: not compiled with ident support\n", lval); |
541 #endif | 540 #endif |
542 } else if ((strncmp(lval, "connect_route.", 14) == 0) | 541 } else if ((strncmp(lval, "connect_route.", 14) == 0) |
543 || (strncmp(lval, "online_routes.", 14) == 0)) { | 542 || (strncmp(lval, "online_routes.", 14) == 0)) { |
544 GList *file_list = parse_list(rval, FALSE); | 543 GList *file_list = parse_list(rval, FALSE); |
545 table_pair *pair = create_pair(&(lval[14]), file_list); | 544 table_pair *pair = create_pair(&(lval[14]), file_list); |
559 else if (strncmp(lval, "get.", 4) == 0) { | 558 else if (strncmp(lval, "get.", 4) == 0) { |
560 #ifdef ENABLE_POP3 | 559 #ifdef ENABLE_POP3 |
561 table_pair *pair = create_pair_string(&(lval[4]), rval); | 560 table_pair *pair = create_pair_string(&(lval[4]), rval); |
562 conf.get_names = g_list_append(conf.get_names, pair); | 561 conf.get_names = g_list_append(conf.get_names, pair); |
563 #else | 562 #else |
564 fprintf(stderr, "get.<name> ignored: not compiled with pop support\n"); | 563 logwrite(LOG_WARNING, "get.<name> ignored: not compiled with pop support\n"); |
565 #endif | 564 #endif |
566 } else if (strncmp(lval, "online_gets.", 12) == 0) { | 565 } else if (strncmp(lval, "online_gets.", 12) == 0) { |
567 #ifdef ENABLE_POP3 | 566 #ifdef ENABLE_POP3 |
568 GList *file_list = parse_list(rval, FALSE); | 567 GList *file_list = parse_list(rval, FALSE); |
569 table_pair *pair = create_pair(&(lval[12]), file_list); | 568 table_pair *pair = create_pair(&(lval[12]), file_list); |
570 conf.online_gets = g_list_append(conf.online_gets, pair); | 569 conf.online_gets = g_list_append(conf.online_gets, pair); |
571 #else | 570 #else |
572 fprintf(stderr, "online_gets.<name> ignored: not compiled with pop support\n"); | 571 logwrite(LOG_WARNING, "online_gets.<name> ignored: not compiled with pop support\n"); |
573 #endif | 572 #endif |
574 } else if (strcmp(lval, "errmsg_file") == 0) | 573 } else if (strcmp(lval, "errmsg_file") == 0) |
575 conf.errmsg_file = g_strdup(rval); | 574 conf.errmsg_file = g_strdup(rval); |
576 else if (strcmp(lval, "warnmsg_file") == 0) | 575 else if (strcmp(lval, "warnmsg_file") == 0) |
577 conf.warnmsg_file = g_strdup(rval); | 576 conf.warnmsg_file = g_strdup(rval); |
579 conf.warn_intervals = parse_list(rval, FALSE); | 578 conf.warn_intervals = parse_list(rval, FALSE); |
580 else if (strcmp(lval, "max_defer_time") == 0) { | 579 else if (strcmp(lval, "max_defer_time") == 0) { |
581 gint dummy; | 580 gint dummy; |
582 gint ival = time_interval(rval, &dummy); | 581 gint ival = time_interval(rval, &dummy); |
583 if (ival < 0) | 582 if (ival < 0) |
584 fprintf(stderr, "invalid time interval for 'max_defer_time': %s\n", rval); | 583 logwrite(LOG_WARNING, "invalid time interval for 'max_defer_time': %s\n", rval); |
585 else | 584 else |
586 conf.max_defer_time = ival; | 585 conf.max_defer_time = ival; |
587 } else if (strcmp(lval, "log_user") == 0) | 586 } else if (strcmp(lval, "log_user") == 0) |
588 conf.log_user = g_strdup(rval); | 587 conf.log_user = g_strdup(rval); |
589 else if(strcmp(lval, "max_msg_size") == 0) { | 588 else if(strcmp(lval, "max_msg_size") == 0) { |
590 conf.max_msg_size = atol(rval); | 589 conf.max_msg_size = atol(rval); |
591 DEBUG(6) fprintf(stderr,"rval=%s, conf.max_msg_size=%ld\n", | 590 DEBUG(6) fprintf(stderr,"rval=%s, conf.max_msg_size=%ld\n", |
592 rval, conf.max_msg_size); | 591 rval, conf.max_msg_size); |
593 } | 592 } |
594 else | 593 else |
595 fprintf(stderr, "var '%s' not (yet) known, ignored\n", lval); | 594 logwrite(LOG_WARNING, "var '%s' not (yet) known, ignored\n", lval); |
596 } | 595 } |
597 fclose(in); | 596 fclose(in); |
598 | 597 |
599 if (conf.errmsg_file == NULL) | 598 if (conf.errmsg_file == NULL) |
600 conf.errmsg_file = g_strdup(DATA_DIR "/tpl/failmsg.tpl"); | 599 conf.errmsg_file = g_strdup(DATA_DIR "/tpl/failmsg.tpl"); |