Cleanup: factored out the non-cryptographic seeder. Files:
ldseed.[hc].
+
+20220130
+
+ Cleanup: added a binhash unit test, and updated the htable
+ unit test. Files: util/Makefile.in, util/binhash.[hc],
+ util/htable.c.
+
+ Cleanup: names of hash_fnv(3) build options. File: hash:fnv.c.
+
+20220202
+
+ Bitrot: Berkeley DB 18 is like Berkeley DB 6. Yasuhiro
+ Kimura. File: util/dict_db.c.
[Feature 20210815] To make the maillog_file feature more useful,
the postlog(1) command is now set-gid postdrop, so that unprivileged
-programs can write logging through the postlogd(8) daemon. This
-required hardening the postlog(1) command against privilege escalation
-attacks. DO NOT turn on the set-gid bit with older postlog(1)
-implementations.
+programs can use it to write logging through the postlogd(8) daemon.
+This required hardening the postlog(1) command against privilege
+escalation attacks. DO NOT turn on the set-gid bit with older
+postlog(1) implementations.
Major changes - pcre2 support
-----------------------------
Visible differences: some error messages may have a different text,
and the 'X' pattern flag is no longer supported with pcre2.
-Major changes - safety
-----------------------
-
-[Feature 20210926] Prevent sharing of xxx_tls_session_cache_database
-instances between different Postfix instances when a database is
-not multi-writer safe. These databases are now opened with a permanent
-lock. The tlsmgr(8) daemon will raise a fatal error when it attempts
-to open an xxx_tls_session_cache_database that is already opened
-by a different tlsmgr(8) process.
-
Major changes - security
------------------------
Disable -DSNAPSHOT and -DNONPROD in makedefs.
+ Alias htable(3) calls to equivalent binhash(3) calls,
+ and obsolete the htable(3) module.
+
FILTER_README needs some text on multi-instance implementations,
and existing multi-instance references need to be updated.
Fatal error error opening existing file
XXX XXX
int compar DNS_RR DNS_RR
-NO_64_BITS NO_64_BITS
+USE_FNV_32BIT USE_FNV_32BIT
softwareengineering
stackexchange
stdint
+Noll
* Patches change both the patchlevel and the release date. Snapshots have no
* patchlevel; they change the release date only.
*/
-#define MAIL_RELEASE_DATE "20220129"
+#define MAIL_RELEASE_DATE "20220204"
#define MAIL_VERSION_NUMBER "3.8"
#ifdef SNAPSHOT
PCF_MASTER_ENT *local_scope)
{
const char *myname = "pcf_expand_parameter_value";
- static VSTRING *local_buf;
int status;
PCF_EVAL_CTX eval_ctx;
config_directory = .
-./postconf: warning: ./main.cf: unused parameter: foo=yes
./postconf: warning: ./main.cf: unused parameter: restriction_classes=foo bar
+./postconf: warning: ./main.cf: unused parameter: foo=yes
yy = aap
zz = $yy
./postconf: warning: ./main.cf: unused parameter: foo_domain=bar
-./postconf: warning: ./main.cf: unused parameter: aa_domain=whatever
./postconf: warning: ./main.cf: unused parameter: xx=proxy:ldap:foo
+./postconf: warning: ./main.cf: unused parameter: aa_domain=whatever
config_directory = .
+./postconf: warning: ./main.cf: unused parameter: pgsqlfoo_domain=bar
./postconf: warning: ./main.cf: unused parameter: sqlitefoo_domain=bar
-./postconf: warning: ./main.cf: unused parameter: mysqlfoo_domain=bar
+./postconf: warning: ./main.cf: unused parameter: ldapxx=proxy:ldap:ldapfoo
./postconf: warning: ./main.cf: unused parameter: sqlitexx=proxy:sqlite:sqlitefoo
-./postconf: warning: ./main.cf: unused parameter: pgsqlxx=proxy:pgsql:pgsqlfoo
+./postconf: warning: ./main.cf: unused parameter: mysqlfoo_domain=bar
+./postconf: warning: ./main.cf: unused parameter: sqlitefoo_domainx=bar
+./postconf: warning: ./main.cf: unused parameter: memcachefoo_domain=bar
./postconf: warning: ./main.cf: unused parameter: pgsqlfoo_domainx=bar
-./postconf: warning: ./main.cf: unused parameter: memcachexx=proxy:memcache:memcachefoo
./postconf: warning: ./main.cf: unused parameter: ldapfoo_domainx=bar
./postconf: warning: ./main.cf: unused parameter: ldapfoo_domain=bar
+./postconf: warning: ./main.cf: unused parameter: memcachexx=proxy:memcache:memcachefoo
./postconf: warning: ./main.cf: unused parameter: memcachefoo_domainx=bar
-./postconf: warning: ./main.cf: unused parameter: sqlitefoo_domainx=bar
-./postconf: warning: ./main.cf: unused parameter: ldapxx=proxy:ldap:ldapfoo
-./postconf: warning: ./main.cf: unused parameter: memcachefoo_domain=bar
-./postconf: warning: ./main.cf: unused parameter: mysqlxx=proxy:mysql:mysqlfoo
./postconf: warning: ./main.cf: unused parameter: mysqlfoo_domainx=bar
-./postconf: warning: ./main.cf: unused parameter: pgsqlfoo_domain=bar
+./postconf: warning: ./main.cf: unused parameter: mysqlxx=proxy:mysql:mysqlfoo
+./postconf: warning: ./main.cf: unused parameter: pgsqlxx=proxy:pgsql:pgsqlfoo
-./postconf: warning: ./main.cf: read-only parameter assignment: process_id=yyy
./postconf: warning: ./main.cf: read-only parameter assignment: process_name=xxx
+./postconf: warning: ./main.cf: read-only parameter assignment: process_id=yyy
mydestination = whatever
process_name = postconf
-./postconf: warning: ./master.cf: read-only parameter assignment: process_id=bbb
./postconf: warning: ./master.cf: read-only parameter assignment: process_name=aaa
+./postconf: warning: ./master.cf: read-only parameter assignment: process_id=bbb
process_name = postconf
-o xxx=yyy
-o aaa=bbb
baz unix - n n - 0 other
-./postconf: warning: ./master.cf: unused parameter: xxx=yyy
./postconf: warning: ./master.cf: unused parameter: aaa=bbb
+./postconf: warning: ./master.cf: unused parameter: xxx=yyy
foo unix - n n - 0 other
bar unix - n n - 0 other
-o xxx=YYY
-o aaa=BBB
baz unix - n n - 0 other
-./postconf: warning: ./master.cf: unused parameter: xxx=YYY
./postconf: warning: ./master.cf: unused parameter: aaa=BBB
+./postconf: warning: ./master.cf: unused parameter: xxx=YYY
bar/unix/aaa = BBB
bar/unix/xxx = YYY
-./postconf: warning: ./master.cf: unused parameter: xxx=YYY
./postconf: warning: ./master.cf: unused parameter: aaa=BBB
+./postconf: warning: ./master.cf: unused parameter: xxx=YYY
-o xxx=yyy
-o aaa=bbb
baz unix - n n - 0 other
-./postconf: warning: ./master.cf: unused parameter: xxx=yyy
./postconf: warning: ./master.cf: unused parameter: aaa=bbb
+./postconf: warning: ./master.cf: unused parameter: xxx=yyy
bar/unix/aaa = bbb
bar/unix/xxx = yyy
-./postconf: warning: ./master.cf: unused parameter: xxx=yyy
./postconf: warning: ./master.cf: unused parameter: aaa=bbb
+./postconf: warning: ./master.cf: unused parameter: xxx=yyy
foo unix - n n - 0 other
bar unix - n n - 0 other
baz unix - n n - 0 other
t1 = Postfix 2.11 compatible
x = x-value
y = y-value
-./postconf: warning: ./main.cf: unused parameter: foo=$bar$baz
./postconf: warning: ./main.cf: unused parameter: t2=$t1
+./postconf: warning: ./main.cf: unused parameter: foo=$bar$baz
-o {name2=value2a value2b}
arg1a arg1b {arg2a arg2b} {arg3a arg3b}
baz unix - n n 0 0 other
-./postconf: warning: ./master.cf: unused parameter: name1=value1
./postconf: warning: ./master.cf: unused parameter: name2=value2a value2b
+./postconf: warning: ./master.cf: unused parameter: name1=value1
-o test2_service_name=smtp
./postconf: warning: ./master.cf: unused parameter: test1_service_name=$service_name
./postconf: warning: ./master.cf: unused parameter: test1_process_name=$process_name
-./postconf: warning: ./master.cf: unused parameter: test2_process_name=$process_name
./postconf: warning: ./master.cf: unused parameter: test2_service_name=$service_name
+./postconf: warning: ./master.cf: unused parameter: test2_process_name=$process_name
valid_utf8_string ip_match base32_code msg_rate_delay netstring \
vstream timecmp dict_cache midna_domain casefold strcasecmp_utf8 \
vbuf_print split_qnameval vstream msg_logger byte_mask \
- known_tcp_ports dict_stream find_inet
+ known_tcp_ports dict_stream find_inet binhash
PLUGIN_MAP_SO = $(LIB_PREFIX)pcre$(LIB_SUFFIX)
HTABLE_FIX = NORANDOMIZE=1
LIB_DIR = ../../lib
$(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(SYSLIBS)
mv junk $@.o
+binhash: $(LIB)
+ mv $@.o junk
+ $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(SYSLIBS)
+ mv junk $@.o
+
unix_recv_fd: $(LIB)
mv $@.o junk
$(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(SYSLIBS)
dict_static_file_test dict_random_test dict_random_file_test \
dict_inline_file_test byte_mask_tests mystrtok_test \
known_tcp_ports_test dict_stream_test dict_inline_regexp_test \
- dict_inline_cidr_test
+ dict_inline_cidr_test binhash_test
dict_pcre_tests: dict_pcre_test miss_endif_pcre_test dict_pcre_file_test \
dict_inline_pcre_test
htable_test: htable /usr/share/dict/words
$(SHLIB_ENV) ${VALGRIND} ./htable < /usr/share/dict/words
+binhash_test: binhash /usr/share/dict/words
+ $(SHLIB_ENV) ${VALGRIND} ./binhash < /usr/share/dict/words
+
hex_code_test: hex_code
$(SHLIB_ENV) ${VALGRIND} ./hex_code
basename.o: vstring.h
binhash.o: binhash.c
binhash.o: binhash.h
+binhash.o: hash_fnv.h
binhash.o: msg.h
binhash.o: mymalloc.h
binhash.o: sys_defs.h
known_tcp_ports.o: vstring.h
ldseed.o: iostuff.h
ldseed.o: ldseed.c
+ldseed.o: ldseed.h
ldseed.o: msg.h
ldseed.o: sys_defs.h
line_number.o: check_arg.h
stream_trigger.o: stream_trigger.c
stream_trigger.o: sys_defs.h
stream_trigger.o: trigger.h
-sys_compat.o: iostuff.h
sys_compat.o: sys_compat.c
sys_compat.o: sys_defs.h
timecmp.o: timecmp.c
/*
/* BINHASH_INFO **binhash_list(table)
/* BINHASH *table;
+/*
+/* BINHASH_INFO *binhash_sequence(table, how)
+/* BINHASH *table;
+/* int how;
/* DESCRIPTION
/* This module maintains one or more hash tables. Each table entry
/* consists of a unique binary-valued lookup key and a generic
/* binhash_list() returns a null-terminated list of pointers to
/* all elements in the named table. The list should be passed to
/* myfree().
+/*
+/* binhash_sequence() returns the first or next element
+/* depending on the value of the "how" argument. Specify
+/* BINHASH_SEQ_FIRST to start a new sequence, BINHASH_SEQ_NEXT
+/* to continue, and BINHASH_SEQ_STOP to terminate a sequence
+/* early. The caller must not delete an element before it is
+/* visited.
/* RESTRICTIONS
/* A callback function should not modify the hash table that is
/* specified to its caller.
/* to delete a non-existent entry.
/* SEE ALSO
/* mymalloc(3) memory management wrapper
+/* hash_fnv(3) Fowler/Noll/Vo hash function
/* LICENSE
/* .ad
/* .fi
/* IBM T.J. Watson Research
/* P.O. Box 704
/* Yorktown Heights, NY 10598, USA
+/*
+/* Wietse Venema
+/* Google, Inc.
+/* 111 8th Avenue
+/* New York, NY 10011, USA
/*--*/
/* C library */
/* binhash_hash - hash a string */
+#ifndef NO_HASH_FNV
+#include "hash_fnv.h"
+
+#define binhash_hash(key, len, size) (hash_fnv((key), (len)) % (size))
+
+#else
+
static size_t binhash_hash(const void *key, ssize_t len, size_t size)
{
size_t h = 0;
return (h % size);
}
+#endif
+
/* binhash_link - insert element into table */
#define binhash_link(table, elm) { \
table = (BINHASH *) mymalloc(sizeof(BINHASH));
binhash_size(table, size < 13 ? 13 : size);
+ table->seq_bucket = table->seq_element = 0;
return (table);
}
}
myfree((void *) table->data);
table->data = 0;
+ if (table->seq_bucket)
+ myfree((void *) table->seq_bucket);
+ table->seq_bucket = 0;
myfree((void *) table);
}
}
list[count] = 0;
return (list);
}
+
+/* binhash_sequence - dict(3) compatibility iterator */
+
+BINHASH_INFO *binhash_sequence(BINHASH *table, int how)
+{
+ if (table == 0)
+ return (0);
+
+ switch (how) {
+ case BINHASH_SEQ_FIRST: /* start new sequence */
+ if (table->seq_bucket)
+ myfree((void *) table->seq_bucket);
+ table->seq_bucket = binhash_list(table);
+ table->seq_element = table->seq_bucket;
+ return (*(table->seq_element)++);
+ case BINHASH_SEQ_NEXT: /* next element */
+ if (table->seq_element && *table->seq_element)
+ return (*(table->seq_element)++);
+ /* FALLTHROUGH */
+ default: /* terminate sequence */
+ if (table->seq_bucket) {
+ myfree((void *) table->seq_bucket);
+ table->seq_bucket = table->seq_element = 0;
+ }
+ return (0);
+ }
+}
+
+#ifdef TEST
+#include <vstring_vstream.h>
+#include <myrand.h>
+
+int main(int unused_argc, char **unused_argv)
+{
+ VSTRING *buf = vstring_alloc(10);
+ ssize_t count = 0;
+ BINHASH *hash;
+ BINHASH_INFO **ht_info;
+ BINHASH_INFO **ht;
+ BINHASH_INFO *info;
+ ssize_t i;
+ ssize_t r;
+ int op;
+
+ /*
+ * Load a large number of strings including terminator, and delete them
+ * in a random order.
+ */
+ hash = binhash_create(10);
+ while (vstring_get(buf, VSTREAM_IN) != VSTREAM_EOF)
+ binhash_enter(hash, vstring_str(buf), VSTRING_LEN(buf) + 1,
+ CAST_INT_TO_VOID_PTR(count++));
+ if (count != hash->used)
+ msg_panic("%ld entries stored, but %lu entries exist",
+ (long) count, (unsigned long) hash->used);
+ for (i = 0, op = BINHASH_SEQ_FIRST; (info = binhash_sequence(hash, op)) != 0;
+ i++, op = BINHASH_SEQ_NEXT)
+ if (memchr(info->key, 0, info->key_len) == 0)
+ msg_panic("no null byte in lookup key");
+ if (i != hash->used)
+ msg_panic("%ld entries found, but %lu entries exist",
+ (long) i, (unsigned long) hash->used);
+ ht_info = binhash_list(hash);
+ for (i = 0; i < hash->used; i++) {
+ r = myrand() % hash->used;
+ info = ht_info[i];
+ ht_info[i] = ht_info[r];
+ ht_info[r] = info;
+ }
+ for (ht = ht_info; *ht; ht++)
+ binhash_delete(hash, ht[0]->key, ht[0]->key_len, (void (*) (void *)) 0);
+ if (hash->used > 0)
+ msg_panic("%ld entries not deleted", (long) hash->used);
+ myfree((void *) ht_info);
+ binhash_free(hash, (void (*) (void *)) 0);
+ vstring_free(buf);
+ return (0);
+}
+
+#endif
ssize_t size; /* length of entries array */
ssize_t used; /* number of entries in table */
BINHASH_INFO **data; /* entries array, auto-resized */
+ BINHASH_INFO **seq_bucket; /* current sequence hash bucket */
+ BINHASH_INFO **seq_element; /* current sequence element */
} BINHASH;
extern BINHASH *binhash_create(ssize_t);
extern void binhash_free(BINHASH *, void (*) (void *));
extern void binhash_walk(BINHASH *, void (*) (BINHASH_INFO *, void *), void *);
extern BINHASH_INFO **binhash_list(BINHASH *);
+extern BINHASH_INFO *binhash_sequence(BINHASH *, int);
+
+#define BINHASH_SEQ_FIRST 0
+#define BINHASH_SEQ_NEXT 1
+#define BINHASH_SEQ_STOP (-1)
/* LICENSE
/* .ad
if (type == DB_HASH && db->set_h_nelem(db, DICT_DB_NELM) != 0)
msg_fatal("set DB hash element count %d: %m", DICT_DB_NELM);
db_base_buf = vstring_alloc(100);
-#if DB_VERSION_MAJOR == 6 || DB_VERSION_MAJOR == 5 || \
+#if DB_VERSION_MAJOR == 18 || DB_VERSION_MAJOR == 6 || DB_VERSION_MAJOR == 5 || \
(DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR > 0)
if ((errno = db->open(db, 0, sane_basename(db_base_buf, db_path),
0, type, db_flags, 0644)) != 0)
/* get the standard behavior.
/*
/* The default HASH_FNV_T result type is uint64_t. When compiled
-/* with -DNO_64_BITS, the result type is uint32_t. On ancient
+/* with -DUSE_FNV_32BIT, the result type is uint32_t. On ancient
/* systems without <stdint.h>, define HASH_FNV_T on the compiler
-/* command line as an unsigned 32-bit or 64-bit integer type.
+/* command line as an unsigned 32-bit or 64-bit integer type,
+/* and specify -DUSE_FNV_32BIT when HASH_FNV_T is a 32-bit type.
/* SEE ALSO
/* http://www.isthe.com/chongo/tech/comp/fnv/index.html
/* https://softwareengineering.stackexchange.com/questions/49550/
/*
* Application-specific.
*/
-#ifdef NO_64_BITS
+#ifdef USE_FNV_32BIT
#define FNV_prime 0x01000193UL
#define FNV_offset_basis 0x811c9dc5UL
#else
*/
#ifndef HASH_FNV_T
#include <stdint.h>
-#ifdef NO_64_BITS
+#ifdef USE_FNV_32BIT
#define HASH_FNV_T uint32_t
-#else /* NO_64_BITS */
+#else /* USE_FNV_32BIT */
#define HASH_FNV_T uint64_t
-#endif /* NO_64_BITS */
+#endif /* USE_FNV_32BIT */
#endif /* HASH_FNV_T */
extern HASH_FNV_T hash_fnv(const void *, size_t);
/* to delete a non-existent entry.
/* SEE ALSO
/* mymalloc(3) memory management wrapper
+/* hash_fnv(3) Fowler/Noll/Vo hash function
/* LICENSE
/* .ad
/* .fi
hash = htable_create(10);
while (vstring_get(buf, VSTREAM_IN) != VSTREAM_EOF)
htable_enter(hash, vstring_str(buf), CAST_INT_TO_VOID_PTR(count++));
+ if (count != hash->used)
+ msg_panic("%ld entries stored, but %lu entries exist",
+ (long) count, (unsigned long) hash->used);
for (i = 0, op = HTABLE_SEQ_FIRST; htable_sequence(hash, op) != 0;
i++, op = HTABLE_SEQ_NEXT)
/* void */ ;
*/
#include <iostuff.h>
#include <msg.h>
+#include <ldseed.h>
/*
* Different systems have different names for non-wallclock time.