head 1.74; access; symbols milter-greylist-4-5-13:1.74 milter-greylist-4-5-12:1.74 milter-greylist-4-5-11:1.74 milter-greylist-4-5-10:1.74 milter-greylist-4-9-10:1.74 milter-greylist-4-5-8:1.73 milter-greylist-4-5-9:1.74 milter-greylist-4-5-7:1.73 milter-greylist-4-5-6:1.73 milter-greylist-4-5:1.73 milter-greylist-4-5-5:1.73 milter-greylist-4-5-4:1.73 milter-greylist-4-5-3:1.73 milter-greylist-4-5-2:1.72 milter-greylist-4-5-1:1.71 milter-greylist-4-4-3:1.71 milter-greylist-4-4-2:1.70 milter-greylist-4-4-1:1.70 milter-greylist-4-4:1.70 milter-greylist-4-4-rc1:1.70 milter-greylist-4-4-alpha4:1.70 milter-greylist-4-4-alpha3:1.70 milter-greylist-4-4-alpha2:1.70 milter-greylist-4-4-alpha1:1.70 milter-greylist-4-2-7:1.61.2.2 milter-greylist-4-3-9:1.69 milter-greylist-4-2-6:1.61.2.2 milter-gresylit-4-2-6:1.61.2.2 milter-greylist-4-3-8:1.69 milter-greylist-4-3-7:1.68 milter-greylist-4-2-5:1.61.2.2 milter-greylist-4-3-6:1.66 milter-greylist-4-2-4:1.61.2.1 milter-greylist-4-3-5:1.65 milter-greylist-4-3-4:1.64 milter-greylist-4-2-3:1.61 milter-greylist-4-3-3:1.62 rmilter-greylist-4-2-3:1.61 milter-greylist-4-3-2:1.62 milter-greylist-4-3-1:1.61 milter-greylist-2-2-2:1.61 milter-greylist-4-2-2:1.61 milter-greylist-4-2-1:1.61 milter-greylist-4-2:1.61 milter-greylist-4-2-rc1:1.61 milter-greylist-4-2-beta1:1.61 milter-greylist-4-2-branch:1.61.0.2 milter-greylist-4-2-base:1.61 milter-greylist-4-2-0-base:1.61 milter-greylist-4-1-12:1.61 milter-greylist-4-1-11:1.61 milter-greylist-4-1-10:1.61 milter-greylist-4-1-9:1.61 milter-greylist-4-1-8:1.60 milter-greylist-4-1-7:1.60 milter-greylist-4-1-6:1.58 milter-greylist-4-0-1:1.50 milter-greylist-4-0-1-rc1:1.50 milter-greylist-4-1-5:1.53 milter-greylist-4-1-4:1.53 milter-greylist-4-1-3:1.52 milter-greylist-4-1-2:1.52 milter-greylist-4-1-1:1.52 milter-greylist-4-0-branch:1.50.0.2 milter-greylist-4-0-base:1.50 milter-greylist-4-0:1.50 milter-greylist-4-0-rc2:1.50 milter-greylist-4-0-rc1:1.50 milter-greylist-4-0-beta4:1.50 milter-greylist-4-0-beta3:1.49 milter-greylist-4-0-beta2:1.47 milter-greylist-4-0-beta1:1.47 milter-greylist-4-0-alpha6:1.46 milter-greylist-4-0-alpha5:1.46 milter-greylist-4-0-alpha4:1.46 milter-greylist-4-0-alpha3:1.46 milter-greylist-4-0-alpha2:1.46 milter-greylist-4-0-alpha1:1.46 milter-greylist-3-1-8:1.46 milter-greylist-3-1-7:1.46 milter-greylist-3-1-6:1.46 milter-greylist-3-1-5:1.46 milter-greylist-3-1-5-alpha1:1.45 milter-greylist-3-0-1-beta1:1.42.2.2 milter-greylist-3-1-4:1.45 milter-greylist-3-1-3:1.45 milter-greylist-3-1-2:1.45 milter-greylist-3-1-1:1.43 milter-greylist-3-0:1.42.2.2 milter-greylist-3-0-rc7:1.42.2.2 milter-greylist-3-0-rc6:1.42.2.2 milter-greylist-3-0-rc5:1.42.2.2 milter-greylist-3-0-rc4:1.42.2.2 milter-greylist-3-0-rc3:1.42.2.2 milter-greylist-3-0-rc2:1.42.2.2 milter-greylist-3-0-rc1:1.42.2.2 milter-greylist-3-0-alpha6:1.42.2.1 milter-greylist-3-0-branch:1.42.0.2 milter-greylist-3-0-base:1.42 milter-greylist-3-0-alpha5:1.42 milter-greylist-3-0-alpha4:1.40 milter-greylist-3-0-alpha3:1.40 milter-greylist-3-0-alpha2:1.38 milter-greylist-3-0-alpha1:1.38 milter-greylist-2-1-12:1.38 milter-greylist-2-1-11:1.38 milter-greylist-2-1-10:1.38 milter-greylist-2-1-9:1.38 milter-greylist-2-1-9a1:1.38 milter-greylist-2-1-8:1.38 milter-greylist-2-1-7:1.38 milter-greylist-2-1-6:1.35 milter-greylist-2-1-5:1.35 milter-greylist-2-1-4:1.35 milter-greylist-2-1-3:1.35 milter-greylist-2-1-2:1.34 milter-greylist-2-1-1:1.34 milter-greylist-2-0-2:1.33 milter-greylist-2-0-1:1.33 milter-greylist-2-0-1-b1:1.33 milter-greylist-2-0-release:1.33 milter-greylist-2-0-rc5:1.33 milter-greylist-2-0-rc4:1.33 milter-greylist-2-0-rc3:1.33 milter-grey-list-2-0-rc3:1.33 milter-grey-list-2-0-rc2:1.33 milter-grey-list-2-0-rc1:1.33 milter-greylist-2-0-beta7:1.33 milter-greylist-2-0-beta6:1.33 milter-gre-ylist-2-0-beta5:1.33 milter-greylist-2-0-beta5:1.33 milter-greylist-2-0-beta4:1.33 milter-greylist-2-0-beta3:1.33 milter-greylist-2-0-beta2:1.32 milter-greylist-2-0:1.32.0.2 milter-greylist-2-0-base:1.32 milter-greylist-2-0-beta1:1.32 milter-greylist-1-7-5:1.32 before_delayed_tempfail:1.31 milter-greylist-1-7-4:1.31 milter-greylist-1-7-3:1.31 milter-greylist-1-7-2:1.30 milter-greylist-1-6-0:1.29 milter-greylist-1-7-1:1.29 milter-greylist-1-6rc1:1.29 milter-greylist-1-6:1.29.0.2 milter-greylist-1-6-base:1.29 milter-greylist-1-5-12:1.29 milter-greylist-1-5-11:1.29 milter-greylist-1-5-10:1.28 milter-greylist-1-5-9:1.28 milter-greylist-1-5-8:1.27 milter-greylist-1-5-7:1.27 milter-greylist-1-5-6:1.27 milter-greylist-1-5-5:1.26 milter-greylist-1-5-4:1.26 milter-greylist-1-5-3:1.24 milter-greylist-1-5-2:1.24 milter-greylist-1-5-1:1.24 milter-greylist-1-4:1.23.0.2 milter-greylist-1-4-base:1.23 milter-greylist-1-3-9:1.23 milter-greylist-1-3-8:1.21 milter-greylist-1-3-7:1.21 milter-greylist-1-3-6:1.20 milter-greylist-1-3-5:1.20 milter-greylist-1-3-4:1.20 milter-greylist-1-3-3:1.19 BDB:1.17.0.2 BDB-base:1.17 before_BDB:1.15 milter-greylist-1-2-2:1.15 milter-greylist-1-3-2:1.15 milter-greylist-1-2-1:1.15 milter-greylist-1-2-0:1.15 milter-greylist-1-2:1.15.0.2 milter-greylist-1-2-base:1.15 milter-greylist-1-1-16:1.15 milter-greylist-1-1-15:1.15 milter-greylis-1-1-15:1.15 milter-greylis-1-1-16:1.15 milter-greylist-1-1-14:1.15 milter-greylist-1-1-13:1.15 milter-greylist-1-1-12:1.15 milter-greylist-1-1-11:1.15 milter-greylist-1-1-10:1.15 milter-greylist-1-10rc1:1.15 milter-greylist-1-1-9:1.14 milter-greylist-1-1-8:1.13 milter-greylist-1-1-7:1.13 milter-greylist-1-1-6:1.13 milter-greylist-1-1-5:1.12 milter-greylist-1-1-4:1.10 milter-greylist-1-1-3:1.7 milter-greylist-1-1-2:1.7 milter-greylist-1-0-2:1.7 rmilter-greylist-1-0-1:1.7 milter-greylist-1-0-1:1.7 milter-greylist-1-1-1:1.7 milter-greylist-1-0-base:1.7 milter-greylist-1-0:1.7.0.2 milter-greylist-1-0-0:1.7 milter-greylist-0-27:1.7 milter-greylist-0-26:1.7 milter-greylist-0-25:1.7 milter-greylist-0-24:1.6 milter-greylist-0-23:1.6 milter-greylist-0-22:1.5 milter-greylist-0-21:1.5 milter-greylist-0-20:1.5 milter-greylist-0-19:1.3 milter-greylist-0-18:1.2 milter-greylist-0-17:1.2 milter-greylist-0-16:1.2 milter-greylist-0-15:1.2 milter-greylist-0-14:1.2 milter-greylist-0-13:1.2; locks; strict; comment @ * @; 1.74 date 2014.02.04.15.19.25; author manu; state Exp; branches; next 1.73; 1.73 date 2013.08.16.03.02.34; author manu; state Exp; branches; next 1.72; 1.72 date 2013.08.13.03.45.35; author manu; state Exp; branches; next 1.71; 1.71 date 2013.01.19.16.01.15; author manu; state Exp; branches; next 1.70; 1.70 date 2011.08.17.01.06.49; author manu; state Exp; branches; next 1.69; 1.69 date 2010.06.16.01.30.30; author manu; state Exp; branches; next 1.68; 1.68 date 2010.04.18.03.55.41; author manu; state Exp; branches; next 1.67; 1.67 date 2010.04.17.09.04.47; author manu; state Exp; branches; next 1.66; 1.66 date 2010.04.13.04.29.36; author manu; state Exp; branches; next 1.65; 1.65 date 2010.03.13.06.57.47; author manu; state Exp; branches; next 1.64; 1.64 date 2009.09.09.12.19.17; author manu; state Exp; branches; next 1.63; 1.63 date 2009.09.07.12.56.54; author manu; state Exp; branches; next 1.62; 1.62 date 2009.04.19.00.55.32; author manu; state Exp; branches; next 1.61; 1.61 date 2009.01.17.04.32.55; author manu; state Exp; branches 1.61.2.1; next 1.60; 1.60 date 2008.11.06.11.23.53; author manu; state Exp; branches; next 1.59; 1.59 date 2008.10.30.04.39.39; author manu; state Exp; branches; next 1.58; 1.58 date 2008.09.26.23.35.44; author manu; state Exp; branches; next 1.57; 1.57 date 2008.09.26.17.00.51; author manu; state Exp; branches; next 1.56; 1.56 date 2008.09.07.00.13.34; author manu; state Exp; branches; next 1.55; 1.55 date 2008.09.02.04.15.33; author manu; state Exp; branches; next 1.54; 1.54 date 2008.08.21.21.05.35; author manu; state Exp; branches; next 1.53; 1.53 date 2008.08.03.05.00.06; author manu; state Exp; branches; next 1.52; 1.52 date 2007.12.29.19.06.49; author manu; state Exp; branches; next 1.51; 1.51 date 2007.11.06.11.39.33; author manu; state Exp; branches; next 1.50; 1.50 date 2007.10.05.10.35.00; author manu; state Exp; branches; next 1.49; 1.49 date 2007.10.03.10.52.23; author manu; state Exp; branches; next 1.48; 1.48 date 2007.09.27.03.45.03; author manu; state Exp; branches; next 1.47; 1.47 date 2007.07.08.21.02.28; author manu; state Exp; branches; next 1.46; 1.46 date 2007.02.06.14.29.55; author manu; state Exp; branches; next 1.45; 1.45 date 2006.12.26.21.21.52; author manu; state Exp; branches; next 1.44; 1.44 date 2006.12.06.15.02.41; author manu; state Exp; branches; next 1.43; 1.43 date 2006.09.20.07.50.09; author manu; state Exp; branches; next 1.42; 1.42 date 2006.08.30.20.50.42; author manu; state Exp; branches 1.42.2.1; next 1.41; 1.41 date 2006.08.30.04.57.58; author manu; state Exp; branches; next 1.40; 1.40 date 2006.08.28.06.09.38; author manu; state Exp; branches; next 1.39; 1.39 date 2006.08.27.20.54.40; author manu; state Exp; branches; next 1.38; 1.38 date 2006.07.27.08.20.12; author manu; state Exp; branches; next 1.37; 1.37 date 2006.07.26.13.03.11; author manu; state Exp; branches; next 1.36; 1.36 date 2006.07.26.08.38.16; author manu; state Exp; branches; next 1.35; 1.35 date 2006.01.11.06.40.39; author manu; state Exp; branches; next 1.34; 1.34 date 2005.11.30.23.32.12; author manu; state Exp; branches; next 1.33; 1.33 date 2005.03.19.07.38.53; author manu; state Exp; branches; next 1.32; 1.32 date 2005.01.29.18.42.53; author manu; state Exp; branches; next 1.31; 1.31 date 2004.12.16.23.08.13; author manu; state Exp; branches; next 1.30; 1.30 date 2004.12.08.22.23.09; author manu; state Exp; branches; next 1.29; 1.29 date 2004.10.26.19.57.40; author manu; state Exp; branches; next 1.28; 1.28 date 2004.10.11.20.57.42; author manu; state Exp; branches; next 1.27; 1.27 date 2004.08.08.21.24.20; author manu; state Exp; branches; next 1.26; 1.26 date 2004.08.01.09.27.03; author manu; state Exp; branches; next 1.25; 1.25 date 2004.06.25.22.28.08; author manu; state Exp; branches; next 1.24; 1.24 date 2004.06.12.08.41.56; author manu; state Exp; branches; next 1.23; 1.23 date 2004.06.08.14.47.47; author manu; state Exp; branches; next 1.22; 1.22 date 2004.06.08.12.04.21; author manu; state Exp; branches; next 1.21; 1.21 date 2004.05.31.15.15.12; author manu; state Exp; branches; next 1.20; 1.20 date 2004.05.26.09.14.29; author manu; state Exp; branches; next 1.19; 1.19 date 2004.05.24.21.57.36; author manu; state Exp; branches; next 1.18; 1.18 date 2004.05.24.21.22.02; author manu; state Exp; branches; next 1.17; 1.17 date 2004.05.23.13.03.41; author manu; state Exp; branches; next 1.16; 1.16 date 2004.05.15.08.41.54; author manu; state Exp; branches; next 1.15; 1.15 date 2004.04.02.15.06.52; author manu; state Exp; branches; next 1.14; 1.14 date 2004.04.02.08.57.18; author manu; state Exp; branches; next 1.13; 1.13 date 2004.04.01.14.03.52; author manu; state Exp; branches; next 1.12; 1.12 date 2004.03.31.17.02.08; author manu; state Exp; branches; next 1.11; 1.11 date 2004.03.31.15.31.59; author manu; state Exp; branches; next 1.10; 1.10 date 2004.03.31.12.10.16; author manu; state Exp; branches; next 1.9; 1.9 date 2004.03.31.11.39.26; author manu; state Exp; branches; next 1.8; 1.8 date 2004.03.31.09.49.16; author manu; state Exp; branches; next 1.7; 1.7 date 2004.03.22.21.56.35; author manu; state Exp; branches; next 1.6; 1.6 date 2004.03.22.07.12.38; author manu; state Exp; branches; next 1.5; 1.5 date 2004.03.19.10.16.38; author manu; state Exp; branches; next 1.4; 1.4 date 2004.03.18.22.37.21; author manu; state Exp; branches; next 1.3; 1.3 date 2004.03.18.09.55.14; author manu; state Exp; branches; next 1.2; 1.2 date 2004.03.11.14.12.48; author manu; state Exp; branches; next 1.1; 1.1 date 2004.03.10.21.11.45; author manu; state Exp; branches; next ; 1.61.2.1 date 2010.03.13.07.07.34; author manu; state Exp; branches; next 1.61.2.2; 1.61.2.2 date 2010.04.18.03.56.40; author manu; state Exp; branches; next ; 1.42.2.1 date 2006.09.04.22.05.58; author manu; state Exp; branches; next 1.42.2.2; 1.42.2.2 date 2006.09.20.07.38.24; author manu; state Exp; branches; next ; desc @@ 1.74 log @multiracl option to disable sticky whitelisting among recipients @ text @/* $Id: conf.c,v 1.73 2013/08/16 03:02:34 manu Exp $ */ /* * Copyright (c) 2004-2010 Emmanuel Dreyfus * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by Emmanuel Dreyfus * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" #ifdef HAVE_SYS_CDEFS_H #include #ifdef __RCSID __RCSID("$Id: conf.c,v 1.73 2013/08/16 03:02:34 manu Exp $"); #endif #endif #if defined(HAVE_OLD_QUEUE_H) || !defined(HAVE_SYS_QUEUE_H) #include "queue.h" #else #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "spf.h" #include "acl.h" #ifdef USE_DNSRBL #include "dnsrbl.h" #endif #ifdef USE_CURL #include "urlcheck.h" #endif #ifdef USE_LDAP #include "ldapcheck.h" #endif #ifdef USE_DKIM #include "dkimcheck.h" #endif #ifdef USE_P0F #include "p0f.h" #endif #ifdef USE_SPAMD #include "spamd.h" #endif #include "conf.h" #include "sync.h" #include "pending.h" #include "dump.h" #include "list.h" #include "macro.h" #include "ratelimit.h" #include "milter-greylist.h" #ifdef USE_DMALLOC #include #endif /* #define CONF_DEBUG */ /* Default configuration */ struct conf_rec defconf; pthread_key_t conf_key; char *conffile = CONFFILE; int conf_cold = 1; int conf_specified = 0; #define CONF_LOCK pthread_mutex_lock(&conf_lock); #define CONF_UNLOCK pthread_mutex_unlock(&conf_lock); static pthread_mutex_t conf_lock = PTHREAD_MUTEX_INITIALIZER; static struct conf_list conf_list_head; static pthread_cond_t conf_update_cond = PTHREAD_COND_INITIALIZER; static int conf_updating; static char *legacy_conffile = "/etc/mail/greylist.conf"; void conf_init(void) { int error; TAILQ_INIT(&conf_list_head); if ((error = pthread_key_create(&conf_key, 0)) != 0) { mg_log(LOG_ERR, "pthread_key_create failed: %s", strerror(error)); exit(EX_OSERR); } return; } #ifdef CONF_DEBUG static void conf_dump(void) { struct conf_rec *c; TAILQ_FOREACH_REVERSE(c, &conf_list_head, conf_list, c_chain) { char textdate[DATELEN]; struct tm tm; localtime_r(&c->c_timestamp, &tm); strftime(textdate, sizeof textdate, "%Y-%m-%d %T", &tm); mg_log(LOG_DEBUG, "conf_dump: stamp %s ref %d", textdate, c->c_refcount); } } #endif /* CONF_DEBUG */ static void * conf_load_internal(timestamp) void *timestamp; { FILE *stream; struct timeval tv1, tv2, tv3; struct conf_rec *currconf, *threadconf, *newconf; CONF_LOCK; currconf = TAILQ_FIRST(&conf_list_head); CONF_UNLOCK; assert(conf_cold ? (currconf == NULL) : (currconf != NULL)); threadconf = GET_CONF(); if (!(newconf = (struct conf_rec *)malloc(sizeof *newconf))) { mg_log(LOG_ERR, "conf malloc failed: %s", strerror(errno)); exit(EX_OSERR); } /* * Reset the configuration to its default * (This includes command line flags) */ memcpy(newconf, &defconf, sizeof *newconf); newconf->c_refcount = 1; newconf->c_timestamp = *(time_t *)timestamp; (void)gettimeofday(&tv1, NULL); if (!conf_cold || newconf->c_debug) mg_log(LOG_INFO, "%sloading config file \"%s\"", conf_cold ? "" : "re", conffile); errno = 0; if ((stream = Fopen(conffile, "r")) == NULL) { mg_log(LOG_ERR, "cannot open config file %s: %s", conffile, (errno == 0) ? "out of stdio streams" : strerror(errno)); if (conf_cold) exit(EX_OSERR); } else { SET_CLOEXEC(stream); TSS_SET(conf_key, newconf); peer_clear(); ACL_WRLOCK; #ifdef USE_DNSRBL dnsrbl_clear(); #endif #ifdef USE_CURL urlcheck_clear(); #endif #ifdef USE_LDAP ldapcheck_clear(); #endif #ifdef USE_DKIM dkimcheck_clear(); #endif all_list_clear(); macro_clear(); ratelimit_clear(); acl_clear(); conf_in = stream; conf_line = 1; conf_acl_end = 0; conf_racl_end = 0; conf_dacl_end = 0; conf_parse(); conf_dispose_input_file(); ACL_UNLOCK; TSS_SET(conf_key, threadconf); Fclose(stream); if (!conf_cold || newconf->c_debug) { (void)gettimeofday(&tv2, NULL); timersub(&tv2, &tv1, &tv3); mg_log(LOG_INFO, "%sloaded config file \"%s\" in %ld.%06lds", conf_cold ? "" : "re", conffile, tv3.tv_sec, tv3.tv_usec); } } /* * Dump the ACL for debugging purposes */ if (newconf->c_debug || newconf->c_acldebug) acl_dump(); CONF_LOCK; assert(TAILQ_FIRST(&conf_list_head) == currconf); if (currconf && --currconf->c_refcount == 0) { TAILQ_REMOVE(&conf_list_head, currconf, c_chain); free(currconf); } TAILQ_INSERT_HEAD(&conf_list_head, newconf, c_chain); CONF_UNLOCK; #ifdef CONF_DEBUG conf_dump(); #endif dump_conf_changed(); return NULL; } /* Functions other than main() must not invoke this */ void conf_load(void) { struct stat st; if (!conf_specified && strcmp(conffile, legacy_conffile) != 0) { struct stat st; if (stat(legacy_conffile, &st) == 0) { mg_log(LOG_WARNING, "legacy configuration file '%s' is used " "instead of '%s'.", legacy_conffile, conffile); conffile = legacy_conffile; } } if (stat(conffile, &st)) st.st_mtime = (time_t)0; conf_load_internal(&st.st_mtime); } void conf_update(void) { struct stat st; pthread_t tid; pthread_attr_t attr; int error; int need_update; if (stat(conffile, &st) != 0) { mg_log(LOG_ERR, "config file \"%s\" unavailable", conffile); return; } CONF_LOCK; while (conf_updating) pthread_cond_wait(&conf_update_cond, &conf_lock); conf_updating = need_update = st.st_mtime > TAILQ_FIRST(&conf_list_head)->c_timestamp; CONF_UNLOCK; if (!need_update) return; /* * On some platforms, the thread stack limit is too low and * conf_parse will get a SIGSEGV because it overflows the * stack. * * In order to fix this, we spawn a new thread just for * parsing the config file, and we request a stack big * enough to hold the parser data. 2 MB seems okay. * * We do not do that during the initial config load because * it is useless and it will trigger a bug on some systems * (launching a thread before a fork seems to be a problem) */ if ((error = pthread_attr_init(&attr)) != 0) { mg_log(LOG_ERR, "pthread_attr_init failed: %s", strerror(error)); exit(EX_OSERR); } if ((error = pthread_attr_setstacksize(&attr, 2 * 1024 * 1024)) != 0) { mg_log(LOG_ERR, "pthread_attr_setstacksize failed: %s", strerror(error)); exit(EX_OSERR); } if ((error = pthread_create(&tid, &attr, conf_load_internal, &st.st_mtime)) != 0) { mg_log(LOG_ERR, "pthread_create failed: %s", strerror(error)); exit(EX_OSERR); } if ((error = pthread_attr_destroy(&attr)) != 0) { mg_log(LOG_ERR, "pthread_attr_destroy failed: %s", strerror(error)); exit(EX_OSERR); } if ((error = pthread_join(tid, NULL)) != 0) { mg_log(LOG_ERR, "pthread_join failed: %s", strerror(error)); exit(EX_OSERR); } CONF_LOCK; conf_updating = 0; CONF_UNLOCK; if ((error = pthread_cond_broadcast(&conf_update_cond)) != 0) { mg_log(LOG_ERR, "pthread_cond_broadcast failed: %s", strerror(error)); abort(); } return; } void conf_retain(void) { struct conf_rec *c; if (GET_CONF()) { mg_log(LOG_ERR, "%s:%d BUG: conf_retain called twice?", __FILE__, __LINE__); assert(0); } CONF_LOCK; c = TAILQ_FIRST(&conf_list_head); #ifdef CONF_DEBUG { char textdate[DATELEN]; struct tm tm; localtime_r(&c->c_timestamp, &tm); strftime(textdate, sizeof textdate, "%Y-%m-%d %T", &tm); mg_log(LOG_DEBUG, "conf_retain: stamp %s ref %d -> %d", textdate, c->c_refcount, c->c_refcount + 1); } #endif ++c->c_refcount; CONF_UNLOCK; TSS_SET(conf_key, c); } void conf_release(void) { struct conf_rec *c = GET_CONF(); if (!c) { mg_log(LOG_ERR, "%s:%d BUG: conf_release before conf_retain", __FILE__, __LINE__); assert(0); return; } CONF_LOCK; #ifdef CONF_DEBUG { char textdate[DATELEN]; struct tm tm; localtime_r(&c->c_timestamp, &tm); strftime(textdate, sizeof textdate, "%Y-%m-%d %T", &tm); mg_log(LOG_DEBUG, "conf_release: stamp %s ref %d -> %d", textdate, c->c_refcount, c->c_refcount - 1); } #endif if (--c->c_refcount == 0) { TAILQ_REMOVE(&conf_list_head, c, c_chain); free(c); } CONF_UNLOCK; TSS_SET(conf_key, NULL); } /* * Write path into dst, stripping leading and trailing quotes */ char * quotepath(dst, path, len) char *dst; char *path; size_t len; { path++; /* strip first quote */ strncpy(dst, path, len); dst[len] = '\0'; /* Strip trailing quote */ if ((len = strlen(dst)) > 0) dst[len - 1] = '\0'; return dst; } void conf_defaults(c) struct conf_rec *c; { c->c_refcount = -1; c->c_timestamp = (time_t)0; c->c_forced = C_GLNONE; c->c_debug = 0; c->c_acldebug = 0; c->c_quiet = 0; c->c_noauth = 0; c->c_multiracl = 0; c->c_noaccessdb = 0; c->c_nospf = 0; c->c_delayedreject = 0; c->c_testmode = 0; c->c_delay = GLDELAY; c->c_autowhite_validity = AUTOWHITE_VALIDITY; c->c_tarpit = TARPIT_DURATION; c->c_tarpit_scope = TAP_SESSION; c->c_pidfile = NULL; c->c_dumpfile = DUMPFILE; c->c_dumpfile_mode = -1; prefix2mask4(32, &c->c_match_mask); #ifdef AF_INET6 prefix2mask6(128, &c->c_match_mask6); #endif c->c_syncaddr = NULL; c->c_syncport = NULL; c->c_syncsrcaddr = NULL; c->c_syncsrcport = NULL; c->c_socket = NULL; c->c_socket_mode = -1; c->c_user = NULL; c->c_nodetach = 0; c->c_report = C_ALL; c->c_dumpfreq = DUMPFREQ; c->c_timeout = TIMEOUT; c->c_extendedregex = 0; c->c_unbracket = 0; c->c_dracdb = DRACDB; c->c_nodrac = 0; c->c_maxpeek = 0; c->c_logfac = LOG_MAIL; c->c_domainexact = 0; #ifdef USE_P0F c->c_p0fsock[0] = '\0'; #endif #ifdef USE_SPAMD c->c_spamdsock[0] = '\0'; c->c_spamdsocktype[0] = '\0'; #endif c->c_syncmaxqlen = SYNC_MAXQLEN; (void)memset(&c->c_localaddr, 0, sizeof(c->c_localaddr)); (void)memset(&c->c_localaddr_string, 0, sizeof(c->c_localaddr_string)); return; } @ 1.73 log @unbracket option to resolved MTA-passed bracketed unresolved IP @ text @d1 1 a1 1 /* $Id: conf.c,v 1.72 2013/08/13 03:45:35 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.72 2013/08/13 03:45:35 manu Exp $"); d452 1 @ 1.72 log @Use localaddr for p0f and %V format string (Jim Klimov) @ text @d1 1 a1 1 /* $Id: conf.c,v 1.71 2013/01/19 16:01:15 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.71 2013/01/19 16:01:15 manu Exp $"); d479 1 @ 1.71 log @More Solaris build fixes (Jim Klimov) @ text @d1 1 a1 1 /* $Id: conf.c,v 1.70 2011/08/17 01:06:49 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.70 2011/08/17 01:06:49 manu Exp $"); d493 1 @ 1.70 log @localaddr option so that Postifix user can use spf self @ text @d1 1 a1 1 /* $Id: conf.c,v 1.69 2010/06/16 01:30:30 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.69 2010/06/16 01:30:30 manu Exp $"); d41 1 a41 1 #ifdef HAVE_OLD_QUEUE_H @ 1.69 log @Close-on-exec sockets to avoid file shortage with stat (Enrico Scholz) @ text @d1 1 a1 1 /* $Id: conf.c,v 1.68 2010/04/18 03:55:41 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.68 2010/04/18 03:55:41 manu Exp $"); d492 1 @ 1.68 log @Fix missing ratelimit initialization. It worked only if you were lucky and if the ratelimit configuration list head pointer was set to 0 on program startup. I am lucky. @ text @d1 1 a1 1 /* $Id: conf.c,v 1.67 2010/04/17 09:04:47 manu Exp $ */ d4 1 a4 1 * Copyright (c) 2004 Emmanuel Dreyfus d37 1 a37 1 __RCSID("$Id: conf.c,v 1.67 2010/04/17 09:04:47 manu Exp $"); d188 1 @ 1.67 log @Test for legacy config file timestamp so that it does not loop reloading: the config file timestamp was taken from the non legacy config file (@@sysconfdir@@/mail/greylist.conf), even if the legacy config file (/etc/mail/greylist.conf) was used afterwards. This resulted in the config file time stamp being epoch, and infinite reloads loops occured. @ text @d1 1 a1 1 /* $Id: conf.c,v 1.66 2010/04/13 04:29:36 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.66 2010/04/13 04:29:36 manu Exp $"); d90 1 d206 1 @ 1.66 log @about config file reloacation: "IT SHOULD BE RENAMED" is a bit too much, let us remove it @ text @d1 1 a1 1 /* $Id: conf.c,v 1.65 2010/03/13 06:57:47 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.65 2010/03/13 06:57:47 manu Exp $"); a177 11 if (!conf_specified && strcmp(conffile, legacy_conffile) != 0) { struct stat st; if (stat(legacy_conffile, &st) == 0) { mg_log(LOG_WARNING, "legacy configuration file '%s' is used " "instead of '%s'.", legacy_conffile, conffile); conffile = legacy_conffile; } } d258 11 d271 1 @ 1.65 log @Fix p0f related crashes caused by thread unsafety (Enrico Scholz) @ text @d1 1 a1 1 /* $Id: conf.c,v 1.64 2009/09/09 12:19:17 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.64 2009/09/09 12:19:17 manu Exp $"); d184 1 a184 3 "instead of '%s'. IT SHOULD BE RENAMED!", legacy_conffile, conffile); @ 1.64 log @Fix Debian startup script @ text @d1 1 a1 1 /* $Id: conf.c,v 1.63 2009/09/07 12:56:54 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.63 2009/09/07 12:56:54 manu Exp $"); a215 3 #ifdef USE_P0F p0f_clear(); #endif @ 1.63 log @New tarpit feature (Kouhei Sutou) @ text @d1 1 a1 1 /* $Id: conf.c,v 1.62 2009/04/19 00:55:32 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.62 2009/04/19 00:55:32 manu Exp $"); d103 1 d111 1 d178 13 @ 1.62 log @Merge autowhite and greylist databases (Rudy Eschauzier) @ text @d1 1 a1 1 /* $Id: conf.c,v 1.61 2009/01/17 04:32:55 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.61 2009/01/17 04:32:55 manu Exp $"); d444 2 @ 1.61 log @Workaround "peer queue overflow" bugs (Laurence Moindrot, Jean Benoit) @ text @d1 1 a1 1 /* $Id: conf.c,v 1.60 2008/11/06 11:23:53 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.60 2008/11/06 11:23:53 manu Exp $"); a83 1 #include "autowhite.h" @ 1.61.2.1 log @Really support dkim self and dkim none clauses @ text @d1 1 a1 1 /* $Id: conf.c,v 1.61 2009/01/17 04:32:55 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.61 2009/01/17 04:32:55 manu Exp $"); d202 3 @ 1.61.2.2 log @Fix missing ratelimit initialization. @ text @d1 1 a1 1 /* $Id: conf.c,v 1.61.2.1 2010/03/13 07:07:34 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.61.2.1 2010/03/13 07:07:34 manu Exp $"); a90 1 #include "ratelimit.h" a203 1 ratelimit_clear(); @ 1.60 log @Add option to match exact domain instead of substrings (Rick Adams) @ text @d1 1 a1 1 /* $Id: conf.c,v 1.59 2008/10/30 04:39:39 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.59 2008/10/30 04:39:39 manu Exp $"); d476 1 @ 1.59 log @Make sure DKIM code does not use invalid pointer on a not yet initialized config @ text @d1 1 a1 1 /* $Id: conf.c,v 1.58 2008/09/26 23:35:44 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.58 2008/09/26 23:35:44 manu Exp $"); d468 1 @ 1.58 log @Spamassassin support and DATA-stage greylisting (Manuel Badzong) @ text @d1 1 a1 1 /* $Id: conf.c,v 1.57 2008/09/26 17:00:51 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.57 2008/09/26 17:00:51 manu Exp $"); a467 3 #ifdef USE_DKIM c->c_dkim = NULL; #endif @ 1.57 log @ Allow syslog facility to be configured (Joe Pruett) Allow logging to be disabled on a per-ACL basis (Joe Pruett)v @ text @d1 1 a1 1 /* $Id: conf.c,v 1.56 2008/09/07 00:13:34 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.56 2008/09/07 00:13:34 manu Exp $"); d81 3 d474 4 @ 1.56 log @Experimental p0f support Fix a memory leak in GeoIP code Fix a memory leak in DKIM code Bump to revision to 4.1.6 (but no tag yet) @ text @d1 1 a1 1 /* $Id: conf.c,v 1.55 2008/09/02 04:15:33 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.55 2008/09/02 04:15:33 manu Exp $"); d464 1 @ 1.55 log @Build again without DKIM @ text @d1 1 a1 1 /* $Id: conf.c,v 1.54 2008/08/21 21:05:35 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.54 2008/08/21 21:05:35 manu Exp $"); d78 3 d199 3 d467 3 a469 1 @ 1.54 log @Exprimental DKIM support @ text @d1 1 a1 1 /* $Id: conf.c,v 1.53 2008/08/03 05:00:06 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.53 2008/08/03 05:00:06 manu Exp $"); d458 1 d460 1 @ 1.53 log @Native LDAP support through OpenLDAP bump to 4.1.4 @ text @d1 1 a1 1 /* $Id: conf.c,v 1.52 2007/12/29 19:06:49 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.52 2007/12/29 19:06:49 manu Exp $"); d75 3 d193 3 d458 1 @ 1.52 log @Add configurable dumpfile permissions @ text @d1 1 a1 1 /* $Id: conf.c,v 1.51 2007/11/06 11:39:33 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.51 2007/11/06 11:39:33 manu Exp $"); d72 3 d187 3 @ 1.51 log @Add SPF status selection to ACL @ text @d1 1 a1 1 /* $Id: conf.c,v 1.50 2007/10/05 10:35:00 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.50 2007/10/05 10:35:00 manu Exp $"); d426 1 d436 1 a436 1 c->c_socket_mode = 0; @ 1.50 log @Apply missing patch bits for FD_POOL (Solaris 256 stream limitation workaround) @ text @d1 1 a1 1 /* $Id: conf.c,v 1.49 2007/10/03 10:52:23 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.49 2007/10/03 10:52:23 manu Exp $"); d64 1 @ 1.49 log @Workaround for Solaris 256 stream limitation (Johann E. Klasek) @ text @d1 1 a1 1 /* $Id: conf.c,v 1.48 2007/09/27 03:45:03 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.48 2007/09/27 03:45:03 manu Exp $"); d165 1 a165 1 if ((stream = fopen(conffile, "r")) == NULL) { @ 1.48 log @Handle libc that fails stdio without setting errno (Johann E. Klasek) @ text @d1 1 a1 1 /* $Id: conf.c,v 1.47 2007/07/08 21:02:28 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.47 2007/07/08 21:02:28 manu Exp $"); d199 1 a199 1 fclose(stream); @ 1.47 log @Add hooks for libdmalloc @ text @d1 1 a1 1 /* $Id: conf.c,v 1.46 2007/02/06 14:29:55 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.46 2007/02/06 14:29:55 manu Exp $"); d164 1 d167 2 a168 1 conffile, strerror(errno)); @ 1.46 log @Allow specifying socket mode in config file @ text @d1 1 a1 1 /* $Id: conf.c,v 1.45 2006/12/26 21:21:52 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.45 2006/12/26 21:21:52 manu Exp $"); d80 4 @ 1.45 log @Allow header and body searches in DATA-stage ACL Allow CIDR match for DNSRBL (not tested) @ text @d1 1 a1 1 /* $Id: conf.c,v 1.44 2006/12/06 15:02:41 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.44 2006/12/06 15:02:41 manu Exp $"); d428 1 @ 1.44 log @Add URL check feature Bump to 3.1.2 @ text @d1 1 a1 1 /* $Id: conf.c,v 1.43 2006/09/20 07:50:09 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.43 2006/09/20 07:50:09 manu Exp $"); d184 2 d436 1 @ 1.43 log @Warn about ignored ACL lines after acl default rule @ text @d1 1 a1 1 /* $Id: conf.c,v 1.42 2006/08/30 20:50:42 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.42 2006/08/30 20:50:42 manu Exp $"); d68 3 d174 3 @ 1.42 log @clear macro and list too @ text @d1 1 a1 1 /* $Id: conf.c,v 1.41 2006/08/30 04:57:58 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.41 2006/08/30 04:57:58 manu Exp $"); d177 1 @ 1.42.2.1 log @Back out race conditions fixes (too intrusive, will be back in 3.1.x) @ text @d1 1 a1 1 /* $Id: conf.c,v 1.40 2006/08/28 06:09:38 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.40 2006/08/28 06:09:38 manu Exp $"); d60 3 d73 2 d77 2 d80 3 a82 4 struct conf defconf; struct conf conf; a83 11 int conf_nodetach = 0; char c_pidfile[QSTRLEN + 1]; char c_dumpfile[QSTRLEN + 1]; char c_socket[QSTRLEN + 1]; char c_user[QSTRLEN + 1]; char c_syncaddr[IPADDRSTRLEN + 1]; char c_syncport[NUMLEN + 1]; char c_syncsrcaddr[IPADDRSTRLEN + 1]; char c_syncsrcport[NUMLEN + 1]; char c_dracdb[QSTRLEN + 1]; d85 6 a90 13 char *conffile = CONFFILE; struct timeval conffile_modified; int numb_of_conf_update_threads; #define MAX_NUMB_OF_CONF_UPDATE_THREADS 1 /* * this lock does not protect conf_update any more, * only conffile_modified and numb_of_conf_update_threads. * there are lot of non-auto variables above to protect as well, * so it is safer to limit the maximum number of configuration loading * processes to one for the time being. */ pthread_rwlock_t conf_lock; d96 3 a98 1 if ((error = pthread_rwlock_init(&conf_lock, NULL)) != 0) { d100 1 a100 1 "pthread_rwlock_init failed: %s", strerror(error)); d107 20 a126 2 void conf_load(void) d130 12 d147 3 a149 1 memcpy(&conf, &defconf, sizeof(conf)); d153 1 a153 1 if (!conf_cold || conf.c_debug) d160 3 a162 1 mg_log(LOG_ERR, "continuing with no exception list"); d164 1 d171 2 d179 1 d182 2 d186 1 a186 1 if (!conf_cold || conf.c_debug) { d196 11 a206 6 if (conf_cold) { (void)gettimeofday(&conffile_modified, NULL); } else { CONF_WRLOCK; --numb_of_conf_update_threads; CONF_UNLOCK; d208 9 d218 4 a221 2 if (conf.c_debug || conf.c_acldebug) acl_dump(); d223 3 a225 1 return; d234 1 d242 8 a249 6 CONF_WRLOCK; numb_of_conf_update_threads++; if (st.st_mtime <= conffile_modified.tv_sec || numb_of_conf_update_threads > MAX_NUMB_OF_CONF_UPDATE_THREADS) { --numb_of_conf_update_threads; CONF_UNLOCK; a250 3 } conffile_modified.tv_sec = st.st_mtime; CONF_UNLOCK; d279 1 a279 1 (void *(*)(void *))conf_load, NULL)) != 0) { d285 2 a286 2 if ((error = pthread_detach(tid)) != 0) { mg_log(LOG_ERR, "pthread_detach failed: %s", d291 2 a292 2 if ((error = pthread_attr_destroy(&attr)) != 0) { mg_log(LOG_ERR, "pthread_attr_destroy failed: %s", d297 9 d309 61 d392 1 a392 1 struct conf *c; d394 3 d420 1 @ 1.42.2.2 log @Warn about ignored ACL lines after acl default rule @ text @d1 1 a1 1 /* $Id: conf.c,v 1.42.2.1 2006/09/04 22:05:58 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.42.2.1 2006/09/04 22:05:58 manu Exp $"); a149 1 conf_acl_end = 0; @ 1.41 log @Fix various race conditions (AIDA Shinra) @ text @d1 1 a1 2 /* $Id: conf.c,v 1.40 2006/08/28 06:09:38 manu Exp $ */ /* vim: set sw=8 ts=8 sts=8 noet cino=(0: */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.40 2006/08/28 06:09:38 manu Exp $"); d73 2 d158 5 a162 5 if (conf_cold) { mg_log(LOG_ERR, "cannot open config file %s: %s", conffile, strerror(errno)); mg_log(LOG_ERR, "continuing with no exception list"); } d171 2 @ 1.40 log @Make sure -c tells what happens and return an usable exit code @ text @d1 2 a2 1 /* $Id: conf.c,v 1.39 2006/08/27 20:54:40 manu Exp $ */ d38 1 a38 1 __RCSID("$Id: conf.c,v 1.39 2006/08/27 20:54:40 manu Exp $"); d61 3 d76 2 d79 2 a80 14 struct conf defconf; struct conf conf; char c_pidfile[QSTRLEN + 1]; char c_dumpfile[QSTRLEN + 1]; char c_socket[QSTRLEN + 1]; char c_user[QSTRLEN + 1]; char c_syncaddr[IPADDRSTRLEN + 1]; char c_syncport[NUMLEN + 1]; char c_syncsrcaddr[IPADDRSTRLEN + 1]; char c_syncsrcport[NUMLEN + 1]; char c_dracdb[QSTRLEN + 1]; d82 1 a82 2 struct timeval conffile_modified; int numb_of_conf_update_threads; d84 6 a89 9 #define MAX_NUMB_OF_CONF_UPDATE_THREADS 1 /* * this lock does not protect conf_update any more, * only conffile_modified and numb_of_conf_update_threads. * there are lot of non-auto variables above to protect as well, * so it is safer to limit the maximum number of configuration loading * processes to one for the time being. */ pthread_rwlock_t conf_lock; d95 3 a97 1 if ((error = pthread_rwlock_init(&conf_lock, NULL)) != 0) { d99 1 a99 1 "pthread_rwlock_init failed: %s", strerror(error)); d106 20 a125 2 void conf_load(void) d129 12 d146 3 a148 1 memcpy(&conf, &defconf, sizeof(conf)); d152 1 a152 1 if (!conf.c_cold || conf.c_debug) d154 1 a154 1 conf.c_cold ? "" : "re", conffile); d157 5 a161 3 mg_log(LOG_ERR, "cannot open config file %s: %s", conffile, strerror(errno)); mg_log(LOG_ERR, "continuing with no exception list"); d163 1 d176 1 d179 2 d183 1 a183 1 if (!conf.c_cold || conf.c_debug) { d188 1 a188 1 conf.c_cold ? "" : "re", conffile, d193 11 a203 6 if (conf.c_cold) { (void)gettimeofday(&conffile_modified, NULL); } else { CONF_WRLOCK; --numb_of_conf_update_threads; CONF_UNLOCK; d205 9 d215 4 a218 2 if (conf.c_debug || conf.c_acldebug) acl_dump(); d220 3 a222 1 return; d231 1 d239 8 a246 6 CONF_WRLOCK; numb_of_conf_update_threads++; if (st.st_mtime <= conffile_modified.tv_sec || numb_of_conf_update_threads > MAX_NUMB_OF_CONF_UPDATE_THREADS) { --numb_of_conf_update_threads; CONF_UNLOCK; a247 3 } conffile_modified.tv_sec = st.st_mtime; CONF_UNLOCK; d276 1 a276 1 (void *(*)(void *))conf_load, NULL)) != 0) { d282 2 a283 2 if ((error = pthread_detach(tid)) != 0) { mg_log(LOG_ERR, "pthread_detach failed: %s", d288 2 a289 2 if ((error = pthread_attr_destroy(&attr)) != 0) { mg_log(LOG_ERR, "pthread_attr_destroy failed: %s", d294 9 d306 61 d389 1 a389 1 struct conf *c; d391 3 a393 1 c->c_cold = 1; @ 1.39 log @Remove the need of LOG_PERROR, make sure no log is missed @ text @d1 1 a1 1 /* $Id: conf.c,v 1.38 2006/07/27 08:20:12 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.38 2006/07/27 08:20:12 manu Exp $"); d128 4 d153 8 a160 4 (void)gettimeofday(&tv2, NULL); timersub(&tv2, &tv1, &tv3); mg_log(LOG_DEBUG, "%sloaded config file in %ld.%06lds", conf.c_cold ? "" : "re", tv3.tv_sec, tv3.tv_usec); a200 2 mg_log(LOG_INFO, "reloading \"%s\"", conffile); @ 1.38 log @Reset conf_line when reparsing config file @ text @d1 1 a1 1 /* $Id: conf.c,v 1.37 2006/07/26 13:03:11 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.37 2006/07/26 13:03:11 manu Exp $"); d106 1 a106 1 syslog(LOG_ERR, d126 1 a126 2 if (!conf.c_cold) (void)gettimeofday(&tv1, NULL); d129 3 a131 8 if (conf.c_cold) { fprintf(stderr, "cannot open config file %s: %s\n", conffile, strerror(errno)); fprintf(stderr, "continuing with no exception list\n"); } else { syslog(LOG_ERR, "cannot open config file %s: %s", conffile, strerror(errno)); } d149 4 a152 7 if (!conf.c_cold) { (void)gettimeofday(&tv2, NULL); timersub(&tv2, &tv1, &tv3); syslog(LOG_DEBUG, "%sloaded config file in %ld.%06lds", conf.c_cold ? "" : "re", tv3.tv_sec, tv3.tv_usec); } a155 2 conf.c_cold = 0; defconf.c_cold = 0; d177 1 a177 1 syslog(LOG_ERR, "config file \"%s\" unavailable", d193 1 a193 1 syslog(LOG_INFO, "reloading \"%s\"", conffile); d209 1 a209 1 syslog(LOG_ERR, "pthread_attr_init failed: %s", d216 1 a216 1 syslog(LOG_ERR, "pthread_attr_setstacksize failed: %s", d223 1 a223 1 syslog(LOG_ERR, "pthread_create failed: %s", d229 1 a229 1 syslog(LOG_ERR, "pthread_detach failed: %s", d235 1 a235 1 syslog(LOG_ERR, "pthread_attr_destroy failed: %s", @ 1.37 log @Rename PATH -> QSTRING @ text @d1 1 a1 1 /* $Id: conf.c,v 1.36 2006/07/26 08:38:16 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.36 2006/07/26 08:38:16 manu Exp $"); d148 1 @ 1.36 log @config reload for DNSRBL information @ text @d1 1 a1 1 /* $Id: conf.c,v 1.35 2006/01/11 06:40:39 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.35 2006/01/11 06:40:39 manu Exp $"); d77 4 a80 4 char c_pidfile[PATHLEN + 1]; char c_dumpfile[PATHLEN + 1]; char c_socket[PATHLEN + 1]; char c_user[PATHLEN + 1]; d85 1 a85 1 char c_dracdb[PATHLEN + 1]; @ 1.35 log @Selectable MX sync source address @ text @d1 1 a1 1 /* $Id: conf.c,v 1.34 2005/11/30 23:32:12 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.34 2005/11/30 23:32:12 manu Exp $"); d62 3 d142 3 a149 1 @ 1.34 log @DRAC support @ text @d1 1 a1 1 /* $Id: conf.c,v 1.33 2005/03/19 07:38:53 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.33 2005/03/19 07:38:53 manu Exp $"); d80 2 d292 2 @ 1.33 log @extendedregex for using extended regex instead of basic regex. @ text @d1 1 a1 1 /* $Id: conf.c,v 1.32 2005/01/29 18:42:53 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.32 2005/01/29 18:42:53 manu Exp $"); d80 1 d297 2 @ 1.32 log @Delayed reject for <> sender to cope better with sender callback (Moritz Both) @ text @d1 1 a1 1 /* $Id: conf.c,v 1.31 2004/12/16 23:08:13 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.31 2004/12/16 23:08:13 manu Exp $"); d295 1 @ 1.31 log @Use Sendmail DB as a whitelist source: if ${greylist} is defined as WHITE, assume whitelist. @ text @d1 1 a1 1 /* $Id: conf.c,v 1.30 2004/12/08 22:23:09 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.30 2004/12/08 22:23:09 manu Exp $"); d277 1 @ 1.30 log @New ACL framework for whitelist and greylist (Remy Card) Tell MX peers about autowhitelist prolongation (Remy Card) @ text @d1 1 a1 1 /* $Id: conf.c,v 1.29 2004/10/26 19:57:40 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.29 2004/10/26 19:57:40 manu Exp $"); d275 1 @ 1.29 log @Don't block the threads while reloading the config @ text @d1 1 a1 1 /* $Id: conf.c,v 1.28 2004/10/11 20:57:42 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.28 2004/10/11 20:57:42 manu Exp $"); d61 1 a63 1 #include "except.h" d135 2 a136 2 EXCEPT_WRLOCK; except_clear(); d142 1 a142 1 EXCEPT_UNLOCK; d165 3 d272 1 @ 1.28 log @Namespace conflicts on Tru64 Unix with IPv6 @ text @d1 1 a1 1 /* $Id: conf.c,v 1.27 2004/08/08 21:24:20 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.27 2004/08/08 21:24:20 manu Exp $"); d83 1 d85 9 a93 1 pthread_rwlock_t conf_lock; /* protects conf_update */ d109 1 a109 1 conf_load(void) /* exceptlist must be write-locked */ d112 1 a112 3 pthread_t tid; pthread_attr_t attr; int error; d120 3 a122 3 /* * And load the new one */ d124 13 a136 5 fprintf(stderr, "cannot open config file %s: %s\n", conffile, strerror(errno)); fprintf(stderr, "continuing with no exception list\n"); return; } d138 1 a138 1 conf_in = stream; a139 14 /* * On some platforms, the thread stack limit is too low and * conf_parse will get a SIGSEGV because it overflows the * stack. * * In order to fix this, we spawn a new thread just for * parsing the config file, and we request a stack big * enough to hold the parser data. 2 MB seems okay. * * We do not do that during the initial config load because * it is useless and it will trigger a bug on some systems * (launching a thread before a fork seems to be a problem) */ if (conf.c_cold) { a140 8 conf.c_cold = 0; defconf.c_cold = 0; } else { if ((error = pthread_attr_init(&attr)) != 0) { syslog(LOG_ERR, "pthread_attr_init failed: %s", strerror(error)); exit(EX_OSERR); } d142 1 a142 6 if ((error = pthread_attr_setstacksize(&attr, 2 * 1024 * 1024)) != 0) { syslog(LOG_ERR, "pthread_attr_setstacksize failed: %s", strerror(error)); exit(EX_OSERR); } d144 1 a144 6 if ((error = pthread_create(&tid, &attr, (void *(*)(void *))conf_parse, NULL)) != 0) { syslog(LOG_ERR, "pthread_create failed: %s", strerror(error)); exit(EX_OSERR); } d146 6 a151 4 if ((error = pthread_join(tid, NULL)) != 0) { syslog(LOG_ERR, "pthread_join failed: %s", strerror(error)); exit(EX_OSERR); d153 1 d155 8 a162 5 if ((error = pthread_attr_destroy(&attr)) != 0) { syslog(LOG_ERR, "pthread_attr_destroy failed: %s", strerror(error)); exit(EX_OSERR); } a164 4 fclose(stream); (void)gettimeofday(&conffile_modified, NULL); d171 3 a173 1 struct timeval tv1, tv2, tv3; d181 6 a186 4 /* * conffile_modified is updated in conf_load() */ if (st.st_mtime < conffile_modified.tv_sec) d188 3 a192 2 if (conf.c_debug) (void)gettimeofday(&tv1, NULL); d194 43 a236 11 peer_clear(); EXCEPT_WRLOCK; except_clear(); conf_load(); EXCEPT_UNLOCK; if (conf.c_debug) { (void)gettimeofday(&tv2, NULL); timersub(&tv2, &tv1, &tv3); syslog(LOG_DEBUG, "reloaded config file in %ld.%06lds", tv3.tv_sec, tv3.tv_usec); @ 1.27 log @Configurable MX sync bind port and address (Cyril Guibourg) Bump to 1.5.6 @ text @d1 1 a1 1 /* $Id: conf.c,v 1.26 2004/08/01 09:27:03 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.26 2004/08/01 09:27:03 manu Exp $"); d245 1 a245 1 c->c_forced = C_NONE; @ 1.26 log @Full blown IPv6 support, from Hajimu Umemoto Correctly clean rc-debian.sh @ text @d1 1 a1 1 /* $Id: conf.c,v 1.25 2004/06/25 22:28:08 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.25 2004/06/25 22:28:08 manu Exp $"); d78 2 d259 2 @ 1.25 log @Avoid race conditions when reloading the config (Attila Bruncsak) @ text @d1 1 a1 1 /* $Id: conf.c,v 1.24 2004/06/12 08:41:56 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.24 2004/06/12 08:41:56 manu Exp $"); d253 4 a256 1 cidr2mask(32, &c->c_match_mask); @ 1.24 log @Minor bug fixes in queue management from Wolfgang Solfrank @ text @d1 1 a1 1 /* $Id: conf.c,v 1.23 2004/06/08 14:47:47 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.23 2004/06/08 14:47:47 manu Exp $"); d81 15 @ 1.23 log @Correctly check pthread function return values @ text @d1 1 a1 1 /* $Id: conf.c,v 1.22 2004/06/08 12:04:21 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.22 2004/06/08 12:04:21 manu Exp $"); d217 2 a218 2 if (strlen(dst) > 0) dst[strlen(dst) - 1] = '\0'; @ 1.22 log @Don't use the thread trick on config reload for the first reload. @ text @d1 1 a1 1 /* $Id: conf.c,v 1.21 2004/05/31 15:15:12 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.21 2004/05/31 15:15:12 manu Exp $"); d88 1 d126 1 a126 1 if (pthread_attr_init(&attr) != 0) { d128 1 a128 1 strerror(errno)); d132 2 a133 1 if (pthread_attr_setstacksize(&attr, 2 * 1024 * 1024) != 0) { d135 1 a135 1 strerror(errno)); d139 2 a140 2 if (pthread_create(&tid, &attr, (void *(*)(void *))conf_parse, NULL) != 0) { d142 1 a142 1 strerror(errno)); d146 1 a146 1 if (pthread_join(tid, NULL) != 0) { d148 1 a148 1 strerror(errno)); d152 1 a152 1 if (pthread_attr_destroy(&attr) != 0) { d154 1 a154 1 strerror(errno)); @ 1.21 log @Bug fix: on some platforms, reloading the config caused SIGSEGV It was caused by a stack overflow with pthread implementation that had a low limit on stack grow. We fix the problem by using a dedicated thread just for config reload (and we request a 2MB stck for that thread) Bump to 1.3.7 @ text @d1 1 a1 1 /* $Id: conf.c,v 1.20 2004/05/26 09:14:29 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.20 2004/05/26 09:14:29 manu Exp $"); d105 2 d115 4 d120 35 a154 31 conf_in = stream; if (pthread_attr_init(&attr) != 0) { syslog(LOG_ERR, "pthread_attr_init failed: %s", strerror(errno)); exit(EX_OSERR); } if (pthread_attr_setstacksize(&attr, 2 * 1024 * 1024) != 0) { syslog(LOG_ERR, "pthread_attr_setstacksize failed: %s", strerror(errno)); exit(EX_OSERR); } if (pthread_create(&tid, &attr, (void *(*)(void *))conf_parse, NULL) != 0) { syslog(LOG_ERR, "pthread_create failed: %s", strerror(errno)); exit(EX_OSERR); } if (pthread_join(tid, NULL) != 0) { syslog(LOG_ERR, "pthread_join failed: %s", strerror(errno)); exit(EX_OSERR); } if (pthread_attr_destroy(&attr) != 0) { syslog(LOG_ERR, "pthread_attr_destroy failed: %s", strerror(errno)); exit(EX_OSERR); a155 1 d225 1 @ 1.20 log @timeout option @ text @d1 1 a1 1 /* $Id: conf.c,v 1.19 2004/05/24 21:57:36 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.19 2004/05/24 21:57:36 manu Exp $"); d86 2 d105 9 d115 33 a147 1 conf_parse(); @ 1.19 log @dumpfreq option @ text @d1 1 a1 1 /* $Id: conf.c,v 1.18 2004/05/24 21:22:02 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.18 2004/05/24 21:22:02 manu Exp $"); d189 1 @ 1.18 log @Back out Berkeley DB stuff, it will now live on the BDB branch. @ text @d1 1 a1 1 /* $Id: conf.c,v 1.15 2004/04/02 15:06:52 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.15 2004/04/02 15:06:52 manu Exp $"); d188 1 @ 1.17 log @Don't use an external lockfile, use a field in the database instead @ text @d1 1 a1 1 /* $Id: conf.c,v 1.16 2004/05/15 08:41:54 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.16 2004/05/15 08:41:54 manu Exp $"); a77 2 char c_greylistdb[PATHLEN + 1]; char c_autowhitedb[PATHLEN + 1]; d116 1 a116 1 a138 4 /* Update databse keys and options if needed */ pending_db_options(PS_WARM); autowhite_db_options(AS_WARM); a187 3 c->c_dumpfreq = DUMPFREQ; c->c_greylistdb = GREYLISTDB; c->c_autowhitedb = AUTOWHITEDB; @ 1.16 log @First attempt with Berkeley DB. Some remaining bugs on dynamic modification of options. @ text @d1 1 a1 1 /* $Id: conf.c,v 1.15 2004/04/02 15:06:52 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.15 2004/04/02 15:06:52 manu Exp $"); a79 1 char c_lockfile[PATHLEN + 1]; d142 2 a143 2 pending_db_options(); autowhite_db_options(); a196 1 c->c_lockfile = LOCKFILE; @ 1.15 log @Add a config option to suprress X-Greylist header Bump to 1.10 @ text @d1 1 a1 1 /* $Id: conf.c,v 1.14 2004/04/02 08:57:18 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.14 2004/04/02 08:57:18 manu Exp $"); d78 3 d119 1 a119 1 d142 4 d195 4 @ 1.14 log @Fix build troubles by removing any reference to in_addr_t @ text @d1 1 a1 1 /* $Id: conf.c,v 1.13 2004/04/01 14:03:52 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.13 2004/04/01 14:03:52 manu Exp $"); d187 1 @ 1.13 log @Log debug messages only when running in debug mode. @ text @d1 1 a1 1 /* $Id: conf.c,v 1.12 2004/03/31 17:02:08 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.12 2004/03/31 17:02:08 manu Exp $"); d70 2 a71 16 struct conf defconf = { C_NONE, /* c_forced */ 0, /* c_debug */ 0, /* c_quiet */ 0, /* c_noauth */ 0, /* c_nospf */ 0, /* c_testmode */ GLDELAY, /* c_delay */ AUTOWHITE_VALIDITY, /* c_autowhite_validity */ NULL, /* c_pidfile */ DUMPFILE, /* c_dumpfile */ 0xffffffff, /* c_match_mask */ NULL, /* c_socket */ NULL, /* c_user */ 0, /* c_nodetach */ }; d167 22 @ 1.12 log @Bug fix: dumpfile was not really set in the new conf framework plus really reset the conf to default before reloading it @ text @d1 1 a1 1 /* $Id: conf.c,v 1.11 2004/03/31 15:31:59 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.11 2004/03/31 15:31:59 manu Exp $"); d132 1 a132 1 syslog(LOG_DEBUG, "config file \"%s\" unavailable", @ 1.11 log @Attempt to fix a warning on Solaris @ text @d1 1 a1 1 /* $Id: conf.c,v 1.10 2004/03/31 12:10:16 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.10 2004/03/31 12:10:16 manu Exp $"); d70 1 a70 1 struct conf conf = { d86 2 d101 9 @ 1.10 log @More documentation, nodetach option in config @ text @d1 1 a1 1 /* $Id: conf.c,v 1.9 2004/03/31 11:39:26 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.9 2004/03/31 11:39:26 manu Exp $"); d81 1 a81 1 {0xffffffff}, /* c_match_mask */ @ 1.9 log @socket can now be given in the config file. Documentation on the config file options @ text @d1 1 a1 1 /* $Id: conf.c,v 1.8 2004/03/31 09:49:16 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.8 2004/03/31 09:49:16 manu Exp $"); d81 4 d89 1 @ 1.8 log @Add flag equivalents to the config file @ text @d1 1 a1 1 /* $Id: conf.c,v 1.7 2004/03/22 21:56:35 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.7 2004/03/22 21:56:35 manu Exp $"); d84 1 @ 1.7 log @Include "config.h" first anywhere @ text @d1 1 a1 1 /* $Id: conf.c,v 1.6 2004/03/22 07:12:38 manu Exp $ */ d37 1 a37 1 __RCSID("$Id: conf.c,v 1.6 2004/03/22 07:12:38 manu Exp $"); d61 1 d65 2 d69 16 d127 1 a127 1 if (debug) d136 1 a136 1 if (debug) { d144 20 @ 1.6 log @Guard inclusion, some systems (older digitalUNIX) do not have it @ text @d1 1 a1 1 /* $Id: conf.c,v 1.5 2004/03/19 10:16:38 manu Exp $ */ d32 2 d37 1 a37 1 __RCSID("$Id: conf.c,v 1.5 2004/03/19 10:16:38 manu Exp $"); a40 1 #include "config.h" @ 1.5 log @Fix includes order and wrong ifdef for old queue.h @ text @d1 1 a1 1 /* $Id: conf.c,v 1.4 2004/03/18 22:37:21 manu Exp $ */ d32 1 d35 2 a36 1 __RCSID("$Id: conf.c,v 1.4 2004/03/18 22:37:21 manu Exp $"); @ 1.4 log @Inlude config.h before using HAVE_OLD_QUEUE_H @ text @d1 1 a1 1 /* $Id: conf.c,v 1.3 2004/03/18 09:55:14 manu Exp $ */ d34 8 a41 1 __RCSID("$Id: conf.c,v 1.3 2004/03/18 09:55:14 manu Exp $"); a56 7 #include "config.h" #ifndef HAVE_OLD_QUEUE_H #include "queue.h" #else #include #endif @ 1.3 log @Use a modern queue.h if it is missing from the system (Linux...) @ text @d1 1 a1 1 /* $Id: conf.c,v 1.2 2004/03/11 14:12:48 manu Exp $ */ d34 1 a34 1 __RCSID("$Id: conf.c,v 1.2 2004/03/11 14:12:48 manu Exp $"); d51 1 @ 1.2 log @Rebuild on Linux Build again with -Werror, both on Linux and NetBSD! @ text @d1 1 a1 1 /* $Id: conf.c,v 1.1 2004/03/10 21:11:45 manu Exp $ */ d34 1 a34 1 __RCSID("$Id: conf.c,v 1.1 2004/03/10 21:11:45 manu Exp $"); a45 1 #include d50 6 @ 1.1 log @Renamed except.greylist as except.conf, split the cde between exception list management and config management @ text @d1 1 a1 1 /* $Id$ */ a31 2 #define _XOPEN_SOURCE 500 d34 1 a34 1 __RCSID("$Id$"); @