Date: Mon, 9 Mar 2026 19:38:08 -0400 (EDT)
Subject: PATCH: fix for bad alias_maps and null pointer at postfix startup
From: Wietse Venema via Postfix-devel <postfix-devel@postfix.org>
Origin: upstream, https://marc.info/?l=postfix-devel&m=177310221511516&w=2
Forwarded: not-needed

Michael Tokarev found a few mistakes in very recent Postfix code.
These caused various startup failures depending on Postfix configuration.

This patch includes a patch that Micahel sent earlier tody, that had
suffered from line wrapping damage.

It's been a long day, so I will roll out releases on Tuesday.

	Wietse

diff '--exclude=man' '--exclude=html' '--exclude=README_FILES' '--exclude=INSTALL' --no-dereference -r -ur /var/tmp/postfix-3.12-20260305/HISTORY ./HISTORY
--- /var/tmp/postfix-3.12-20260305/HISTORY	2026-03-05 10:18:00.000000000 -0500
+++ ./HISTORY	2026-03-09 19:25:41.607868948 -0400
@@ -30583,3 +30583,18 @@
 	master_service_disable=inet" + "postfix start" step, to
 	locate settings that still need to be updated. File:
 	proto/NON_BERKELEYDB_README.html.
+
+20260309
+
+	Bugfix (defect introduced: 20260219): alias_maps errors
+	when default_database_type was not set in main.cf, or when
+	it was set later than alias_maps. Fix by Michael Tokarev.
+	File: global/mail_params.c.
+
+	Bugfix (defect introduced: 20260219): null pointer in
+	nbdb_reindexd(8) because the "service_name" value was not
+	propagated. Report by Michael Tokarev, fix by Wietse. Files:
+	global/mail_params.c, global/mail_params.h
+
+	Bugfix (defect introduced: 20260219): spurious error message
+	from nbdb_reindexd(8). File: conf/postfix-script.
diff '--exclude=man' '--exclude=html' '--exclude=README_FILES' '--exclude=INSTALL' --no-dereference -r -ur /var/tmp/postfix-3.12-20260305/conf/postfix-script ./conf/postfix-script
--- /var/tmp/postfix-3.12-20260305/conf/postfix-script	2026-02-26 16:17:35.000000000 -0500
+++ ./conf/postfix-script	2026-03-09 18:33:21.050354980 -0400
@@ -311,6 +311,7 @@
 	# 
 	# To avoid this, craft a one-time stand-alone re-indexing request.
 	test -f $config_directory/check-alias-maps-migration-done && exit 0
+	test "x`$command_directory/postconf -h non_bdb_migration_level`" = xenable-reindex || exit 0
 	BACKUP_IFS="$IFS"
 	for map	in `$command_directory/postconf -hx alias_maps`
 	do
diff '--exclude=man' '--exclude=html' '--exclude=README_FILES' '--exclude=INSTALL' --no-dereference -r -ur /var/tmp/postfix-3.12-20260305/src/global/mail_params.c ./src/global/mail_params.c
--- /var/tmp/postfix-3.12-20260305/src/global/mail_params.c	2026-03-02 15:28:43.000000000 -0500
+++ ./src/global/mail_params.c	2026-03-09 18:54:54.043833321 -0400
@@ -797,6 +797,7 @@
 	VAR_POSTLOG_SERVICE, DEF_POSTLOG_SERVICE, &var_postlog_service, 1, 0,
 	VAR_DNSSEC_PROBE, DEF_DNSSEC_PROBE, &var_dnssec_probe, 0, 0,
 	VAR_KNOWN_TCP_PORTS, DEF_KNOWN_TCP_PORTS, &var_known_tcp_ports, 0, 0,
+	VAR_SERVNAME, DEF_SERVNAME, &var_servname, 0, 0,
 	0,
     };
     static const CONFIG_BOOL_TABLE first_bool_defaults[] = {
@@ -839,10 +840,10 @@
 	VAR_PROXY_INTERFACES, DEF_PROXY_INTERFACES, &var_proxy_interfaces, 0, 0,
 	VAR_DOUBLE_BOUNCE, DEF_DOUBLE_BOUNCE, &var_double_bounce_sender, 1, 0,
 	VAR_DEFAULT_PRIVS, DEF_DEFAULT_PRIVS, &var_default_privs, 1, 0,
-	VAR_ALIAS_DB_MAP, DEF_ALIAS_DB_MAP, &var_alias_db_map, 0, 0,
 	VAR_MAIL_RELEASE, DEF_MAIL_RELEASE, &var_mail_release, 1, 0,
 	VAR_DB_TYPE, DEF_DB_TYPE, &var_db_type, 1, 0,
 	VAR_CACHE_DB_TYPE, DEF_CACHE_DB_TYPE, &var_cache_db_type, 1, 0,
+	VAR_ALIAS_DB_MAP, DEF_ALIAS_DB_MAP, &var_alias_db_map, 0, 0,
 	VAR_HASH_QUEUE_NAMES, DEF_HASH_QUEUE_NAMES, &var_hash_queue_names, 1, 0,
 	VAR_RCPT_DELIM, DEF_RCPT_DELIM, &var_rcpt_delim, 0, 0,
 	VAR_RELAY_DOMAINS, DEF_RELAY_DOMAINS, &var_relay_domains, 0, 0,
diff '--exclude=man' '--exclude=html' '--exclude=README_FILES' '--exclude=INSTALL' --no-dereference -r -ur /var/tmp/postfix-3.12-20260305/src/global/mail_params.h ./src/global/mail_params.h
--- /var/tmp/postfix-3.12-20260305/src/global/mail_params.h	2026-03-02 15:28:43.000000000 -0500
+++ ./src/global/mail_params.h	2026-03-09 19:13:44.864611006 -0400
@@ -2636,6 +2636,7 @@
 extern char *var_procname;
 
 #define VAR_SERVNAME		"service_name"
+#define DEF_SERVNAME		"amnesiac"
 extern char *var_servname;
 
 #define VAR_PID			"process_id"
