mirror of
https://github.com/vdukhovni/postfix
synced 2025-08-31 22:25:24 +00:00
snapshot-20001217
This commit is contained in:
committed by
Viktor Dukhovni
parent
2330c3ef92
commit
f15d238e20
1
postfix/.indent.pro
vendored
1
postfix/.indent.pro
vendored
@@ -73,6 +73,7 @@
|
|||||||
-TMKMAP_OPEN_INFO
|
-TMKMAP_OPEN_INFO
|
||||||
-TMULTI_SERVER
|
-TMULTI_SERVER
|
||||||
-TMVECT
|
-TMVECT
|
||||||
|
-TMYSQL
|
||||||
-TMYSQL_NAME
|
-TMYSQL_NAME
|
||||||
-TNAMADR_LIST
|
-TNAMADR_LIST
|
||||||
-TNAME_MASK
|
-TNAME_MASK
|
||||||
|
@@ -18,7 +18,7 @@ use something like:
|
|||||||
|
|
||||||
% make tidy
|
% make tidy
|
||||||
% make makefiles CCARGS="-DHAS_DB -I/usr/local/BerkeleyDB.3.1/include" \
|
% make makefiles CCARGS="-DHAS_DB -I/usr/local/BerkeleyDB.3.1/include" \
|
||||||
AUXLIBS=/usr/local/BerkeleyDB.3.1/lib/libdb.a
|
AUXLIBS="-L/usr/local/BerkeleyDB.3.1/lib -ldb"
|
||||||
% make
|
% make
|
||||||
|
|
||||||
The exact pathnames depend on the DB version that you installed.
|
The exact pathnames depend on the DB version that you installed.
|
||||||
|
@@ -4654,6 +4654,13 @@ Apologies for any names omitted.
|
|||||||
Code cleanup: in a CONFIG_TIME_TABLE, the default time unit
|
Code cleanup: in a CONFIG_TIME_TABLE, the default time unit
|
||||||
is now always the last character of a default time value.
|
is now always the last character of a default time value.
|
||||||
It is no longer necessary to specify the default time unit
|
It is no longer necessary to specify the default time unit
|
||||||
separately. This change means that it is not longer possible
|
separately. This change means that it will not be possible
|
||||||
to specify default values in the form of function calls.
|
to specify default values in the form of function calls,
|
||||||
Files: global/mail_conf_time.c, and user code.
|
but that was unused anyway. Files: global/mail_conf_time.c,
|
||||||
|
and user code.
|
||||||
|
|
||||||
|
20001217
|
||||||
|
|
||||||
|
Bugfix: reorganized some code in the MYSQL client to end
|
||||||
|
a number of memory allocation/deallocation problems.
|
||||||
|
This code needs more work. File: dict_mysql.c.
|
||||||
|
@@ -23,12 +23,16 @@ If you're using the libraries from the UM distribution
|
|||||||
Postfix source tree should work:
|
Postfix source tree should work:
|
||||||
|
|
||||||
% make tidy
|
% make tidy
|
||||||
% make makefiles CCARGS="-I/some/where/include -DHAS_LDAP" \
|
% make makefiles CCARGS="-I/usr/local/include -DHAS_LDAP" \
|
||||||
AUXLIBS="/some/where/lib/libldap.a /some/where/lib/liblber.a"
|
AUXLIBS="-L/usr/local/lib -lldap -L/usr/local/lib -llber"
|
||||||
|
|
||||||
The 'make tidy' command is needed only if you have previously built
|
The 'make tidy' command is needed only if you have previously built
|
||||||
Postfix without LDAP support.
|
Postfix without LDAP support.
|
||||||
|
|
||||||
|
Instead of '/usr/local' specify the actual locations of your LDAP
|
||||||
|
include files and libraries. Be sure to not mix LDAP include files
|
||||||
|
and LDAP libraries of different versions!!
|
||||||
|
|
||||||
If your LDAP libraries were built with Kerberos support, you'll also
|
If your LDAP libraries were built with Kerberos support, you'll also
|
||||||
need to include your Kerberos libraries in this line. Note that the KTH
|
need to include your Kerberos libraries in this line. Note that the KTH
|
||||||
Kerberos IV libraries might conflict with Postfix's lib/libdns.a, which
|
Kerberos IV libraries might conflict with Postfix's lib/libdns.a, which
|
||||||
|
@@ -10,8 +10,8 @@ In order to build postfix with mysql map support, you will need to add
|
|||||||
the mysqlclient library (and libm) to AUXLIBS, for example:
|
the mysqlclient library (and libm) to AUXLIBS, for example:
|
||||||
|
|
||||||
make -f Makefile.init makefiles \
|
make -f Makefile.init makefiles \
|
||||||
'CCARGS=-DHAS_MYSQL -I/some/where/include/mysql' \
|
'CCARGS=-DHAS_MYSQL -I/usr/local/mysql/include' \
|
||||||
'AUXLIBS=/some/where/lib/mysql/libmysqlclient.a -lm'
|
'AUXLIBS=-L/usr/local/mysql/lib -lmysqlclient -lm'
|
||||||
|
|
||||||
then, just run 'make'.
|
then, just run 'make'.
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
Major changes with snapshot-20001215
|
Major changes with snapshot-20001217
|
||||||
====================================
|
====================================
|
||||||
|
|
||||||
This release involves little change in functionality and a lot of
|
This release involves little change in functionality and a lot of
|
||||||
@@ -10,11 +10,16 @@ suffix to indicate the time unit (s: second, m: minute, h: hour,
|
|||||||
d: day, w: week). The exceptions are the LDAP and MYSQL modules
|
d: day, w: week). The exceptions are the LDAP and MYSQL modules
|
||||||
which are maintained separately.
|
which are maintained separately.
|
||||||
|
|
||||||
|
The mysql client was partially rewritten in order to elimimate some
|
||||||
|
memory allocation/deallocation problems. The code needs more work,
|
||||||
|
and needs to be tested in a real production environment.
|
||||||
|
|
||||||
The local_transport and default_transport configuration parameters
|
The local_transport and default_transport configuration parameters
|
||||||
can now be specified in transport:destination notation, just like
|
can now be specified in transport:destination notation, just like
|
||||||
the mailbox_transport and fallback_transport parameters. The
|
the mailbox_transport and fallback_transport parameters. The
|
||||||
:destination part is optional. This change makes the relayhost
|
:destination part is optional. However, these parameters take only
|
||||||
parameter obsolescent.
|
one destination, unlike relayhost and fallback-relay which take
|
||||||
|
any number of destinations.
|
||||||
|
|
||||||
Incompatible changes with snapshot-20001210
|
Incompatible changes with snapshot-20001210
|
||||||
===========================================
|
===========================================
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* Version of this program.
|
* Version of this program.
|
||||||
*/
|
*/
|
||||||
#define VAR_MAIL_VERSION "mail_version"
|
#define VAR_MAIL_VERSION "mail_version"
|
||||||
#define DEF_MAIL_VERSION "Snapshot-20001216"
|
#define DEF_MAIL_VERSION "Snapshot-20001217"
|
||||||
extern char *var_mail_version;
|
extern char *var_mail_version;
|
||||||
|
|
||||||
/* LICENSE
|
/* LICENSE
|
||||||
|
@@ -89,7 +89,7 @@ extern int dict_errno;
|
|||||||
|
|
||||||
/* need some structs to help organize things */
|
/* need some structs to help organize things */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
MYSQL db;
|
MYSQL *db;
|
||||||
char *hostname;
|
char *hostname;
|
||||||
int stat; /* STATUNTRIED | STATFAIL | STATCUR */
|
int stat; /* STATUNTRIED | STATFAIL | STATCUR */
|
||||||
time_t ts; /* used for attempting reconnection
|
time_t ts; /* used for attempting reconnection
|
||||||
@@ -126,7 +126,7 @@ static MYSQL_RES *plmysql_query(PLMYSQL *, const char *, char *, char *, char *)
|
|||||||
static void plmysql_dealloc(PLMYSQL *);
|
static void plmysql_dealloc(PLMYSQL *);
|
||||||
static void plmysql_down_host(HOST *);
|
static void plmysql_down_host(HOST *);
|
||||||
static void plmysql_connect_single(HOST *, char *, char *, char *);
|
static void plmysql_connect_single(HOST *, char *, char *, char *);
|
||||||
static int plmysql_ready_reconn(HOST);
|
static int plmysql_ready_reconn(HOST *);
|
||||||
static void dict_mysql_update(DICT *, const char *, const char *);
|
static void dict_mysql_update(DICT *, const char *, const char *);
|
||||||
static const char *dict_mysql_lookup(DICT *, const char *);
|
static const char *dict_mysql_lookup(DICT *, const char *);
|
||||||
DICT *dict_mysql_open(const char *, int, int);
|
DICT *dict_mysql_open(const char *, int, int);
|
||||||
@@ -235,13 +235,16 @@ static MYSQL_RES *plmysql_query(PLMYSQL *PLDB,
|
|||||||
|
|
||||||
/* answer already found */
|
/* answer already found */
|
||||||
if (res != 0 && host->stat == STATACTIVE) {
|
if (res != 0 && host->stat == STATACTIVE) {
|
||||||
msg_info("dict_mysql: closing unnessary connection to %s", host->hostname);
|
if (msg_verbose)
|
||||||
mysql_close(&(host->db));
|
msg_info("dict_mysql: closing unnessary connection to %s",
|
||||||
|
host->hostname);
|
||||||
plmysql_down_host(host);
|
plmysql_down_host(host);
|
||||||
}
|
}
|
||||||
/* try to connect for the first time if we don't have a result yet */
|
/* try to connect for the first time if we don't have a result yet */
|
||||||
if (res == 0 && host->stat == STATUNTRIED) {
|
if (res == 0 && host->stat == STATUNTRIED) {
|
||||||
msg_info("dict_mysql: attempting to connect to host %s", host->hostname);
|
if (msg_verbose)
|
||||||
|
msg_info("dict_mysql: attempting to connect to host %s",
|
||||||
|
host->hostname);
|
||||||
plmysql_connect_single(host, dbname, username, password);
|
plmysql_connect_single(host, dbname, username, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -249,8 +252,10 @@ static MYSQL_RES *plmysql_query(PLMYSQL *PLDB,
|
|||||||
* try to reconnect if we don't have an answer and the host had a
|
* try to reconnect if we don't have an answer and the host had a
|
||||||
* prob in the past and it's time for it to reconnect
|
* prob in the past and it's time for it to reconnect
|
||||||
*/
|
*/
|
||||||
if (res == 0 && host->stat == STATFAIL && (plmysql_ready_reconn(*host))) {
|
if (res == 0 && host->stat == STATFAIL && host->ts < time((time_t *) 0)) {
|
||||||
msg_warn("dict_mysql: attempting to reconnect to host %s", host->hostname);
|
if (msg_verbose)
|
||||||
|
msg_info("dict_mysql: attempting to reconnect to host %s",
|
||||||
|
host->hostname);
|
||||||
plmysql_connect_single(host, dbname, username, password);
|
plmysql_connect_single(host, dbname, username, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,16 +264,16 @@ static MYSQL_RES *plmysql_query(PLMYSQL *PLDB,
|
|||||||
* try the query. If the query fails, mark the host STATFAIL
|
* try the query. If the query fails, mark the host STATFAIL
|
||||||
*/
|
*/
|
||||||
if (res == 0 && host->stat == STATACTIVE) {
|
if (res == 0 && host->stat == STATACTIVE) {
|
||||||
if (!(mysql_query(&(host->db), query))) {
|
if (!(mysql_query(host->db, query))) {
|
||||||
if ((res = mysql_store_result(&(host->db))) == 0) {
|
if ((res = mysql_store_result(host->db)) == 0) {
|
||||||
msg_warn("%s", mysql_error(&(host->db)));
|
msg_warn("%s", mysql_error(host->db));
|
||||||
plmysql_down_host(host);
|
plmysql_down_host(host);
|
||||||
} else {
|
} else {
|
||||||
if (msg_verbose)
|
if (msg_verbose)
|
||||||
msg_info("dict_mysql: successful query from host %s", host->hostname);
|
msg_info("dict_mysql: successful query from host %s", host->hostname);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
msg_warn("%s", mysql_error(&(host->db)));
|
msg_warn("%s", mysql_error(host->db));
|
||||||
plmysql_down_host(host);
|
plmysql_down_host(host);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -303,13 +308,15 @@ static void plmysql_connect_single(HOST *host, char *dbname, char *username, cha
|
|||||||
port = ntohs(find_inet_port(service, "tcp"));
|
port = ntohs(find_inet_port(service, "tcp"));
|
||||||
}
|
}
|
||||||
|
|
||||||
host->db = *((MYSQL *) mysql_init(NULL));
|
host->db = mysql_init(NULL);
|
||||||
if (mysql_real_connect(&(host->db), hostname, username, password, dbname, port, unix_socket, 0)) {
|
if (mysql_real_connect(host->db, hostname, username, password, dbname, port, unix_socket, 0)) {
|
||||||
msg_info("dict_mysql: successful connection to host %s", host->hostname);
|
if (msg_verbose)
|
||||||
|
msg_info("dict_mysql: successful connection to host %s",
|
||||||
|
host->hostname);
|
||||||
host->stat = STATACTIVE;
|
host->stat = STATACTIVE;
|
||||||
} else {
|
} else {
|
||||||
|
msg_warn("%s", mysql_error(host->db));
|
||||||
plmysql_down_host(host);
|
plmysql_down_host(host);
|
||||||
msg_warn("%s", mysql_error(&(host->db)));
|
|
||||||
}
|
}
|
||||||
if (hostname)
|
if (hostname)
|
||||||
myfree(hostname);
|
myfree(hostname);
|
||||||
@@ -322,37 +329,11 @@ static void plmysql_connect_single(HOST *host, char *dbname, char *username, cha
|
|||||||
static void plmysql_down_host(HOST *host)
|
static void plmysql_down_host(HOST *host)
|
||||||
{
|
{
|
||||||
if (host->stat != STATFAIL) {
|
if (host->stat != STATFAIL) {
|
||||||
host->ts = time(&(host->ts));
|
host->ts = time((time_t *) 0) + RETRY_CONN_INTV;
|
||||||
host->stat = STATFAIL;
|
host->stat = STATFAIL;
|
||||||
}
|
}
|
||||||
}
|
mysql_close(host->db);
|
||||||
|
host->db = 0;
|
||||||
/*
|
|
||||||
* plmysql_ready_reconn -
|
|
||||||
* given a downed HOST, return whether or not it should retry connection
|
|
||||||
*/
|
|
||||||
static int plmysql_ready_reconn(HOST host)
|
|
||||||
{
|
|
||||||
time_t t;
|
|
||||||
long now;
|
|
||||||
|
|
||||||
now = (long) time(&t);
|
|
||||||
if (msg_verbose > 1) {
|
|
||||||
msg_info("dict_mysql: plmysql_ready_reconn(): now is %d", now);
|
|
||||||
msg_info("dict_mysql: plmysql_ready_reconn(): ts is %d", (long) host.ts);
|
|
||||||
msg_info("dict_mysql: plmysql_ready_reconn(): RETRY_CONN_INTV is %d", RETRY_CONN_INTV);
|
|
||||||
if ((now - ((long) host.ts)) >= RETRY_CONN_INTV) {
|
|
||||||
msg_info("dict_mysql: plymsql_ready_reconn(): returning TRUE");
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
msg_info("dict_mysql: plymsql_ready_reconn(): returning FALSE");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ((now - ((long) host.ts)) >= RETRY_CONN_INTV)
|
|
||||||
return 1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
@@ -372,7 +353,6 @@ DICT *dict_mysql_open(const char *name, int unused_flags, int unused_dict_flag
|
|||||||
dict_mysql->dict.close = dict_mysql_close;
|
dict_mysql->dict.close = dict_mysql_close;
|
||||||
dict_mysql->dict.fd = -1; /* there's no file descriptor
|
dict_mysql->dict.fd = -1; /* there's no file descriptor
|
||||||
* for locking */
|
* for locking */
|
||||||
dict_mysql->name = (MYSQL_NAME *) mymalloc(sizeof(MYSQL_NAME));
|
|
||||||
dict_mysql->name = mysqlname_parse(name);
|
dict_mysql->name = mysqlname_parse(name);
|
||||||
dict_mysql->pldb = plmysql_init(dict_mysql->name->hostnames,
|
dict_mysql->pldb = plmysql_init(dict_mysql->name->hostnames,
|
||||||
dict_mysql->name->len_hosts);
|
dict_mysql->name->len_hosts);
|
||||||
@@ -463,25 +443,23 @@ static MYSQL_NAME *mysqlname_parse(const char *mysqlcf_path)
|
|||||||
else
|
else
|
||||||
hosts = mystrdup(nameval);
|
hosts = mystrdup(nameval);
|
||||||
/* coo argv interface */
|
/* coo argv interface */
|
||||||
hosts_argv = argv_split(hosts, " ");
|
hosts_argv = argv_split(hosts, " ,\t\r\n");
|
||||||
argv_terminate(hosts_argv);
|
|
||||||
|
|
||||||
if (hosts_argv->argc == 0) { /* no hosts specified,
|
if (hosts_argv->argc == 0) { /* no hosts specified,
|
||||||
* default to 'localhost' */
|
* default to 'localhost' */
|
||||||
msg_info("mysqlname_parse(): no hostnames specified, defaulting to 'localhost'");
|
if (msg_verbose)
|
||||||
name->len_hosts = 1;
|
msg_info("mysqlname_parse(): no hostnames specified, defaulting to 'localhost'");
|
||||||
name->hostnames = (char **) mymalloc(sizeof(char *));
|
argv_add(hosts_argv, "localhost", ARGV_END);
|
||||||
name->hostnames[0] = mystrdup("localhost");
|
argv_terminate(hosts_argv);
|
||||||
} else {
|
}
|
||||||
name->len_hosts = hosts_argv->argc;
|
name->len_hosts = hosts_argv->argc;
|
||||||
name->hostnames = (char **) mymalloc((sizeof(char *)) * name->len_hosts);
|
name->hostnames = (char **) mymalloc((sizeof(char *)) * name->len_hosts);
|
||||||
i = 0;
|
i = 0;
|
||||||
for (i = 0; hosts_argv->argv[i] != NULL; i++) {
|
for (i = 0; hosts_argv->argv[i] != NULL; i++) {
|
||||||
name->hostnames[i] = mystrdup(hosts_argv->argv[i]);
|
name->hostnames[i] = mystrdup(hosts_argv->argv[i]);
|
||||||
if (msg_verbose)
|
if (msg_verbose)
|
||||||
msg_info("mysqlname_parse(): adding host '%s' to list of mysql server hosts",
|
msg_info("mysqlname_parse(): adding host '%s' to list of mysql server hosts",
|
||||||
name->hostnames[i]);
|
name->hostnames[i]);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
myfree(hosts);
|
myfree(hosts);
|
||||||
vstring_free(opt_dict_name);
|
vstring_free(opt_dict_name);
|
||||||
@@ -494,8 +472,7 @@ static MYSQL_NAME *mysqlname_parse(const char *mysqlcf_path)
|
|||||||
* plmysql_init - initalize a MYSQL database.
|
* plmysql_init - initalize a MYSQL database.
|
||||||
* Return NULL on failure, or a PLMYSQL * on success.
|
* Return NULL on failure, or a PLMYSQL * on success.
|
||||||
*/
|
*/
|
||||||
static PLMYSQL *plmysql_init(char *hostnames[],
|
static PLMYSQL *plmysql_init(char *hostnames[], int len_hosts)
|
||||||
int len_hosts)
|
|
||||||
{
|
{
|
||||||
PLMYSQL *PLDB;
|
PLMYSQL *PLDB;
|
||||||
MYSQL *dbs;
|
MYSQL *dbs;
|
||||||
@@ -518,15 +495,12 @@ static PLMYSQL *plmysql_init(char *hostnames[],
|
|||||||
/* host_init - initialize HOST structure */
|
/* host_init - initialize HOST structure */
|
||||||
static HOST host_init(char *hostname)
|
static HOST host_init(char *hostname)
|
||||||
{
|
{
|
||||||
int stat;
|
|
||||||
MYSQL db;
|
|
||||||
time_t ts;
|
|
||||||
HOST host;
|
HOST host;
|
||||||
|
|
||||||
host.stat = STATUNTRIED;
|
host.stat = STATUNTRIED;
|
||||||
host.hostname = hostname;
|
host.hostname = mystrdup(hostname);
|
||||||
host.db = db;
|
host.db = 0;
|
||||||
host.ts = ts;
|
host.ts = 0;
|
||||||
return host;
|
return host;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -550,6 +524,7 @@ static void dict_mysql_close(DICT *dict)
|
|||||||
for (i = 0; i < dict_mysql->name->len_hosts; i++) {
|
for (i = 0; i < dict_mysql->name->len_hosts; i++) {
|
||||||
myfree(dict_mysql->name->hostnames[i]);
|
myfree(dict_mysql->name->hostnames[i]);
|
||||||
}
|
}
|
||||||
|
myfree((char *) dict_mysql->name->hostnames);
|
||||||
myfree((char *) dict_mysql->name);
|
myfree((char *) dict_mysql->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -559,7 +534,8 @@ static void plmysql_dealloc(PLMYSQL *PLDB)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < PLDB->len_hosts; i++) {
|
for (i = 0; i < PLDB->len_hosts; i++) {
|
||||||
mysql_close(&(PLDB->db_hosts[i].db));
|
if (PLDB->db_hosts[i].db)
|
||||||
|
mysql_close(PLDB->db_hosts[i].db);
|
||||||
myfree(PLDB->db_hosts[i].hostname);
|
myfree(PLDB->db_hosts[i].hostname);
|
||||||
}
|
}
|
||||||
myfree((char *) PLDB->db_hosts);
|
myfree((char *) PLDB->db_hosts);
|
||||||
|
Reference in New Issue
Block a user