masqmail

diff 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
line diff
     1.1 --- a/src/conf.c	Thu Jul 08 09:20:34 2010 +0200
     1.2 +++ b/src/conf.c	Thu Jul 08 09:43:27 2010 +0200
     1.3 @@ -433,12 +433,11 @@
     1.4  	conf.max_defer_time = 86400 * 4;  /* 4 days */
     1.5  	conf.max_msg_size = 0; /* no limit on msg size */
     1.6  	conf.spool_dir = SPOOL_DIR;
     1.7 -	conf.log_dir = LOG_DIR;
     1.8  	conf.local_hosts = parse_list("localhost", FALSE);
     1.9  	conf.mail_dir = "/var/mail";
    1.10  
    1.11  	if ((in = fopen(filename, "r")) == NULL) {
    1.12 -		fprintf(stderr, "could not open config file %s: %s\n", filename, strerror(errno));
    1.13 +		logwrite(LOG_ALERT, "could not open config file %s: %s\n", filename, strerror(errno));
    1.14  		return FALSE;
    1.15  	}
    1.16  
    1.17 @@ -467,7 +466,7 @@
    1.18  				char buf[256];
    1.19  				FILE *fptr = fopen(rval, "rt");
    1.20  				if (fptr) {
    1.21 -					fprintf(stderr, "could not open %s: %s\n", rval, strerror(errno));
    1.22 +					logwrite(LOG_ALERT, "could not open %s: %s\n", rval, strerror(errno));
    1.23  					return FALSE;
    1.24  				}
    1.25  				fgets(buf, 255, fptr);
    1.26 @@ -476,7 +475,7 @@
    1.27  				fclose(fptr);
    1.28  			}
    1.29  		} else if (strcmp(lval, "remote_port") == 0) {
    1.30 -			fprintf(stderr, "the remote_port option is now deprecated. Use 'mail_host' in the\n"
    1.31 +			logwrite(LOG_WARNING, "the remote_port option is now deprecated. Use 'mail_host' in the\n"
    1.32  							"route configuration instead. See man masqmail.route\n");
    1.33  			conf.remote_port = atoi(rval);
    1.34  		} else if (strcmp(lval, "local_hosts") == 0)
    1.35 @@ -537,7 +536,7 @@
    1.36  			}
    1.37  			g_list_free(tmp_list);
    1.38  #else
    1.39 -			fprintf(stderr, "%s ignored: not compiled with ident support\n", lval);
    1.40 +			logwrite(LOG_WARNING, "%s ignored: not compiled with ident support\n", lval);
    1.41  #endif
    1.42  		} else if ((strncmp(lval, "connect_route.", 14) == 0)
    1.43  		           || (strncmp(lval, "online_routes.", 14) == 0)) {
    1.44 @@ -561,7 +560,7 @@
    1.45  			table_pair *pair = create_pair_string(&(lval[4]), rval);
    1.46  			conf.get_names = g_list_append(conf.get_names, pair);
    1.47  #else
    1.48 -			fprintf(stderr, "get.<name> ignored: not compiled with pop support\n");
    1.49 +			logwrite(LOG_WARNING, "get.<name> ignored: not compiled with pop support\n");
    1.50  #endif
    1.51  		} else if (strncmp(lval, "online_gets.", 12) == 0) {
    1.52  #ifdef ENABLE_POP3
    1.53 @@ -569,7 +568,7 @@
    1.54  			table_pair *pair = create_pair(&(lval[12]), file_list);
    1.55  			conf.online_gets = g_list_append(conf.online_gets, pair);
    1.56  #else
    1.57 -			fprintf(stderr, "online_gets.<name> ignored: not compiled with pop support\n");
    1.58 +			logwrite(LOG_WARNING, "online_gets.<name> ignored: not compiled with pop support\n");
    1.59  #endif
    1.60  		} else if (strcmp(lval, "errmsg_file") == 0)
    1.61  			conf.errmsg_file = g_strdup(rval);
    1.62 @@ -581,7 +580,7 @@
    1.63  			gint dummy;
    1.64  			gint ival = time_interval(rval, &dummy);
    1.65  			if (ival < 0)
    1.66 -				fprintf(stderr, "invalid time interval for 'max_defer_time': %s\n", rval);
    1.67 +				logwrite(LOG_WARNING, "invalid time interval for 'max_defer_time': %s\n", rval);
    1.68  			else
    1.69  				conf.max_defer_time = ival;
    1.70  		} else if (strcmp(lval, "log_user") == 0)
    1.71 @@ -592,7 +591,7 @@
    1.72  			                 rval, conf.max_msg_size);
    1.73  		}
    1.74  		else
    1.75 -			fprintf(stderr, "var '%s' not (yet) known, ignored\n", lval);
    1.76 +			logwrite(LOG_WARNING, "var '%s' not (yet) known, ignored\n", lval);
    1.77  	}
    1.78  	fclose(in);
    1.79