diff --git a/postfix/HISTORY b/postfix/HISTORY
index ef70ad097..e248fed1a 100644
--- a/postfix/HISTORY
+++ b/postfix/HISTORY
@@ -2993,5 +2993,18 @@ Apologies for any names omitted.
that rejects destinations not in $relay_domains. By Lamont
Jones of Hewlett-Packard. File: smtpd/smtpd_check.c.
- Robustness: postconf now validates the syntax of all main.cf
- parameters.
+ Security: do not allow weird characters in the expansion
+ of $names that appear in $forward_path. Just like with
+ shell commands, replace bad characters in expansions by
+ underscores. Configuration parameter: forward_expansion_filter.
+
+19990902
+
+ Documentation: added a sample postfix alias to the examples
+ in the INSTALL document and in the conf/aliases file.
+ Reminded by Simon J. Mudd @ alltrading.com.
+
+19990903
+
+ Bugfix: in case of some error conditions the pickup daemon
+ could leak small amounts of memory.
diff --git a/postfix/INSTALL b/postfix/INSTALL
index 9eabab10e..f69202c9c 100644
--- a/postfix/INSTALL
+++ b/postfix/INSTALL
@@ -389,6 +389,10 @@ like this:
postfix:*:12345:12345:postfix:/no/where:/no/shell
+And there is a corresponding alias in /etc/aliases:
+
+ postfix: root
+
Secondly, you must specify what domain will be appended to a
local address. The "myorigin" parameter defaults to the local
hostname, but that is probably OK only for very small sites.
diff --git a/postfix/Makefile.in b/postfix/Makefile.in
index 008a183c2..af3c9ba81 100644
--- a/postfix/Makefile.in
+++ b/postfix/Makefile.in
@@ -20,6 +20,8 @@ update printfck:
(set -e; echo "[$$i]"; cd $$i; $(MAKE) $(OPTS) $@) || exit 1; \
done
+printfck: update
+
depend clean:
set -e; for i in $(DIRS); do \
(set -e; echo "[$$i]"; cd $$i; $(MAKE) $@) || exit 1; \
diff --git a/postfix/conf/aliases b/postfix/conf/aliases
index a372b1655..9e2edc344 100644
--- a/postfix/conf/aliases
+++ b/postfix/conf/aliases
@@ -16,6 +16,7 @@ nobody: root
uucp: root
www: root
ftp-bugs: root
+postfix: root
# Put your local aliases here.
diff --git a/postfix/conf/main.cf b/postfix/conf/main.cf
index 9c0e5ddcc..b686c373a 100644
--- a/postfix/conf/main.cf
+++ b/postfix/conf/main.cf
@@ -290,7 +290,7 @@ program_directory = /some/where/postfix/bin
# is built-in. Specify "/^header-name: stuff you do not want/ REJECT"
# in the pattern file. Patterns are case-insensitive by default. Note:
# specify only patterns ending in REJECT. Patterns ending in OK are
-# a waste of cycles.
+# mostly a waste of cycles.
#
#header_checks = regexp:/etc/postfix/filename
#header_checks = pcre:/etc/postfix/filename
diff --git a/postfix/conf/sample-smtpd.cf b/postfix/conf/sample-smtpd.cf
index 4381939fb..99323fe9d 100644
--- a/postfix/conf/sample-smtpd.cf
+++ b/postfix/conf/sample-smtpd.cf
@@ -169,8 +169,8 @@ smtpd_helo_restrictions =
# Specify a list of restrictions, separated by commas and/or whitespace.
# Continue long lines by starting the next line with whitespace.
#
-# smtpd_sender_restrictions = reject_unknown_address
-# smtpd_sender_restrictions = reject_unknown_address, hash:/etc/postfix/access
+# smtpd_sender_restrictions = reject_unknown_sender_domain
+# smtpd_sender_restrictions = reject_unknown_sender_domain, hash:/etc/postfix/access
smtpd_sender_restrictions =
# The smtpd_recipient_restrictions parameter specifies restrictions on
@@ -289,7 +289,8 @@ reject_code = 550
relay_domains_reject_code = 550
# The unknown_address_reject_code parameter specifies the SMTP server
-# response when a client violates the reject_unknown_address restriction.
+# response when a client violates the reject_unknown_sender_domain
+# or reject_unknown_recipient_domain restrictions.
#
# Do not change this unless you have a complete understanding of RFC 822.
#
diff --git a/postfix/global/mail_params.h b/postfix/global/mail_params.h
index cec982f92..876f82e32 100644
--- a/postfix/global/mail_params.h
+++ b/postfix/global/mail_params.h
@@ -343,7 +343,7 @@ ABCDEFGHIJKLMNOPQRSTUVWXYZ"
extern char *var_cmd_exp_filter;
#define VAR_FWD_EXP_FILTER "forward_expansion_filter"
-#define DEF_FWD_EXP_FILTER "1234567890!@%-_=+:,.\
+#define DEF_FWD_EXP_FILTER "1234567890!@%-_=+:,./\
abcdefghijklmnopqrstuvwxyz\
ABCDEFGHIJKLMNOPQRSTUVWXYZ"
extern char *var_fwd_exp_filter;
diff --git a/postfix/global/mail_version.h b/postfix/global/mail_version.h
index f2d3dfc06..0af7f54fc 100644
--- a/postfix/global/mail_version.h
+++ b/postfix/global/mail_version.h
@@ -15,7 +15,7 @@
* Version of this program.
*/
#define VAR_MAIL_VERSION "mail_version"
-#define DEF_MAIL_VERSION "Snapshot-19990831"
+#define DEF_MAIL_VERSION "Snapshot-19990904"
extern char *var_mail_version;
/* LICENSE
diff --git a/postfix/html/faq.html b/postfix/html/faq.html
index cd2f6d58d..634c56079 100644
--- a/postfix/html/faq.html
+++ b/postfix/html/faq.html
@@ -327,8 +327,8 @@ that are disconnected most of the time)
When you disable DNS lookups, you must specify the
relayhost as either a numeric IP address, or as a hostname
-that resolves to one or more IP addresses (Postfix does no
-MX lookup).
+that resolves to one or more IP addresses (with DNS lookup disabled,
+Postfix does no MX lookup).
diff --git a/postfix/html/uce.html b/postfix/html/uce.html
index 42a5ddbb1..a35d91f3b 100644
--- a/postfix/html/uce.html
+++ b/postfix/html/uce.html
@@ -103,9 +103,14 @@ is allowed in message headers.
Syntax:
-Specify a list of zero or more lookup tables. Whenever a
-header matches a table, a REJECT result means reject the
-message; an OK result means pass.
+Specify a list of zero or more lookup tables. Whenever a header
+matches a table, a REJECT result means reject the message.
+
+
+
+A rule ending in OK affects only the header being matched. The
+next header may still result in a REJECT match, causing the mail
+still to be rejected.
@@ -797,7 +802,7 @@ subdomain under any of the domains listed in $maps_rbl_domains.
relay_domains
This parameter controls the behavior of the check_relay_domains and a
+href="#check_relay_domains"> check_relay_domains and reject_unauth_destination
restrictions that can appear as part of a recipient address
restriction list.
diff --git a/postfix/include/argv.h b/postfix/include/argv.h
new file mode 100644
index 000000000..0d5562310
--- /dev/null
+++ b/postfix/include/argv.h
@@ -0,0 +1,44 @@
+#ifndef _ARGV_H_INCLUDED_
+#define _ARGV_H_INCLUDED_
+
+/*++
+/* NAME
+/* argv 3h
+/* SUMMARY
+/* string array utilities
+/* SYNOPSIS
+/* #include "argv.h"
+ DESCRIPTION
+ .nf
+
+ /*
+ * External interface.
+ */
+typedef struct ARGV {
+ int len; /* number of array elements */
+ int argc; /* array elements in use */
+ char **argv; /* string array */
+} ARGV;
+
+extern ARGV *argv_alloc(int);
+extern void argv_add(ARGV *,...);
+extern void argv_terminate(ARGV *);
+extern ARGV *argv_free(ARGV *);
+
+extern ARGV *argv_split(const char *, const char *);
+extern ARGV *argv_split_append(ARGV *, const char *, const char *);
+
+#define ARGV_END ((char *) 0)
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/attr.h b/postfix/include/attr.h
new file mode 100644
index 000000000..e81381ed3
--- /dev/null
+++ b/postfix/include/attr.h
@@ -0,0 +1,33 @@
+#ifndef _ATTR_H_INCLUDED_
+#define _ATTR_H_INCLUDED_
+
+/*++
+/* NAME
+/* attr 3h
+/* SUMMARY
+/* attribute list manager
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /*
+ * External interface.
+ */
+extern void attr_enter(HTABLE *, const char *, const char *);
+extern void attr_free(HTABLE *);
+
+#define attr_find(table, name) htable_find((table), (name))
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/binhash.h b/postfix/include/binhash.h
new file mode 100644
index 000000000..f94e35bee
--- /dev/null
+++ b/postfix/include/binhash.h
@@ -0,0 +1,58 @@
+#ifndef _BINHASH_H_INCLUDED_
+#define _BINHASH_H_INCLUDED_
+
+/*++
+/* NAME
+/* binhash 3h
+/* SUMMARY
+/* hash table manager
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /* Structure of one hash table entry. */
+
+typedef struct BINHASH_INFO {
+ char *key; /* lookup key */
+ int key_len; /* key length */
+ char *value; /* associated value */
+ struct BINHASH_INFO *next; /* colliding entry */
+ struct BINHASH_INFO *prev; /* colliding entry */
+} BINHASH_INFO;
+
+ /* Structure of one hash table. */
+
+typedef struct BINHASH {
+ int size; /* length of entries array */
+ int used; /* number of entries in table */
+ BINHASH_INFO **data; /* entries array, auto-resized */
+} BINHASH;
+
+extern BINHASH *binhash_create(int);
+extern BINHASH_INFO *binhash_enter(BINHASH *, const char *, int, char *);
+extern BINHASH_INFO *binhash_locate(BINHASH *, const char *, int);
+extern char *binhash_find(BINHASH *, const char *, int);
+extern void binhash_delete(BINHASH *, const char *, int, void (*) (char *));
+extern void binhash_free(BINHASH *, void (*) (char *));
+extern void binhash_walk(BINHASH *, void (*) (BINHASH_INFO *, char *), char *);
+extern BINHASH_INFO **binhash_list(BINHASH *);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/* CREATION DATE
+/* Thu Feb 20 16:54:29 EST 1997
+/* LAST MODIFICATION
+/* %E% %U%
+/* VERSION/RELEASE
+/* %I%
+/*--*/
+
+#endif
diff --git a/postfix/include/chroot_uid.h b/postfix/include/chroot_uid.h
new file mode 100644
index 000000000..f2a839920
--- /dev/null
+++ b/postfix/include/chroot_uid.h
@@ -0,0 +1,29 @@
+#ifndef _CHROOT_UID_H_INCLUDED_
+#define _CHROOT_UID_H_INCLUDED_
+
+/*++
+/* NAME
+/* chroot_uid 3h
+/* SUMMARY
+/* limit possible damage a process can do
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /* External interface. */
+
+extern void chroot_uid(const char *, const char *);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/connect.h b/postfix/include/connect.h
new file mode 100644
index 000000000..080b99c06
--- /dev/null
+++ b/postfix/include/connect.h
@@ -0,0 +1,37 @@
+#ifndef _CONNECT_H_INCLUDED_
+#define _CONNECT_H_INCLUDED_
+
+/*++
+/* NAME
+/* connect 3h
+/* SUMMARY
+/* client interface file
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /*
+ * Utility library.
+ */
+#include
+
+ /*
+ * Client external interface.
+ */
+extern int unix_connect(const char *, int, int);
+extern int inet_connect(const char *, int, int);
+extern int stream_connect(const char *, int, int);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/dict.h b/postfix/include/dict.h
new file mode 100644
index 000000000..3ec4e93fe
--- /dev/null
+++ b/postfix/include/dict.h
@@ -0,0 +1,100 @@
+#ifndef _DICT_H_INCLUDED_
+#define _DICT_H_INCLUDED_
+
+/*++
+/* NAME
+/* dict 3h
+/* SUMMARY
+/* dictionary manager
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /*
+ * System library.
+ */
+#include
+
+ /*
+ * Utility library.
+ */
+#include
+
+ /*
+ * Generic dictionary interface - in reality, a dictionary extends this
+ * structure with private members to maintain internal state.
+ */
+typedef struct DICT {
+ int flags; /* see below */
+ const char *(*lookup) (struct DICT *, const char *);
+ void (*update) (struct DICT *, const char *, const char *);
+ int (*delete) (struct DICT *, const char *);
+ int (*sequence) (struct DICT *, int, const char **, const char **);
+ void (*close) (struct DICT *);
+ int fd; /* for dict_update() lock */
+ time_t mtime; /* mod time at open */
+} DICT;
+
+#define DICT_FLAG_DUP_WARN (1<<0) /* if file, warn about dups */
+#define DICT_FLAG_DUP_IGNORE (1<<1) /* if file, ignore dups */
+#define DICT_FLAG_TRY0NULL (1<<2) /* do not append 0 to key/value */
+#define DICT_FLAG_TRY1NULL (1<<3) /* append 0 to key/value */
+#define DICT_FLAG_FIXED (1<<4) /* fixed key map */
+#define DICT_FLAG_PATTERN (1<<5) /* keys are patterns */
+#define DICT_FLAG_LOCK (1<<6) /* lock before access */
+#define DICT_FLAG_DUP_REPLACE (1<<7) /* if file, replace dups */
+
+extern int dict_unknown_allowed;
+extern int dict_errno;
+
+#define DICT_ERR_RETRY 1 /* soft error */
+
+ /*
+ * Sequence function types.
+ */
+#define DICT_SEQ_FUN_FIRST 0 /* set cursor to first record */
+#define DICT_SEQ_FUN_NEXT 1 /* set cursor to next record */
+
+ /*
+ * High-level interface, with logical dictionary names.
+ */
+extern void dict_register(const char *, DICT *);
+extern DICT *dict_handle(const char *);
+extern void dict_unregister(const char *);
+extern void dict_update(const char *, const char *, const char *);
+extern const char *dict_lookup(const char *, const char *);
+extern int dict_delete(const char *, const char *);
+extern int dict_sequence(const char *, const int, const char **, const char **);
+extern void dict_load_file(const char *, const char *);
+extern void dict_load_fp(const char *, VSTREAM *);
+extern const char *dict_eval(const char *, const char *, int);
+
+ /*
+ * Low-level interface, with physical dictionary handles.
+ */
+extern DICT *dict_open(const char *, int, int);
+extern DICT *dict_open3(const char *, const char *, int, int);
+extern void dict_open_register(const char *, DICT *(*) (const char *, int, int));
+
+#define dict_get(dp, key) (dp)->lookup((dp), (key))
+#define dict_put(dp, key, val) (dp)->update((dp), (key), (val))
+#define dict_del(dp, key) (dp)->delete((dp), (key))
+#define dict_seq(dp, f, key, val) (dp)->sequence((dp), (f), (key), (val))
+#define dict_close(dp) (dp)->close(dp)
+typedef void (*DICT_WALK_ACTION) (const char *, DICT *, char *);
+extern void dict_walk(DICT_WALK_ACTION, char *);
+extern int dict_changed(void);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/dict_db.h b/postfix/include/dict_db.h
new file mode 100644
index 000000000..43d7e35ab
--- /dev/null
+++ b/postfix/include/dict_db.h
@@ -0,0 +1,36 @@
+#ifndef _DICT_DB_H_INCLUDED_
+#define _DICT_DB_H_INCLUDED_
+
+/*++
+/* NAME
+/* dict_db 3h
+/* SUMMARY
+/* dictionary manager interface to DB files
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /*
+ * Utility library.
+ */
+#include
+
+ /*
+ * External interface.
+ */
+extern DICT *dict_hash_open(const char *, int, int);
+extern DICT *dict_btree_open(const char *, int, int);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/dict_dbm.h b/postfix/include/dict_dbm.h
new file mode 100644
index 000000000..e15e8fb72
--- /dev/null
+++ b/postfix/include/dict_dbm.h
@@ -0,0 +1,35 @@
+#ifndef _DICT_DBN_H_INCLUDED_
+#define _DICT_DBN_H_INCLUDED_
+
+/*++
+/* NAME
+/* dict_dbm 3h
+/* SUMMARY
+/* dictionary manager interface to DBM files
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /*
+ * Utility library.
+ */
+#include
+
+ /*
+ * External interface.
+ */
+extern DICT *dict_dbm_open(const char *, int, int);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/dict_env.h b/postfix/include/dict_env.h
new file mode 100644
index 000000000..f49e10551
--- /dev/null
+++ b/postfix/include/dict_env.h
@@ -0,0 +1,35 @@
+#ifndef _DICT_ENV_H_INCLUDED_
+#define _DICT_ENV_H_INCLUDED_
+
+/*++
+/* NAME
+/* dict_env 3h
+/* SUMMARY
+/* dictionary manager interface to environment variables
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /*
+ * Utility library.
+ */
+#include
+
+ /*
+ * External interface.
+ */
+extern DICT *dict_env_open(const char *, int, int);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/dict_ht.h b/postfix/include/dict_ht.h
new file mode 100644
index 000000000..4f408bc97
--- /dev/null
+++ b/postfix/include/dict_ht.h
@@ -0,0 +1,36 @@
+#ifndef _DICT_HT_H_INCLUDED_
+#define _DICT_HT_H_INCLUDED_
+
+/*++
+/* NAME
+/* dict_ht 3h
+/* SUMMARY
+/* dictionary manager interface to hash tables
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /*
+ * Utility library.
+ */
+#include
+#include
+
+ /*
+ * External interface.
+ */
+extern DICT *dict_ht_open(HTABLE *, void (*) (char *));
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/dict_ldap.h b/postfix/include/dict_ldap.h
new file mode 100644
index 000000000..818835df0
--- /dev/null
+++ b/postfix/include/dict_ldap.h
@@ -0,0 +1,31 @@
+#ifndef _DICT_LDAP_H_INCLUDED_
+#define _DICT_LDAP_H_INCLUDED_
+
+/*++
+/* NAME
+/* dict_ldap 3h
+/* SUMMARY
+/* dictionary manager interface to LDAP maps
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /*
+ * Utility library.
+ */
+#include
+
+ /*
+ * External interface.
+ */
+extern DICT *dict_ldap_open(const char *, int, int);
+
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10532, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/dict_mysql.h b/postfix/include/dict_mysql.h
new file mode 100644
index 000000000..601ccda34
--- /dev/null
+++ b/postfix/include/dict_mysql.h
@@ -0,0 +1,46 @@
+#ifdef HAS_MYSQL
+
+#include
+#include "mysql.h"
+
+#define STATACTIVE 0
+#define STATFAIL 1
+#define STATUNTRIED 2
+#define RETRY_CONN_INTV 300 /* 5 minutes */
+
+extern DICT *dict_mysql_open(const char *name, int unused_flags, int dict_flags);
+
+typedef struct {
+ char *hostname;
+ int stat; /* STATUNTRIED | STATFAIL | STATCUR */
+ time_t ts; /* used for attempting reconnection
+ * every so often if a host is down */
+ MYSQL db;
+} HOST;
+
+
+typedef struct {
+ char *username; /* login for database */
+ char *password; /* password for database */
+ char *dbname; /* the name of the database on all
+ * the servers */
+ HOST *db_hosts; /* the hosts on which the databases
+ * reside */
+ int len_hosts; /* number of hosts */
+} PLMYSQL;
+
+extern PLMYSQL *plmysql_init(char *dbname, char *hostnames[], int len_hosts);
+
+extern int plmysql_connect(PLMYSQL *PLDB, char *username, char *password);
+
+MYSQL_RES *plmysql_query(PLMYSQL *PLDB, const char *query);
+
+void plmysql_dealloc(PLMYSQL *PLDB);
+
+inline void plmysql_down_host(HOST *host);
+
+int plmysql_connect_single(PLMYSQL *PLDB, int host);
+
+int plmysql_ready_reconn(HOST host);
+
+#endif
diff --git a/postfix/include/dict_ni.h b/postfix/include/dict_ni.h
new file mode 100644
index 000000000..b0221a4b6
--- /dev/null
+++ b/postfix/include/dict_ni.h
@@ -0,0 +1,32 @@
+#ifndef _DICT_NI_H_INCLUDED_
+#define _DICT_NI_H_INCLUDED_
+
+/*++
+/* NAME
+/* dict_ni 3h
+/* SUMMARY
+/* dictionary manager interface to NetInfo maps
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /*
+ * Utility library.
+ */
+#include
+
+ /*
+ * External interface.
+ */
+extern DICT *dict_ni_open(const char *, int, int);
+
+/* AUTHOR(S)
+/* Pieter Schoenmakers
+/* Eindhoven University of Technology
+/* P.O. Box 513
+/* 5600 MB Eindhoven
+/* The Netherlands
+/*--*/
+
+#endif
diff --git a/postfix/include/dict_nis.h b/postfix/include/dict_nis.h
new file mode 100644
index 000000000..ff2759b7c
--- /dev/null
+++ b/postfix/include/dict_nis.h
@@ -0,0 +1,35 @@
+#ifndef _DIST_NIS_H_INCLUDED_
+#define _DIST_NIS_H_INCLUDED_
+
+/*++
+/* NAME
+/* dict_nis 3h
+/* SUMMARY
+/* dictionary manager interface to NIS maps
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /*
+ * Utility library.
+ */
+#include
+
+ /*
+ * External interface.
+ */
+extern DICT *dict_nis_open(const char *, int, int);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/dict_nisplus.h b/postfix/include/dict_nisplus.h
new file mode 100644
index 000000000..f43b3141b
--- /dev/null
+++ b/postfix/include/dict_nisplus.h
@@ -0,0 +1,35 @@
+#ifndef _DICT_NISPLUS_H_INCLUDED_
+#define _DICT_NISPLUS_H_INCLUDED_
+
+/*++
+/* NAME
+/* dict_nisplus 3h
+/* SUMMARY
+/* dictionary manager interface to NIS+ maps
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /*
+ * Utility library.
+ */
+#include
+
+ /*
+ * External interface.
+ */
+extern DICT *dict_nisplus_open(const char *, int, int);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/dir_forest.h b/postfix/include/dir_forest.h
new file mode 100644
index 000000000..2c4c3639e
--- /dev/null
+++ b/postfix/include/dir_forest.h
@@ -0,0 +1,35 @@
+#ifndef _DIR_FOREST_H_INCLUDED_
+#define _DIR_FOREST_H_INCLUDED_
+
+/*++
+/* NAME
+/* dir_forest 3h
+/* SUMMARY
+/* file name to directory forest
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /*
+ * Utility library.
+ */
+#include
+
+ /*
+ * External interface.
+ */
+extern char *dir_forest(VSTRING *, const char *, int);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/events.h b/postfix/include/events.h
new file mode 100644
index 000000000..bc39b4787
--- /dev/null
+++ b/postfix/include/events.h
@@ -0,0 +1,62 @@
+#ifndef _EVENTS_H_INCLUDED_
+#define _EVENTS_H_INCLUDED_
+
+/*++
+/* NAME
+/* events 3h
+/* SUMMARY
+/* event manager
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /*
+ * System library.
+ */
+#include
+
+ /*
+ * External interface.
+ */
+typedef void (*EVENT_NOTIFY_RDWR) (int, char *);
+typedef void (*EVENT_NOTIFY_TIME) (int, char *);
+
+extern time_t event_time(void);
+extern void event_enable_read(int, EVENT_NOTIFY_RDWR, char *);
+extern void event_enable_write(int, EVENT_NOTIFY_RDWR, char *);
+extern void event_disable_readwrite(int);
+extern time_t event_request_timer(EVENT_NOTIFY_TIME, char *, int);
+extern int event_cancel_timer(EVENT_NOTIFY_TIME, char *);
+extern void event_loop(int);
+
+ /*
+ * Event codes.
+ */
+#define EVENT_READ (1<<0) /* read event */
+#define EVENT_WRITE (1<<1) /* write event */
+#define EVENT_XCPT (1<<2) /* exception */
+#define EVENT_TIME (1<<3) /* timer event */
+
+#define EVENT_ERROR EVENT_XCPT
+
+ /*
+ * Dummies.
+ */
+#define EVENT_NULL_TYPE 0
+#define EVENT_NULL_CONTEXT ((char *) 0)
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/* CREATION DATE
+/* Wed Jan 29 17:00:03 EST 1997
+/*--*/
+
+#endif
diff --git a/postfix/include/exec_command.h b/postfix/include/exec_command.h
new file mode 100644
index 000000000..4e77211de
--- /dev/null
+++ b/postfix/include/exec_command.h
@@ -0,0 +1,30 @@
+#ifndef _EXEC_COMMAND_H_INCLUDED_
+#define _EXEC_COMMAND_H_INCLUDED_
+
+/*++
+/* NAME
+/* exec_command 3h
+/* SUMMARY
+/* execute command
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /*
+ * External interface.
+ */
+extern NORETURN exec_command(const char *);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/find_inet.h b/postfix/include/find_inet.h
new file mode 100644
index 000000000..0e5ce7271
--- /dev/null
+++ b/postfix/include/find_inet.h
@@ -0,0 +1,33 @@
+#ifndef _FIND_INET_H_INCLUDED_
+#define _FIND_INET_H_INCLUDED_
+
+/*++
+/* NAME
+/* find_inet 3h
+/* SUMMARY
+/* inet-domain name services
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /*
+ * External interface.
+ */
+extern unsigned find_inet_addr(const char *);
+extern int find_inet_port(const char *, const char *);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/* LAST MODIFICATION
+/* Thu Feb 6 12:46:36 EST 1997
+/*--*/
+
+#endif
diff --git a/postfix/include/fsspace.h b/postfix/include/fsspace.h
new file mode 100644
index 000000000..c118e50cf
--- /dev/null
+++ b/postfix/include/fsspace.h
@@ -0,0 +1,33 @@
+#ifndef _FSSPACE_H_INCLUDED_
+#define _FSSPACE_H_INCLUDED_
+
+/*++
+/* NAME
+/* fsspace 3h
+/* SUMMARY
+/* determine available file system space
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /* External interface. */
+struct fsspace {
+ unsigned long block_size; /* block size */
+ unsigned long block_free; /* free space */
+};
+
+extern void fsspace(const char *, struct fsspace *);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/fullname.h b/postfix/include/fullname.h
new file mode 100644
index 000000000..f24492ae7
--- /dev/null
+++ b/postfix/include/fullname.h
@@ -0,0 +1,29 @@
+#ifndef _FULLNAME_H_INCLUDED_
+#define _FULLNAME_H_INCLUDED_
+
+/*++
+/* NAME
+/* fullname 3h
+/* SUMMARY
+/* lookup personal name of invoking user
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /* External interface. */
+
+extern const char *fullname(void);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/get_domainname.h b/postfix/include/get_domainname.h
new file mode 100644
index 000000000..177e3fdbd
--- /dev/null
+++ b/postfix/include/get_domainname.h
@@ -0,0 +1,29 @@
+#ifndef _GET_DOMAINNAME_H_INCLUDED_
+#define _GET_DOMAINNAME_H_INCLUDED_
+
+/*++
+/* NAME
+/* get_domainname 3h
+/* SUMMARY
+/* network domain name lookup
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /* External interface */
+
+extern const char *get_domainname(void);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/get_hostname.h b/postfix/include/get_hostname.h
new file mode 100644
index 000000000..32d2ab2fa
--- /dev/null
+++ b/postfix/include/get_hostname.h
@@ -0,0 +1,29 @@
+#ifndef _GET_HOSTNAME_H_INCLUDED_
+#define _GET_HOSTNAME_H_INCLUDED_
+
+/*++
+/* NAME
+/* get_hostname 3h
+/* SUMMARY
+/* network name lookup
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /* External interface */
+
+extern const char *get_hostname(void);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/htable.h b/postfix/include/htable.h
new file mode 100644
index 000000000..72eaa98f1
--- /dev/null
+++ b/postfix/include/htable.h
@@ -0,0 +1,57 @@
+#ifndef _HTABLE_H_INCLUDED_
+#define _HTABLE_H_INCLUDED_
+
+/*++
+/* NAME
+/* htable 3h
+/* SUMMARY
+/* hash table manager
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /* Structure of one hash table entry. */
+
+typedef struct HTABLE_INFO {
+ char *key; /* lookup key */
+ char *value; /* associated value */
+ struct HTABLE_INFO *next; /* colliding entry */
+ struct HTABLE_INFO *prev; /* colliding entry */
+} HTABLE_INFO;
+
+ /* Structure of one hash table. */
+
+typedef struct HTABLE {
+ int size; /* length of entries array */
+ int used; /* number of entries in table */
+ HTABLE_INFO **data; /* entries array, auto-resized */
+} HTABLE;
+
+extern HTABLE *htable_create(int);
+extern HTABLE_INFO *htable_enter(HTABLE *, const char *, char *);
+extern HTABLE_INFO *htable_locate(HTABLE *, const char *);
+extern char *htable_find(HTABLE *, const char *);
+extern void htable_delete(HTABLE *, const char *, void (*) (char *));
+extern void htable_free(HTABLE *, void (*) (char *));
+extern void htable_walk(HTABLE *, void (*) (HTABLE_INFO *, char *), char *);
+extern HTABLE_INFO **htable_list(HTABLE *);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/* CREATION DATE
+/* Fri Feb 14 13:43:19 EST 1997
+/* LAST MODIFICATION
+/* %E% %U%
+/* VERSION/RELEASE
+/* %I%
+/*--*/
+
+#endif
diff --git a/postfix/include/inet_addr_host.h b/postfix/include/inet_addr_host.h
new file mode 100644
index 000000000..39d150a5a
--- /dev/null
+++ b/postfix/include/inet_addr_host.h
@@ -0,0 +1,35 @@
+#ifndef INET_ADDR_HOST_H_INCLUDED_
+#define INET_ADDR_HOST_H_INCLUDED_
+
+/*++
+/* NAME
+/* inet_addr_host 3h
+/* SUMMARY
+/* determine all host internet interface addresses
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /*
+ * Utility library.
+ */
+#include
+
+ /*
+ * External interface.
+ */
+extern int inet_addr_host(INET_ADDR_LIST *, const char *);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/inet_addr_list.h b/postfix/include/inet_addr_list.h
new file mode 100644
index 000000000..48a4c9712
--- /dev/null
+++ b/postfix/include/inet_addr_list.h
@@ -0,0 +1,43 @@
+#ifndef _INET_ADDR_LIST_H_INCLUDED_
+#define _INET_ADDR_LIST_H_INCLUDED_
+
+/*++
+/* NAME
+/* inet_addr_list 3h
+/* SUMMARY
+/* internet address list manager
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /*
+ * System library.
+ */
+#include
+
+ /*
+ * External interface.
+ */
+typedef struct INET_ADDR_LIST {
+ int used; /* nr of elements in use */
+ int size; /* actual list size */
+ struct in_addr *addrs; /* payload */
+} INET_ADDR_LIST;
+
+extern void inet_addr_list_init(INET_ADDR_LIST *);
+extern void inet_addr_list_free(INET_ADDR_LIST *);
+extern void inet_addr_list_append(INET_ADDR_LIST *, struct in_addr *);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/inet_addr_local.h b/postfix/include/inet_addr_local.h
new file mode 100644
index 000000000..f48ca1eb0
--- /dev/null
+++ b/postfix/include/inet_addr_local.h
@@ -0,0 +1,35 @@
+#ifndef _INET_ADDR_LOCAL_H_INCLUDED_
+#define _INET_ADDR_LOCAL_H_INCLUDED_
+
+/*++
+/* NAME
+/* inet_addr_local 3h
+/* SUMMARY
+/* determine if IP address is local
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /*
+ * Utility library.
+ */
+#include
+
+ /*
+ * External interface.
+ */
+extern int inet_addr_local(INET_ADDR_LIST *);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/inet_util.h b/postfix/include/inet_util.h
new file mode 100644
index 000000000..7eea60279
--- /dev/null
+++ b/postfix/include/inet_util.h
@@ -0,0 +1,29 @@
+#ifndef _INET_UTIL_H_INCLUDED_
+#define _INET_UTIL_H_INCLUDED_
+
+/*++
+/* NAME
+/* inet_util 3h
+/* SUMMARY
+/* INET-domain utilities
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /* External interface. */
+
+extern char *inet_parse(const char *, char **, char **);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/iostuff.h b/postfix/include/iostuff.h
new file mode 100644
index 000000000..909bffb5e
--- /dev/null
+++ b/postfix/include/iostuff.h
@@ -0,0 +1,48 @@
+#ifndef _IOSTUFF_H_INCLUDED_
+#define _IOSTUFF_H_INCLUDED_
+
+/*++
+/* NAME
+/* iostuff 3h
+/* SUMMARY
+/* miscellaneous I/O primitives
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+
+ /*
+ * External interface.
+ */
+extern int non_blocking(int, int);
+extern int close_on_exec(int, int);
+extern int open_limit(int);
+extern int readable(int);
+extern int writable(int);
+extern off_t get_file_limit(void);
+extern void set_file_limit(off_t);
+extern int peekfd(int);
+extern int read_wait(int, int);
+extern int write_wait(int, int);
+extern int write_buf(int, const char *, int, int);
+extern void doze(unsigned);
+
+#define BLOCKING 0
+#define NON_BLOCKING 1
+
+#define CLOSE_ON_EXEC 1
+#define PASS_ON_EXEC 0
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/* CREATION DATE
+/* Sat Jan 25 16:54:13 EST 1997
+/*--*/
+
+#endif
diff --git a/postfix/include/line_wrap.h b/postfix/include/line_wrap.h
new file mode 100644
index 000000000..b901c1f3d
--- /dev/null
+++ b/postfix/include/line_wrap.h
@@ -0,0 +1,31 @@
+#ifndef _LINE_WRAP_H_INCLUDED_
+#define _LINE_WRAP_H_INCLUDED_
+
+/*++
+/* NAME
+/* line_wrap 3h
+/* SUMMARY
+/* wrap long lines upon output
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /*
+ * External interface.
+ */
+typedef void (*LINE_WRAP_FN) (const char *, int, int, char *);
+extern void line_wrap(const char *, int, int, LINE_WRAP_FN, char *);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/listen.h b/postfix/include/listen.h
new file mode 100644
index 000000000..81c5389c0
--- /dev/null
+++ b/postfix/include/listen.h
@@ -0,0 +1,42 @@
+#ifndef _LISTEN_H_INCLUDED_
+#define _LISTEN_H_INCLUDED_
+
+/*++
+/* NAME
+/* listen 3h
+/* SUMMARY
+/* listener interface file
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /*
+ * Utility library.
+ */
+#include
+
+ /*
+ * Listener external interface.
+ */
+extern int unix_listen(const char *, int, int);
+extern int inet_listen(const char *, int, int);
+extern int fifo_listen(const char *, int, int);
+extern int stream_listen(const char *, int, int);
+
+extern int inet_accept(int);
+extern int unix_accept(int);
+extern int stream_accept(int);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/lstat_as.h b/postfix/include/lstat_as.h
new file mode 100644
index 000000000..824b32115
--- /dev/null
+++ b/postfix/include/lstat_as.h
@@ -0,0 +1,30 @@
+#ifndef _LSTAT_AS_H_INCLUDED_
+#define _LSTAT_AS_H_INCLUDED_
+
+/*++
+/* NAME
+/* lstat_as 3h
+/* SUMMARY
+/* lstat file as user
+/* SYNOPSIS
+/* #include
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /* External interface. */
+
+extern int lstat_as(const char *, struct stat *, uid_t, gid_t);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/mac_parse.h b/postfix/include/mac_parse.h
new file mode 100644
index 000000000..1acbb60d5
--- /dev/null
+++ b/postfix/include/mac_parse.h
@@ -0,0 +1,44 @@
+#ifndef _MAC_PARSE_H_INCLUDED_
+#define _MAC_PARSE_H_INCLUDED_
+
+/*++
+/* NAME
+/* mac_parse 3h
+/* SUMMARY
+/* locate macro references in string
+/* SYNOPSIS
+/* #include
+ DESCRIPTION
+ .nf
+
+ /*
+ * Utility library.
+ */
+#include
+
+ /*
+ * External interface.
+ */
+#define MAC_PARSE_LITERAL 1
+#define MAC_PARSE_VARNAME 2
+
+#define MAC_PARSE_ERROR (1<<0)
+#define MAC_PARSE_UNDEF (1<<1)
+#define MAC_PARSE_USER 2 /* start user definitions */
+
+typedef int (*MAC_PARSE_FN)(int, VSTRING *, char *);
+
+extern int mac_parse(const char *, MAC_PARSE_FN, char *);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/make_dirs.h b/postfix/include/make_dirs.h
new file mode 100644
index 000000000..0df6117d8
--- /dev/null
+++ b/postfix/include/make_dirs.h
@@ -0,0 +1,30 @@
+#ifndef MAKE_DIRS_H_INCLUDED_
+#define MAKE_DIRS_H_INCLUDED_
+
+/*++
+/* NAME
+/* make_dirs 3h
+/* SUMMARY
+/* create directory hierarchy
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /*
+ * External interface.
+ */
+extern int make_dirs(const char *, int);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/match_list.h b/postfix/include/match_list.h
new file mode 100644
index 000000000..aba88b8f6
--- /dev/null
+++ b/postfix/include/match_list.h
@@ -0,0 +1,35 @@
+#ifndef _MATCH_LIST_H_INCLUDED_
+#define _MATCH_LIST_H_INCLUDED_
+
+/*++
+/* NAME
+/* match_list 3h
+/* SUMMARY
+/* generic list-based pattern matching
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /*
+ * External interface.
+ */
+typedef struct MATCH_LIST MATCH_LIST;
+typedef int (*MATCH_LIST_FN) (const char *, const char *);
+
+extern MATCH_LIST *match_list_init(const char *, int,...);
+extern int match_list_match(MATCH_LIST *,...);
+extern void match_list_free(MATCH_LIST *);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/match_ops.h b/postfix/include/match_ops.h
new file mode 100644
index 000000000..a938c04fb
--- /dev/null
+++ b/postfix/include/match_ops.h
@@ -0,0 +1,31 @@
+#ifndef _MATCH_OPS_H_INCLUDED_
+#define _MATCH_OPS_H_INCLUDED_
+
+/*++
+/* NAME
+/* match_ops 3h
+/* SUMMARY
+/* simple string or host pattern matching
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /* External interface. */
+
+extern int match_string(const char *, const char *);
+extern int match_hostname(const char *, const char *);
+extern int match_hostaddr(const char *, const char *);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/msg.h b/postfix/include/msg.h
new file mode 100644
index 000000000..2b62dec5e
--- /dev/null
+++ b/postfix/include/msg.h
@@ -0,0 +1,42 @@
+#ifndef _MSG_H_INCLUDED_
+#define _MSG_H_INCLUDED_
+
+/*++
+/* NAME
+/* msg 3h
+/* SUMMARY
+/* diagnostics interface
+/* SYNOPSIS
+/* #include "msg.h"
+/* DESCRIPTION
+/* .nf
+
+/*
+ * External interface.
+ */
+typedef void (*MSG_CLEANUP_FN) (void);
+
+extern int msg_verbose;
+
+extern void msg_info(const char *,...);
+extern void msg_warn(const char *,...);
+extern void msg_error(const char *,...);
+extern NORETURN msg_fatal(const char *,...);
+extern NORETURN msg_panic(const char *,...);
+
+extern int msg_error_limit(int);
+extern void msg_error_clear(void);
+extern MSG_CLEANUP_FN msg_cleanup(MSG_CLEANUP_FN);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/msg_output.h b/postfix/include/msg_output.h
new file mode 100644
index 000000000..b409e9518
--- /dev/null
+++ b/postfix/include/msg_output.h
@@ -0,0 +1,47 @@
+#ifndef _MSG_OUTPUT_FN_
+#define _MSG_OUTPUT_FN_
+
+/*++
+/* NAME
+/* msg_output 3h
+/* SUMMARY
+/* diagnostics output management
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+
+ /*
+ * System library.
+ */
+#include
+
+ /*
+ * External interface. Severity levels are documented to be monotonically
+ * increasing from 0 up to MSG_LAST.
+ */
+typedef void (*MSG_OUTPUT_FN) (int, const char *);
+extern void msg_output(MSG_OUTPUT_FN);
+extern void msg_printf(int, const char *,...);
+extern void msg_vprintf(int, const char *, va_list);
+extern void msg_text(int, const char *);
+
+#define MSG_INFO 0 /* informative */
+#define MSG_WARN 1 /* warning (non-fatal) */
+#define MSG_ERROR 2 /* error (fatal) */
+#define MSG_FATAL 3 /* software error (fatal) */
+#define MSG_PANIC 4 /* software error (fatal) */
+
+#define MSG_LAST 4 /* highest-numbered severity level */
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/msg_syslog.h b/postfix/include/msg_syslog.h
new file mode 100644
index 000000000..94e1ea3ff
--- /dev/null
+++ b/postfix/include/msg_syslog.h
@@ -0,0 +1,34 @@
+#ifndef _MSG_SYSLOG_H_INCLUDED_
+#define _MSG_SYSLOG_H_INCLUDED_
+
+/*++
+/* NAME
+/* msg_syslog 3h
+/* SUMMARY
+/* direct diagnostics to syslog daemon
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+
+ /*
+ * System library.
+ */
+#include
+
+ /*
+ * External interface.
+ */
+extern void msg_syslog_init(const char *, int, int);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/msg_vstream.h b/postfix/include/msg_vstream.h
new file mode 100644
index 000000000..a0dfc7048
--- /dev/null
+++ b/postfix/include/msg_vstream.h
@@ -0,0 +1,34 @@
+#ifndef _MSG_VSTREAM_H_INCLUDED_
+#define _MSG_VSTREAM_H_INCLUDED_
+
+/*++
+/* NAME
+/* msg_vstream 3h
+/* SUMMARY
+/* direct diagnostics to VSTREAM
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+
+ /*
+ * Utility library.
+ */
+#include
+
+ /*
+ * External interface.
+ */
+extern void msg_vstream_init(const char *, VSTREAM *);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/mvect.h b/postfix/include/mvect.h
new file mode 100644
index 000000000..23214d547
--- /dev/null
+++ b/postfix/include/mvect.h
@@ -0,0 +1,42 @@
+#ifndef _MVECT_H_INCLUDED_
+#define _MVECT_H_INCLUDED_
+
+/*++
+/* NAME
+/* mvect 3h
+/* SUMMARY
+/* memory vector management
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /*
+ * Generic memory vector interface.
+ */
+typedef void (*MVECT_FN) (char *, int);
+
+typedef struct {
+ char *ptr;
+ int elsize;
+ int nelm;
+ MVECT_FN init_fn;
+ MVECT_FN wipe_fn;
+} MVECT;
+
+extern char *mvect_alloc(MVECT *, int, int, MVECT_FN, MVECT_FN);
+extern char *mvect_realloc(MVECT *, int);
+extern char *mvect_free(MVECT *);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/myflock.h b/postfix/include/myflock.h
new file mode 100644
index 000000000..7d43efeae
--- /dev/null
+++ b/postfix/include/myflock.h
@@ -0,0 +1,38 @@
+#ifndef _MYFLOCK_H_INCLUDED_
+#define _MYFLOCK_H_INCLUDED_
+
+/*++
+/* NAME
+/* myflock 3h
+/* SUMMARY
+/* lock open file
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /*
+ * External interface.
+ */
+extern int myflock(int, int);
+extern int myflock_locked(int);
+
+#define MYFLOCK_NONE 0
+#define MYFLOCK_SHARED 1
+#define MYFLOCK_EXCLUSIVE 2
+#define MYFLOCK_LOCK_MASK (MYFLOCK_SHARED | MYFLOCK_EXCLUSIVE)
+#define MYFLOCK_NOWAIT 4
+#define MYFLOCK_BITS (MYFLOCK_LOCK_MASK | MYFLOCK_NOWAIT)
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/mymalloc.h b/postfix/include/mymalloc.h
new file mode 100644
index 000000000..9503bcd17
--- /dev/null
+++ b/postfix/include/mymalloc.h
@@ -0,0 +1,35 @@
+#ifndef _MALLOC_H_INCLUDED_
+#define _MALLOC_H_INCLUDED_
+
+/*++
+/* NAME
+/* mymalloc 3h
+/* SUMMARY
+/* memory management wrappers
+/* SYNOPSIS
+/* #include "mymalloc.h"
+ DESCRIPTION
+ .nf
+
+ /*
+ * External interface.
+ */
+extern char *mymalloc(int);
+extern char *myrealloc(char *, int);
+extern void myfree(char *);
+extern char *mystrdup(const char *);
+extern char *mystrndup(const char *, int len);
+extern char *mymemdup(const char *, int);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/name_mask.h b/postfix/include/name_mask.h
new file mode 100644
index 000000000..2387f3921
--- /dev/null
+++ b/postfix/include/name_mask.h
@@ -0,0 +1,35 @@
+#ifndef _NAME_MASK_H_INCLUDED_
+#define _NAME_MASK_H_INCLUDED_
+
+/*++
+/* NAME
+/* name_mask 3h
+/* SUMMARY
+/* map names to bit mask
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /*
+ * External interface.
+ */
+typedef struct {
+ const char *name;
+ int mask;
+} NAME_MASK;
+
+extern int name_mask(NAME_MASK *, const char *);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/open_as.h b/postfix/include/open_as.h
new file mode 100644
index 000000000..308e0094f
--- /dev/null
+++ b/postfix/include/open_as.h
@@ -0,0 +1,30 @@
+#ifndef _OPEN_H_INCLUDED_
+#define _OPEN_H_INCLUDED_
+
+/*++
+/* NAME
+/* open_as 3h
+/* SUMMARY
+/* open file as user
+/* SYNOPSIS
+/* #include
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /* External interface. */
+
+extern int open_as(const char *, int, int, uid_t, gid_t);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/open_lock.h b/postfix/include/open_lock.h
new file mode 100644
index 000000000..869233f95
--- /dev/null
+++ b/postfix/include/open_lock.h
@@ -0,0 +1,41 @@
+#ifndef _OPEN_LOCK_H_INCLUDED_
+#define _OPEN_LOCK_H_INCLUDED_
+
+/*++
+/* NAME
+/* open_lock 3h
+/* SUMMARY
+/* open or create file and lock it for exclusive access
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /*
+ * System library.
+ */
+#include
+
+ /*
+ * Utility library.
+ */
+#include
+#include
+
+ /*
+ * External interface.
+ */
+extern VSTREAM *open_lock(const char *, int, int, VSTRING *);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/percentm.h b/postfix/include/percentm.h
new file mode 100644
index 000000000..d170e9586
--- /dev/null
+++ b/postfix/include/percentm.h
@@ -0,0 +1,35 @@
+#ifndef _PERCENT_H_INCLUDED_
+#define _PERCENT_H_INCLUDED_
+
+/*++
+/* NAME
+/* percentm 3h
+/* SUMMARY
+/* expand %m embedded in string to system error text
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /*
+ * External interface.
+ */
+extern char *percentm(const char *, int);
+
+/* HISTORY
+/* .ad
+/* .fi
+/* A percentm() routine appears in the TCP Wrapper software
+/* by Wietse Venema.
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/posix_signals.h b/postfix/include/posix_signals.h
new file mode 100644
index 000000000..12c1664db
--- /dev/null
+++ b/postfix/include/posix_signals.h
@@ -0,0 +1,59 @@
+#ifndef _POSIX_SIGNALS_H_INCLUDED_
+#define _POSIX_SIGNALS_H_INCLUDED_
+/*++
+/* NAME
+/* posix_signals 3h
+/* SUMMARY
+/* POSIX signal handling compatibility
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /*
+ * Compatibility interface.
+ */
+
+#ifdef MISSING_SIGSET_T
+
+typedef int sigset_t;
+
+enum {
+ SIG_BLOCK,
+ SIG_UNBLOCK,
+ SIG_SETMASK
+};
+
+extern int sigemptyset(sigset_t *);
+extern int sigaddset(sigset_t *, int);
+extern int sigprocmask(int, sigset_t *, sigset_t *);
+
+#endif
+
+#ifdef MISSING_SIGACTION
+
+struct sigaction {
+ void (*sa_handler) ();
+ sigset_t sa_mask;
+ int sa_flags;
+};
+
+ /* Possible values for sa_flags. Or them to set multiple. */
+enum {
+ SA_RESTART,
+ SA_NOCLDSTOP = 4 /* drop the = 4. */
+};
+
+extern int sigaction(int, struct sigaction *, struct sigaction *);
+
+#endif
+
+/* AUTHOR(S)
+/* Pieter Schoenmakers
+/* Eindhoven University of Technology
+/* P.O. Box 513
+/* 5600 MB Eindhoven
+/* The Netherlands
+/*--*/
+
+#endif
diff --git a/postfix/include/readlline.h b/postfix/include/readlline.h
new file mode 100644
index 000000000..8a8bd5487
--- /dev/null
+++ b/postfix/include/readlline.h
@@ -0,0 +1,36 @@
+#ifndef _READLINE_H_INCLUDED_
+#define _READLINE_H_INCLUDED_
+
+/*++
+/* NAME
+/* readlline 3h
+/* SUMMARY
+/* read logical line
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /*
+ * Utility library.
+ */
+#include
+#include
+
+ /*
+ * External interface.
+ */
+extern VSTRING *readlline(VSTRING *, VSTREAM *, int *);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/ring.h b/postfix/include/ring.h
new file mode 100644
index 000000000..a96fe2696
--- /dev/null
+++ b/postfix/include/ring.h
@@ -0,0 +1,45 @@
+#ifndef _RING_H_INCLUDED_
+#define _RING_H_INCLUDED_
+
+/*++
+/* NAME
+/* ring 3h
+/* SUMMARY
+/* circular list management
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /*
+ * External interface.
+ */
+typedef struct RING RING;
+
+struct RING {
+ RING *succ; /* successor */
+ RING *pred; /* predecessor */
+};
+
+extern void ring_init(RING *);
+extern void ring_prepend(RING *, RING *);
+extern void ring_append(RING *, RING *);
+extern void ring_detach(RING *);
+
+#define ring_succ(c) ((c)->succ)
+#define ring_pred(c) ((c)->pred)
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/* LAST MODIFICATION
+/* Tue Jan 28 16:50:20 EST 1997
+/*--*/
+
+#endif
diff --git a/postfix/include/safe.h b/postfix/include/safe.h
new file mode 100644
index 000000000..8b75bf43e
--- /dev/null
+++ b/postfix/include/safe.h
@@ -0,0 +1,30 @@
+#ifndef _SAFE_H_INCLUDED_
+#define _SAFE_H_INCLUDED_
+
+/*++
+/* NAME
+/* safe 3h
+/* SUMMARY
+/* miscellaneous taint checks
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /* External interface. */
+
+extern int unsafe(void);
+extern char *safe_getenv(const char *);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/safe_open.h b/postfix/include/safe_open.h
new file mode 100644
index 000000000..02964f8ba
--- /dev/null
+++ b/postfix/include/safe_open.h
@@ -0,0 +1,41 @@
+#ifndef _SAFE_OPEN_H_INCLUDED_
+#define _SAFE_OPEN_H_INCLUDED_
+
+/*++
+/* NAME
+/* safe_open 3h
+/* SUMMARY
+/* safely open or create regular file
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /*
+ * System library.
+ */
+#include
+
+ /*
+ * Utility library.
+ */
+#include
+#include
+
+ /*
+ * External interface.
+ */
+extern VSTREAM *safe_open(const char *, int, int, uid_t, gid_t, VSTRING *);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/sane_accept.h b/postfix/include/sane_accept.h
new file mode 100644
index 000000000..84cc36034
--- /dev/null
+++ b/postfix/include/sane_accept.h
@@ -0,0 +1,29 @@
+#ifndef _SANE_ACCEPT_H_
+#define _SANE_ACCEPT_H_
+
+/*++
+/* NAME
+/* sane_accept 3h
+/* SUMMARY
+/* sanitize accept() error returns
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /* External interface. */
+
+extern int sane_accept(int, struct sockaddr *, SOCKADDR_SIZE *);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/scan_dir.h b/postfix/include/scan_dir.h
new file mode 100644
index 000000000..8f3bf8b98
--- /dev/null
+++ b/postfix/include/scan_dir.h
@@ -0,0 +1,37 @@
+#ifndef _SCAN_DIR_H_INCLUDED_
+#define _SCAN_DIR_H_INCLUDED_
+
+/*++
+/* NAME
+/* scan_dir 3h
+/* SUMMARY
+/* directory scanner
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /*
+ * The directory scanner interface.
+ */
+typedef struct SCAN_DIR SCAN_DIR;
+
+extern SCAN_DIR *scan_dir_open(const char *);
+extern char *scan_dir_next(SCAN_DIR *);
+extern char *scan_dir_path(SCAN_DIR *);
+extern void scan_dir_push(SCAN_DIR *, const char *);
+extern SCAN_DIR *scan_dir_pop(SCAN_DIR *);
+extern SCAN_DIR *scan_dir_close(SCAN_DIR *);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/set_eugid.h b/postfix/include/set_eugid.h
new file mode 100644
index 000000000..e461cbfed
--- /dev/null
+++ b/postfix/include/set_eugid.h
@@ -0,0 +1,29 @@
+#ifndef _SET_EUGID_H_INCLUDED_
+#define _SET_EUGID_H_INCLUDED_
+
+/*++
+/* NAME
+/* set_eugid 3h
+/* SUMMARY
+/* set effective user and group attributes
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /* External interface. */
+
+extern void set_eugid(uid_t, gid_t);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/set_ugid.h b/postfix/include/set_ugid.h
new file mode 100644
index 000000000..e752beb92
--- /dev/null
+++ b/postfix/include/set_ugid.h
@@ -0,0 +1,29 @@
+#ifndef _SET_UGID_H_INCLUDED_
+#define _SET_UGID_H_INCLUDED_
+
+/*++
+/* NAME
+/* set_ugid 3h
+/* SUMMARY
+/* set real, effective and saved user and group attributes
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /* External interface. */
+
+extern void set_ugid(uid_t, gid_t);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/sigdelay.h b/postfix/include/sigdelay.h
new file mode 100644
index 000000000..d3b4ea33b
--- /dev/null
+++ b/postfix/include/sigdelay.h
@@ -0,0 +1,31 @@
+#ifndef _SIGDELAY_H_INCLUDED_
+#define _SIGDELAY_H_INCLUDED_
+
+/*++
+/* NAME
+/* sigdelay 3h
+/* SUMMARY
+/* delay/resume signal delivery
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /*
+ * External interface.
+ */
+extern void sigdelay(void);
+extern void sigresume(void);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/split_at.h b/postfix/include/split_at.h
new file mode 100644
index 000000000..2d03ebb2c
--- /dev/null
+++ b/postfix/include/split_at.h
@@ -0,0 +1,35 @@
+#ifndef _SPLIT_AT_H_INCLUDED_
+#define _SPLIT_AT_H_INCLUDED_
+
+/*++
+/* NAME
+/* split_at 3h
+/* SUMMARY
+/* trivial token splitter
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /* External interface. */
+
+extern char *split_at(char *, int);
+extern char *split_at_right(char *, int);
+
+/* HISTORY
+/* .ad
+/* .fi
+/* A split_at() routine appears in the TCP Wrapper software
+/* by Wietse Venema.
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/stat_as.h b/postfix/include/stat_as.h
new file mode 100644
index 000000000..aad37d30a
--- /dev/null
+++ b/postfix/include/stat_as.h
@@ -0,0 +1,30 @@
+#ifndef _STAT_AS_H_INCLUDED_
+#define _STAT_AS_H_INCLUDED_
+
+/*++
+/* NAME
+/* stat_as 3h
+/* SUMMARY
+/* stat file as user
+/* SYNOPSIS
+/* #include
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /* External interface. */
+
+extern int stat_as(const char *, struct stat *, uid_t, gid_t);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/stringops.h b/postfix/include/stringops.h
new file mode 100644
index 000000000..854c02923
--- /dev/null
+++ b/postfix/include/stringops.h
@@ -0,0 +1,38 @@
+#ifndef _STRINGOPS_H_INCLUDED_
+#define _STRINGOPS_H_INCLUDED_
+
+/*++
+/* NAME
+/* stringops 3h
+/* SUMMARY
+/* string operations
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /* External interface. */
+
+extern char *printable(char *, int);
+extern char *lowercase(char *);
+extern char *skipblanks(const char *);
+extern char *trimblanks(char *, int);
+extern char *concatenate(const char *,...);
+extern char *mystrtok(char **, const char *);
+extern char *translit(char *, const char *, const char *);
+#ifndef HAVE_BASENAME
+extern char *basename(const char *);
+#endif
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/sys_defs.h b/postfix/include/sys_defs.h
new file mode 100644
index 000000000..6665f8d39
--- /dev/null
+++ b/postfix/include/sys_defs.h
@@ -0,0 +1,772 @@
+#ifndef _SYS_DEFS_H_INCLUDED_
+#define _SYS_DEFS_H_INCLUDED_
+
+/*++
+/* NAME
+/* sys_defs 3h
+/* SUMMARY
+/* portability header
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /*
+ * Specific platforms. Major release numbers differ for a good reason. So be
+ * a good girl, plan for the future, and at least include the major release
+ * number in the system type (for example, SUNOS5 or FREEBSD2). The system
+ * type is determined by the makedefs shell script in the top-level
+ * directory. Adding support for a new system type means updating the
+ * makedefs script, and adding a section below for the new system.
+ */
+#if defined(FREEBSD2) || defined(FREEBSD3) || defined(FREEBSD4) \
+ || defined(BSDI2) || defined(BSDI3) || defined(BSDI4) \
+ || defined(OPENBSD2) || defined(NETBSD1) || defined(RHAPSODY5)
+#define SUPPORTED
+#include
+#define USE_PATHS_H
+#define USE_FLOCK_LOCK
+#define HAS_SUN_LEN
+#define HAS_FSYNC
+#define HAS_DB
+#define HAS_SA_LEN
+#define DEF_DB_TYPE "hash"
+#define ALIAS_DB_MAP "hash:/etc/aliases"
+#define GETTIMEOFDAY(t) gettimeofday(t,(struct timezone *) 0)
+#define ROOT_PATH "/bin:/usr/bin:/sbin:/usr/sbin"
+#define USE_STATFS
+#define STATFS_IN_SYS_MOUNT_H
+#define HAS_POSIX_REGEXP
+#endif
+
+#if defined(OPENBSD2)
+#define HAS_ISSETUGID
+#endif
+
+#if defined(NETBSD1)
+#define USE_DOT_LOCK
+#endif
+
+#if defined(RHAPSODY5)
+#define NORETURN void
+#define HAS_NETINFO
+#endif
+
+#ifdef ULTRIX4
+#define SUPPORTED
+/* Ultrix by default has only 64 descriptors per process */
+#ifndef FD_SETSIZE
+#define FD_SETSIZE 96
+#endif
+#include
+#define UNSAFE_CTYPE /* XXX verify */
+#define _PATH_MAILDIR "/var/spool/mail"
+#define _PATH_BSHELL "/bin/sh"
+#define _PATH_DEFPATH "/usr/bin:/usr/ucb"
+#define _PATH_STDPATH "/usr/bin:/usr/etc:/usr/ucb"
+#define USE_FLOCK_LOCK
+#define USE_DOT_LOCK
+#define HAS_FSYNC
+/* might be set by makedef */
+#ifdef HAS_DB
+#define DEF_DB_TYPE "hash"
+#define ALIAS_DB_MAP "hash:/etc/aliases"
+#else
+#define HAS_DBM
+#define DEF_DB_TYPE "dbm"
+#define ALIAS_DB_MAP "dbm:/etc/aliases"
+#endif
+extern int optind;
+extern char *optarg;
+extern int opterr;
+
+#define MISSING_STRFTIME_E
+#define HAS_NIS
+#define GETTIMEOFDAY(t) gettimeofday(t,(struct timezone *) 0)
+#define ROOT_PATH "/bin:/usr/bin:/etc:/usr/etc:/usr/ucb"
+#define USE_STATFS
+#define USE_STRUCT_FS_DATA
+#define STATFS_IN_SYS_MOUNT_H
+/* Ultrix misses just S_ISSOCK, the others are there */
+#define S_ISSOCK(mode) (((mode) & (S_IFMT)) == (S_IFSOCK))
+#define DUP2_DUPS_CLOSE_ON_EXEC
+#define MISSING_USLEEP
+#endif
+
+#ifdef OSF1
+#define SUPPORTED
+#include
+#define MISSING_SETENV
+#define USE_PATHS_H
+#define _PATH_DEFPATH "/usr/bin:/usr/ucb"
+#define USE_FLOCK_LOCK
+#define USE_DOT_LOCK
+#define HAS_FSYNC
+#define HAVE_BASENAME
+#define HAS_DBM
+#define DEF_DB_TYPE "dbm"
+#define ALIAS_DB_MAP "dbm:/var/adm/sendmail/aliases"
+extern int optind; /* XXX use */
+extern char *optarg; /* XXX use */
+extern int opterr; /* XXX use */
+
+#define HAS_NIS
+#define GETTIMEOFDAY(t) gettimeofday(t,(struct timezone *) 0)
+#define ROOT_PATH "/bin:/usr/bin:/sbin:/usr/sbin:/usr/ucb"
+#define USE_STATFS
+#define STATFS_IN_SYS_MOUNT_H
+#define HAS_POSIX_REGEXP
+#endif
+
+#ifdef SUNOS4
+#define SUPPORTED
+#include
+#define UNSAFE_CTYPE
+#define fpos_t long
+#define MISSING_SETENV
+#define MISSING_STRERROR
+#define _PATH_MAILDIR "/var/spool/mail"
+#define _PATH_BSHELL "/bin/sh"
+#define _PATH_DEFPATH "/usr/bin:/usr/ucb"
+#define _PATH_STDPATH "/usr/bin:/usr/etc:/usr/ucb"
+#define USE_FLOCK_LOCK
+#define USE_DOT_LOCK
+#define HAS_FSYNC
+#define HAS_DBM
+#define DEF_DB_TYPE "dbm"
+#define ALIAS_DB_MAP "dbm:/etc/aliases"
+extern int optind;
+extern char *optarg;
+extern int opterr;
+
+#define HAS_NIS
+#define GETTIMEOFDAY(t) gettimeofday(t,(struct timezone *) 0)
+#define ROOT_PATH "/bin:/usr/bin:/etc:/usr/etc:/usr/ucb"
+#define USE_STATFS
+#define STATFS_IN_SYS_VFS_H
+#define memmove(d,s,l) bcopy(s,d,l)
+#endif
+
+#ifdef SUNOS5
+#define SUPPORTED
+#define _SVID_GETTOD /* Solaris 2.5, XSH4.2 versus SVID */
+#include
+#define MISSING_SETENV
+#define _PATH_MAILDIR "/var/mail"
+#define _PATH_BSHELL "/bin/sh"
+#define _PATH_DEFPATH "/usr/bin:/usr/ucb"
+#define _PATH_STDPATH "/usr/bin:/usr/sbin:/usr/ucb"
+#define USE_FCNTL_LOCK
+#define USE_DOT_LOCK
+#define HAS_FSYNC
+#define HAS_DBM
+#define DEF_DB_TYPE "dbm"
+#define ALIAS_DB_MAP "dbm:/etc/mail/aliases"
+#define HAS_NIS
+#define USE_SYS_SOCKIO_H /* Solaris 2.5, changed sys/ioctl.h */
+#define GETTIMEOFDAY(t) gettimeofday(t)
+#define ROOT_PATH "/bin:/usr/bin:/sbin:/usr/sbin:/usr/ucb"
+#define FIONREAD_IN_SYS_FILIO_H
+#define USE_STATVFS
+#define STATVFS_IN_SYS_STATVFS_H
+#define STREAM_CONNECTIONS /* avoid UNIX-domain sockets */
+#define LOCAL_LISTEN stream_listen
+#define LOCAL_ACCEPT stream_accept
+#define LOCAL_CONNECT stream_connect
+#define LOCAL_TRIGGER stream_trigger
+#define HAS_VOLATILE_LOCKS
+#endif
+
+#ifdef UW7 /* UnixWare 7 */
+#define SUPPORTED
+#include
+#define _PATH_MAILDIR "/var/mail"
+#define _PATH_BSHELL "/bin/sh"
+#define _PATH_DEFPATH "/usr/bin:/usr/ucb"
+#define _PATH_STDPATH "/usr/bin:/usr/sbin:/usr/ucb"
+#define MISSING_SETENV
+#define USE_FCNTL_LOCK
+#define USE_DOT_LOCK
+#define HAS_FSYNC
+#define HAS_DBM
+#define DEF_DB_TYPE "dbm"
+#define ALIAS_DB_MAP "dbm:/etc/mail/aliases"
+#define HAS_NIS
+#define USE_SYS_SOCKIO_H
+#define GETTIMEOFDAY(t) gettimeofday(t,(struct timezone *) 0)
+#define ROOT_PATH "/bin:/usr/bin:/sbin:/usr/sbin:/usr/ucb"
+#define FIONREAD_IN_SYS_FILIO_H
+#define DBM_NO_TRAILING_NULL
+#define USE_STATVFS
+#define STATVFS_IN_SYS_STATVFS_H
+#define UNIX_DOMAIN_CONNECT_BLOCKS_FOR_ACCEPT
+#endif
+
+#ifdef UW21 /* UnixWare 2.1.x */
+#define SUPPORTED
+#include
+#define _PATH_MAILDIR "/var/mail"
+#define _PATH_BSHELL "/bin/sh"
+#define _PATH_DEFPATH "/usr/bin:/usr/ucb"
+#define _PATH_STDPATH "/usr/bin:/usr/sbin:/usr/ucb"
+#define MISSING_SETENV
+#define USE_FCNTL_LOCK
+#define USE_DOT_LOCK
+#define HAS_FSYNC
+#define HAS_DBM
+#define DEF_DB_TYPE "dbm"
+#define ALIAS_DB_MAP "dbm:/etc/mail/aliases"
+/* Uncomment the following line if you have NIS package installed
+#define HAS_NIS */
+#define USE_SYS_SOCKIO_H
+#define GETTIMEOFDAY(t) gettimeofday(t,NULL)
+#define ROOT_PATH "/bin:/usr/bin:/sbin:/usr/sbin:/usr/ucb"
+#define FIONREAD_IN_SYS_FILIO_H
+#define DBM_NO_TRAILING_NULL
+#define USE_STATVFS
+#define STATVFS_IN_SYS_STATVFS_H
+#define UNIX_DOMAIN_CONNECT_BLOCKS_FOR_ACCEPT
+#endif
+
+#ifdef AIX4
+#define SUPPORTED
+#include
+#define MISSING_SETENV
+#define _PATH_BSHELL "/bin/sh"
+#define _PATH_MAILDIR "/var/spool/mail" /* paths.h lies */
+#define _PATH_DEFPATH "/usr/bin:/usr/ucb"
+#define _PATH_STDPATH "/usr/bin:/usr/sbin:/usr/ucb"
+#define USE_FCNTL_LOCK
+#define USE_DOT_LOCK
+#define USE_SYS_SELECT_H
+#define HAS_FSYNC
+#define HAS_DBM
+#define DEF_DB_TYPE "dbm"
+#define ALIAS_DB_MAP "dbm:/etc/aliases"
+#define HAS_NIS
+#define HAS_SA_LEN
+#define GETTIMEOFDAY(t) gettimeofday(t,(struct timezone *) 0)
+#define RESOLVE_H_NEEDS_STDIO_H
+#define ROOT_PATH "/bin:/usr/bin:/sbin:/usr/sbin:/usr/ucb"
+#define SOCKADDR_SIZE size_t
+#define SOCKOPT_SIZE size_t
+#define USE_STATVFS
+#define STATVFS_IN_SYS_STATVFS_H
+#define STRCASECMP_IN_STRINGS_H
+extern time_t time(time_t *);
+extern int seteuid(uid_t);
+extern int setegid(gid_t);
+extern int initgroups(const char *, int);
+
+#endif
+
+#ifdef AIX3
+#define SUPPORTED
+#include
+#define MISSING_SETENV
+#define _PATH_BSHELL "/bin/sh"
+#define _PATH_MAILDIR "/var/spool/mail" /* paths.h lies */
+#define _PATH_DEFPATH "/usr/bin:/usr/ucb"
+#define _PATH_STDPATH "/usr/bin:/usr/sbin:/usr/ucb"
+#define USE_FCNTL_LOCK
+#define USE_DOT_LOCK
+#define USE_SYS_SELECT_H
+#define HAS_FSYNC
+#define HAS_DBM
+#define DEF_DB_TYPE "dbm"
+#define ALIAS_DB_MAP "dbm:/etc/aliases"
+#define HAS_NIS
+#define HAS_SA_LEN
+#define GETTIMEOFDAY(t) gettimeofday(t,(struct timezone *) 0)
+#define RESOLVE_H_NEEDS_STDIO_H
+#define ROOT_PATH "/bin:/usr/bin:/sbin:/usr/sbin:/usr/ucb"
+#define SOCKADDR_SIZE size_t
+#define SOCKOPT_SIZE size_t
+#define USE_STATFS
+#define STATFS_IN_SYS_STATFS_H
+#define STRCASECMP_IN_STRINGS_H
+extern time_t time(time_t *);
+extern int seteuid(uid_t);
+extern int setegid(gid_t);
+extern int initgroups(const char *, int);
+
+#endif
+
+#if defined(IRIX5) || defined(IRIX6)
+#define SUPPORTED
+#include
+#define MISSING_SETENV
+#define _PATH_MAILDIR "/var/mail"
+#define _PATH_BSHELL "/bin/sh"
+#define _PATH_DEFPATH "/usr/bin:/usr/bsd"
+#define _PATH_STDPATH "/usr/bin:/usr/sbin:/usr/bsd"
+#define USE_FCNTL_LOCK
+#define USE_DOT_LOCK
+#define HAS_FSYNC
+#define HAS_DBM
+#define DEF_DB_TYPE "dbm"
+#define ALIAS_DB_MAP "dbm:/etc/aliases"
+#define HAS_NIS
+#define USE_SYS_SOCKIO_H /* XXX check */
+#define GETTIMEOFDAY(t) gettimeofday(t)
+#define ROOT_PATH "/bin:/usr/bin:/sbin:/usr/sbin:/usr/bsd"
+#define FIONREAD_IN_SYS_FILIO_H /* XXX check */
+#define DBM_NO_TRAILING_NULL /* XXX check */
+#define USE_STATVFS
+#define STATVFS_IN_SYS_STATVFS_H
+#endif
+
+#if defined(IRIX5)
+#define MISSING_USLEEP
+#endif
+
+#ifdef LINUX2
+#define SUPPORTED
+#include
+#define USE_PATHS_H
+#define USE_FLOCK_LOCK
+#define USE_DOT_LOCK
+#define HAS_FSYNC
+#define HAS_DB
+#define DEF_DB_TYPE "hash"
+#define ALIAS_DB_MAP "hash:/etc/aliases"
+#define HAS_NIS
+#define GETTIMEOFDAY(t) gettimeofday(t,(struct timezone *) 0)
+#define ROOT_PATH "/bin:/usr/bin:/sbin:/usr/sbin"
+#define FIONREAD_IN_TERMIOS_H
+#define USE_STATFS
+#define STATFS_IN_SYS_VFS_H
+#define UNIX_DOMAIN_CONNECT_BLOCKS_FOR_ACCEPT
+#define PREPEND_PLUS_TO_OPTSTRING
+#define HAS_POSIX_REGEXP
+#endif
+
+ /*
+ * HPUX11 was copied from HPUX10, but can perhaps be trimmed down a bit.
+ */
+#ifdef HPUX11
+#define SUPPORTED
+#define USE_SIG_RETURN
+#include
+#define HAS_DBM
+#define USE_FCNTL_LOCK
+#define HAS_FSYNC
+#define DEF_DB_TYPE "dbm"
+#define ALIAS_DB_MAP "dbm:/etc/mail/aliases"
+#define ROOT_PATH "/usr/bin:/sbin:/usr/sbin"
+#define MISSING_SETENV
+#define HAS_NIS
+#define GETTIMEOFDAY(t) gettimeofday(t,(struct timezone *) 0)
+#define _PATH_BSHELL "/bin/sh"
+#define _PATH_MAILDIR "/var/mail"
+#define _PATH_DEFPATH "/usr/bin"
+#define _PATH_STDPATH "/usr/bin:/sbin:/usr/sbin"
+#define MISSING_SETEUID
+#define HAVE_SETRESUID
+#define MISSING_SETEGID
+#define HAVE_SETRESGID
+extern int h_errno; /* imports too much stuff */
+
+#define USE_STATFS
+#define STATFS_IN_SYS_VFS_H
+#define HAS_POSIX_REGEXP
+#endif
+
+#ifdef HPUX10
+#define SUPPORTED
+#define USE_SIG_RETURN
+#include
+#define HAS_DBM
+#define USE_FCNTL_LOCK
+#define HAS_FSYNC
+#define DEF_DB_TYPE "dbm"
+#define ALIAS_DB_MAP "dbm:/etc/mail/aliases"
+#define ROOT_PATH "/usr/bin:/sbin:/usr/sbin"
+#define MISSING_SETENV
+#define HAS_NIS
+#define GETTIMEOFDAY(t) gettimeofday(t,(struct timezone *) 0)
+#define _PATH_BSHELL "/bin/sh"
+#define _PATH_MAILDIR "/var/mail"
+#define _PATH_DEFPATH "/usr/bin"
+#define _PATH_STDPATH "/usr/bin:/sbin:/usr/sbin"
+#define MISSING_SETEUID
+#define HAVE_SETRESUID
+#define MISSING_SETEGID
+#define HAVE_SETRESGID
+extern int h_errno; /* imports too much stuff */
+
+#define USE_STATFS
+#define STATFS_IN_SYS_VFS_H
+#define HAS_POSIX_REGEXP
+#endif
+
+#ifdef HPUX9
+#define SUPPORTED
+#define USE_SIG_RETURN
+#include
+#define HAS_DBM
+#define USE_FCNTL_LOCK
+#define HAS_FSYNC
+#define HAS_NIS
+#define MISSING_SETENV
+#define MISSING_RLIMIT_FSIZE
+#define GETTIMEOFDAY(t) gettimeofday(t,(struct timezone *) 0)
+#define DEF_DB_TYPE "dbm"
+#define ALIAS_DB_MAP "dbm:/usr/lib/aliases"
+#define ROOT_PATH "/bin:/usr/bin:/etc"
+#define _PATH_BSHELL "/bin/sh"
+#define _PATH_MAILDIR "/usr/mail"
+#define _PATH_DEFPATH "/bin:/usr/bin"
+#define _PATH_STDPATH "/bin:/usr/bin:/etc"
+#define MISSING_SETEUID
+#define HAVE_SETRESUID
+#define MISSING_SETEGID
+#define HAVE_SETRESGID
+extern int h_errno;
+
+#define USE_ULIMIT /* no setrlimit() */
+#define USE_STATFS
+#define STATFS_IN_SYS_VFS_H
+#define HAS_POSIX_REGEXP
+#endif
+
+ /*
+ * NEXTSTEP3, without -lposix, because its naming service is broken.
+ */
+#ifdef NEXTSTEP3
+#define SUPPORTED
+#include
+#define HAS_DBM
+#define USE_FLOCK_LOCK
+#define USE_STATFS
+#define HAVE_SYS_DIR_H
+#define STATFS_IN_SYS_VFS_H
+#define HAS_FSYNC
+#define HAS_NIS
+#define HAS_NETINFO
+#define MISSING_SETENV_PUTENV
+#define MISSING_MKFIFO
+#define MISSING_SIGSET_T
+#define MISSING_SIGACTION
+#define MISSING_STD_FILENOS
+#define MISSING_SETSID
+#define MISSING_WAITPID
+#define MISSING_UTIMBUF
+#define HAS_WAIT4
+#define WAIT_STATUS_T union wait
+#define NORMAL_EXIT_STATUS(x) (WIFEXITED(x) && !WEXITSTATUS (x))
+#define GETTIMEOFDAY(t) gettimeofday(t,(struct timezone *) 0)
+#define _PATH_MAILDIR "/usr/spool/mail"
+#define _PATH_BSHELL "/bin/sh"
+#define _PATH_DEFPATH "/bin:/usr/bin:/usr/ucb"
+#define _PATH_STDPATH "/bin:/usr/bin:/usr/ucb"
+#define ROOT_PATH "/bin:/usr/bin:/usr/etc:/usr/ucb"
+#define DEF_DB_TYPE "dbm"
+#define ALIAS_DB_MAP "netinfo:/aliases"
+#include
+#define MISSING_POSIX_S_IS
+#define MISSING_POSIX_S_MODES
+/* It's amazing what is all missing... */
+#define isascii(c) ((unsigned)(c)<=0177)
+extern int opterr;
+
+#define MISSING_PID_T
+#define MISSING_STRFTIME_E
+#define FD_CLOEXEC 1
+#define O_NONBLOCK O_NDELAY
+#define WEXITSTATUS(x) ((x).w_retcode)
+#define WTERMSIG(x) ((x).w_termsig)
+#endif
+
+ /*
+ * OPENSTEP does not have posix (some fix...)
+ */
+#ifdef OPENSTEP4
+#define SUPPORTED
+#include
+#define HAS_DBM
+#define USE_FLOCK_LOCK
+#define USE_STATFS
+#define HAVE_SYS_DIR_H
+#define STATFS_IN_SYS_VFS_H
+#define HAS_FSYNC
+#define HAS_NIS
+#define HAS_NETINFO
+#define MISSING_SETENV_PUTENV
+#define MISSING_MKFIFO
+#define MISSING_SIGSET_T
+#define MISSING_SIGACTION
+#define MISSING_STD_FILENOS
+#define MISSING_SETSID
+#define MISSING_WAITPID
+#define MISSING_UTIMBUF
+#define HAS_WAIT4
+#define WAIT_STATUS_T union wait
+#define NORMAL_EXIT_STATUS(x) (WIFEXITED(x) && !WEXITSTATUS (x))
+#define GETTIMEOFDAY(t) gettimeofday(t,(struct timezone *) 0)
+#define _PATH_MAILDIR "/usr/spool/mail"
+#define _PATH_BSHELL "/bin/sh"
+#define _PATH_DEFPATH "/bin:/usr/bin:/usr/ucb"
+#define _PATH_STDPATH "/bin:/usr/bin:/usr/ucb"
+#define ROOT_PATH "/bin:/usr/bin:/usr/etc:/usr/ucb"
+#define DEF_DB_TYPE "dbm"
+#define ALIAS_DB_MAP "netinfo:/aliases"
+#include
+#define MISSING_POSIX_S_IS
+#define MISSING_POSIX_S_MODES
+/* It's amazing what is all missing... */
+#define isascii(c) ((unsigned)(c)<=0177)
+extern int opterr;
+
+#define MISSING_PID_T
+#define MISSING_STRFTIME_E
+#define FD_CLOEXEC 1
+#define O_NONBLOCK O_NDELAY
+#define WEXITSTATUS(x) ((x).w_retcode)
+#define WTERMSIG(x) ((x).w_termsig)
+#define NORETURN /* the native compiler */
+#endif
+
+#ifdef ReliantUnix543
+#define SUPPORTED
+#include
+#define MISSING_SETENV
+#define _PATH_DEFPATH "/usr/bin:/usr/ucb"
+#define _PATH_BSHELL "/bin/sh"
+#define _PATH_MAILDIR "/var/spool/mail"
+#define USE_FCNTL_LOCK
+#define USE_DOT_LOCK
+#define HAS_FSYNC
+#define FIONREAD_IN_SYS_FILIO_H
+#define USE_SYS_SOCKIO_H
+#define HAS_DBM
+#define DEF_DB_TYPE "dbm"
+#define ALIAS_DB_MAP "dbm:/var/adm/sendmail/aliases"
+extern int optind; /* XXX use */
+extern char *optarg; /* XXX use */
+extern int opterr; /* XXX use */
+
+#define HAS_NIS
+#define GETTIMEOFDAY(t) gettimeofday(t)
+#define ROOT_PATH "/bin:/usr/bin:/sbin:/usr/sbin:/usr/ucb"
+#define USE_STATVFS
+#define STATVFS_IN_SYS_STATVFS_H
+#define MISSING_USLEEP
+#endif
+
+ /*
+ * We're not going to try to guess like configure does.
+ */
+#ifndef SUPPORTED
+#error "unsupported platform"
+#endif
+
+#ifdef DUP2_DUPS_CLOSE_ON_EXEC
+/* dup2_pass_on_exec() can be found in util/sys_compat.c */
+extern int dup2_pass_on_exec(int oldd, int newd);
+
+#define DUP2 dup2_pass_on_exec
+#else
+#define DUP2 dup2
+#endif
+
+#ifdef PREPEND_PLUS_TO_OPTSTRING
+#define GETOPT(argc, argv, str) getopt((argc), (argv), "+" str)
+#else
+#define GETOPT(argc, argv, str) getopt((argc), (argv), (str))
+#endif
+#define OPTIND (optind > 0 ? optind : 1)
+
+#if defined(USE_FCNTL_LOCK) && defined(USE_FLOCK_LOCK)
+#error "define USE_FCNTL_LOCK or USE_FLOCK_LOCK, not both"
+#endif
+
+#if !defined(USE_FCNTL_LOCK) && !defined(USE_FLOCK_LOCK)
+#error "define USE_FCNTL_LOCK or USE_FLOCK_LOCK"
+#endif
+
+#if defined(USE_STATFS) && defined(USE_STATVFS)
+#error "define USE_STATFS or USE_STATVFS, not both"
+#endif
+
+#if !defined(USE_STATFS) && !defined(USE_STATVFS)
+#error "define USE_STATFS or USE_STATVFS"
+#endif
+
+ /*
+ * Defaults for normal systems.
+ */
+#ifndef SOCKADDR_SIZE
+#define SOCKADDR_SIZE int
+#endif
+
+#ifndef SOCKOPT_SIZE
+#define SOCKOPT_SIZE int
+#endif
+
+#ifndef LOCAL_LISTEN
+#define LOCAL_LISTEN unix_listen
+#define LOCAL_ACCEPT unix_accept
+#define LOCAL_CONNECT unix_connect
+#define LOCAL_TRIGGER unix_trigger
+#endif
+
+#if !defined (HAVE_SYS_NDIR_H) && !defined (HAVE_SYS_DIR_H) \
+ && !defined (HAVE_NDIR_H)
+#define HAVE_DIRENT_H
+#endif
+
+#ifndef WAIT_STATUS_T
+typedef int WAIT_STATUS_T;
+
+#define NORMAL_EXIT_STATUS(status) ((status) == 0)
+#endif
+
+ /*
+ * Turn on the compatibility stuff.
+ */
+#ifdef MISSING_UTIMBUF
+struct utimbuf {
+ time_t actime;
+ time_t modtime;
+};
+
+#endif
+
+#ifdef MISSING_STRERROR
+extern const char *strerror(int);
+
+#endif
+
+#if defined (MISSING_SETENV) || defined (MISSING_SETENV_PUTENV)
+extern int setenv(const char *, const char *, int);
+
+#endif
+
+#ifdef MISSING_SETEUID
+extern int seteuid(uid_t euid);
+
+#endif
+
+#ifdef MISSING_SETEGID
+extern int setegid(gid_t egid);
+
+#endif
+
+#ifdef MISSING_MKFIFO
+extern int mkfifo(char *, int);
+
+#endif
+
+#ifdef MISSING_WAITPID
+extern int waitpid(int, WAIT_STATUS_T *status, int options);
+
+#endif
+
+#ifdef MISSING_SETSID
+extern int setsid(void);
+
+#endif
+
+#ifdef MISSING_STD_FILENOS
+#define STDIN_FILENO 0
+#define STDOUT_FILENO 1
+#define STDERR_FILENO 2
+#endif
+
+#ifdef MISSING_PID_T
+typedef int pid_t;
+
+#endif
+
+#ifdef MISSING_POSIX_S_IS
+#define S_ISBLK(mode) (((mode) & (_S_IFMT)) == (_S_IFBLK))
+#define S_ISCHR(mode) (((mode) & (_S_IFMT)) == (_S_IFCHR))
+#define S_ISDIR(mode) (((mode) & (_S_IFMT)) == (_S_IFDIR))
+#define S_ISSOCK(mode) (((mode) & (_S_IFMT)) == (_S_IFSOCK))
+#define S_ISFIFO(mode) (((mode) & (_S_IFMT)) == (_S_IFIFO))
+#define S_ISREG(mode) (((mode) & (_S_IFMT)) == (_S_IFREG))
+#endif
+
+#ifdef MISSING_POSIX_S_MODES
+#define S_IRUSR _S_IRUSR
+#define S_IRGRP 0000040
+#define S_IROTH 0000004
+#define S_IWUSR _S_IWUSR
+#define S_IWGRP 0000020
+#define S_IWOTH 0000002
+#define S_IXUSR _S_IXUSR
+#define S_IXGRP 0000010
+#define S_IXOTH 0000001
+#define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
+#endif
+
+ /*
+ * Need to specify what functions never return, so that the compiler can
+ * warn for missing initializations and other trouble. However, OPENSTEP4
+ * gcc 2.7.x cannot handle this so we define this only if NORETURN isn't
+ * already defined above.
+ */
+#ifndef NORETURN
+#if __GNUC__ == 2 && __GNUC_MINOR__ >= 5 || __GNUC__ >= 3
+#define NORETURN void __attribute__((__noreturn__))
+#endif
+#endif
+
+#ifndef NORETURN
+#define NORETURN void
+#endif
+
+ /*
+ * Making the ctype.h macros not more expensive than necessary. On some
+ * systems, ctype.h misbehaves badly with signed characters.
+ */
+#define _UCHAR_(c) ((unsigned char)(c))
+#ifdef UNSAFE_CTYPE
+#define ISASCII(c) isascii(_UCHAR_(c))
+#define ISALNUM(c) (ISASCII(c) && isalnum(c))
+#define ISALPHA(c) (ISASCII(c) && isalpha(c))
+#define ISCNTRL(c) (ISASCII(c) && iscntrl(c))
+#define ISDIGIT(c) (ISASCII(c) && isdigit(c))
+#define ISGRAPH(c) (ISASCII(c) && isgraph(c))
+#define ISLOWER(c) (ISASCII(c) && islower(c))
+#define ISPRINT(c) (ISASCII(c) && isprint(c))
+#define ISPUNCT(c) (ISASCII(c) && ispunct(c))
+#define ISSPACE(c) (ISASCII(c) && isspace(c))
+#define ISUPPER(c) (ISASCII(c) && isupper(c))
+#define TOLOWER(c) (ISUPPER(c) ? tolower(c) : (c))
+#define TOUPPER(c) (ISLOWER(c) ? toupper(c) : (c))
+#else
+#define ISASCII(c) isascii(_UCHAR_(c))
+#define ISALNUM(c) isalnum(_UCHAR_(c))
+#define ISALPHA(c) isalpha(_UCHAR_(c))
+#define ISCNTRL(c) iscntrl(_UCHAR_(c))
+#define ISDIGIT(c) isdigit(_UCHAR_(c))
+#define ISGRAPH(c) isgraph(_UCHAR_(c))
+#define ISLOWER(c) islower(_UCHAR_(c))
+#define ISPRINT(c) isprint(_UCHAR_(c))
+#define ISPUNCT(c) ispunct(_UCHAR_(c))
+#define ISSPACE(c) isspace(_UCHAR_(c))
+#define ISUPPER(c) isupper(_UCHAR_(c))
+#define TOLOWER(c) tolower(_UCHAR_(c))
+#define TOUPPER(c) toupper(_UCHAR_(c))
+#endif
+
+ /*
+ * Scaffolding. I don't want to lose messages while the program is under
+ * development.
+ */
+extern int REMOVE(const char *);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/timed_connect.h b/postfix/include/timed_connect.h
new file mode 100644
index 000000000..76ac7159c
--- /dev/null
+++ b/postfix/include/timed_connect.h
@@ -0,0 +1,31 @@
+#ifndef _TIMED_CONNECT_H_INCLUDED_
+#define _TIMED_CONNECT_H_INCLUDED_
+
+/*++
+/* NAME
+/* timed_connect 3h
+/* SUMMARY
+/* connect operation with timeout
+/* SYNOPSIS
+/* #include
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /*
+ * External interface.
+ */
+extern int timed_connect(int, struct sockaddr *, int, int);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/timed_wait.h b/postfix/include/timed_wait.h
new file mode 100644
index 000000000..bdbc270c6
--- /dev/null
+++ b/postfix/include/timed_wait.h
@@ -0,0 +1,30 @@
+#ifndef _TIMED_WAIT_H_INCLUDED_
+#define _TIMED_WAIT_H_INCLUDED_
+
+/*++
+/* NAME
+/* timed_wait 3h
+/* SUMMARY
+/* wait operations with timeout
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /*
+ * External interface.
+ */
+extern int timed_waitpid(pid_t, WAIT_STATUS_T *, int, int);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/trigger.h b/postfix/include/trigger.h
new file mode 100644
index 000000000..ffcf63c52
--- /dev/null
+++ b/postfix/include/trigger.h
@@ -0,0 +1,33 @@
+#ifndef _TRIGGER_H_INCLUDED_
+#define _TRIGGER_H_INCLUDED_
+
+/*++
+/* NAME
+/* trigger 3h
+/* SUMMARY
+/* client interface file
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /*
+ * External interface.
+ */
+extern int unix_trigger(const char *, const char *, int, int);
+extern int inet_trigger(const char *, const char *, int, int);
+extern int fifo_trigger(const char *, const char *, int, int);
+extern int stream_trigger(const char *, const char *, int, int);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/username.h b/postfix/include/username.h
new file mode 100644
index 000000000..648be45e6
--- /dev/null
+++ b/postfix/include/username.h
@@ -0,0 +1,29 @@
+#ifndef _USERNAME_H_INCLUDED_
+#define _USERNAME_H_INCLUDED_
+
+/*++
+/* NAME
+/* username 3h
+/* SUMMARY
+/* lookup name of real user
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /* External interface. */
+
+extern const char *username(void);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/valid_hostname.h b/postfix/include/valid_hostname.h
new file mode 100644
index 000000000..69db14056
--- /dev/null
+++ b/postfix/include/valid_hostname.h
@@ -0,0 +1,33 @@
+#ifndef _VALID_HOSTNAME_H_INCLUDED_
+#define _VALID_HOSTNAME_H_INCLUDED_
+
+/*++
+/* NAME
+/* valid_hostname 3h
+/* SUMMARY
+/* validate hostname
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /* External interface */
+
+#define VALID_HOSTNAME_LEN 255 /* RFC 1035 */
+#define VALID_LABEL_LEN 63 /* RFC 1035 */
+
+extern int valid_hostname(const char *);
+extern int valid_hostaddr(const char *);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/vbuf.h b/postfix/include/vbuf.h
new file mode 100644
index 000000000..57aa6f6f9
--- /dev/null
+++ b/postfix/include/vbuf.h
@@ -0,0 +1,98 @@
+#ifndef _VBUF_H_INCLUDED_
+#define _VBUF_H_INCLUDED_
+
+/*++
+/* NAME
+/* vbuf 3h
+/* SUMMARY
+/* generic buffer
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /*
+ * The VBUF buffer is defined by 1) its structure, by 2) the VBUF_GET() and
+ * 3) VBUF_PUT() operations that automatically handle buffer empty and
+ * buffer full conditions, and 4) by the VBUF_SPACE() operation that allows
+ * the user to reserve buffer space ahead of time, to allow for situations
+ * where calling VBUF_PUT() is not possible or desirable.
+ *
+ * The VBUF buffer does not specify primitives for memory allocation or
+ * deallocation. The purpose is to allow different applications to have
+ * different strategies: a memory-resident buffer; a memory-mapped file; or
+ * a stdio-like window to an open file. Each application provides its own
+ * get(), put() and space() methods that perform the necessary magic.
+ *
+ * This interface is pretty normal. With one exception: the number of bytes
+ * left to read is negated. This is done so that we can change direction
+ * between reading and writing on the fly.
+ */
+typedef struct VBUF VBUF;
+typedef int (*VBUF_GET_READY_FN) (VBUF *);
+typedef int (*VBUF_PUT_READY_FN) (VBUF *);
+typedef int (*VBUF_SPACE_FN) (VBUF *, int);
+
+struct VBUF {
+ int flags; /* status, see below */
+ unsigned char *data; /* variable-length buffer */
+ int len; /* buffer length */
+ int cnt; /* bytes left to read/write */
+ unsigned char *ptr; /* read/write position */
+ VBUF_GET_READY_FN get_ready; /* read buffer empty action */
+ VBUF_PUT_READY_FN put_ready; /* write buffer full action */
+ VBUF_SPACE_FN space; /* request for buffer space */
+};
+
+ /*
+ * Typically, an application will embed a VBUF structure into a larger
+ * structure that also contains application-specific members. This approach
+ * gives us the best of both worlds. The application can still use the
+ * generic VBUF primitives for reading and writing VBUFs. The macro below
+ * transforms a pointer from VBUF structure to the structure that contains
+ * it.
+ */
+#define VBUF_TO_APPL(vbuf_ptr,app_type,vbuf_member) \
+ ((app_type *) (((char *) (vbuf_ptr)) - offsetof(app_type,vbuf_member)))
+
+ /*
+ * Buffer status management.
+ */
+#define VBUF_FLAG_ERR (1<<0) /* some I/O error */
+#define VBUF_FLAG_EOF (1<<1) /* end of data */
+#define VBUF_FLAG_BAD (VBUF_FLAG_ERR | VBUF_FLAG_EOF)
+#define VBUF_FLAG_FIXED (1<<2) /* fixed-size buffer */
+
+#define vbuf_error(v) ((v)->flags & VBUF_FLAG_ERR)
+#define vbuf_eof(v) ((v)->flags & VBUF_FLAG_EOF)
+#define vbuf_clearerr(v) ((v)->flags &= ~VBUF_FLAG_BAD)
+
+ /*
+ * Buffer I/O-like operations and results.
+ */
+#define VBUF_GET(v) ((v)->cnt < 0 ? ++(v)->cnt, \
+ (int) *(v)->ptr++ : vbuf_get(v))
+#define VBUF_PUT(v,c) ((v)->cnt > 0 ? --(v)->cnt, \
+ (int) (*(v)->ptr++ = (c)) : vbuf_put((v),(c)))
+#define VBUF_SPACE(v,n) ((v)->space((v),(n)))
+
+#define VBUF_EOF (-1) /* no more space or data */
+
+extern int vbuf_get(VBUF *);
+extern int vbuf_put(VBUF *, int);
+extern int vbuf_unget(VBUF *, int);
+extern int vbuf_read(VBUF *, char *, int);
+extern int vbuf_write(VBUF *, const char *, int);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/vbuf_print.h b/postfix/include/vbuf_print.h
new file mode 100644
index 000000000..32549c142
--- /dev/null
+++ b/postfix/include/vbuf_print.h
@@ -0,0 +1,40 @@
+#ifndef _VBUF_PRINT_H_INCLUDED_
+#define _VBUF_PRINT_H_INCLUDED_
+
+/*++
+/* NAME
+/* vbuf_print 3h
+/* SUMMARY
+/* formatted print to generic buffer
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /*
+ * System library.
+ */
+#include
+
+ /*
+ * Utility library.
+ */
+#include
+
+ /*
+ * External interface.
+ */
+extern VBUF *vbuf_print(VBUF *, const char *, va_list);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/vstream.h b/postfix/include/vstream.h
new file mode 100644
index 000000000..d67ee2377
--- /dev/null
+++ b/postfix/include/vstream.h
@@ -0,0 +1,135 @@
+#ifndef _VSTREAM_H_INCLUDED_
+#define _VSTREAM_H_INCLUDED_
+
+/*++
+/* NAME
+/* vstream 3h
+/* SUMMARY
+/* simple buffered I/O package
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+/* .nf
+
+ /*
+ * System library.
+ */
+#include
+#include
+
+ /*
+ * Utility library.
+ */
+#include
+
+ /*
+ * Simple buffered stream. The members of this structure are not part of the
+ * official interface and can change without prior notice.
+ */
+typedef int (*VSTREAM_FN) (int, void *, unsigned);
+typedef int (*VSTREAM_WAITPID_FN) (pid_t, WAIT_STATUS_T *, int);
+
+typedef struct VSTREAM {
+ VBUF buf; /* generic intelligent buffer */
+ int fd; /* file handle, no 256 limit */
+ VSTREAM_FN read_fn; /* buffer fill action */
+ VSTREAM_FN write_fn; /* buffer fill action */
+ long offset; /* cached seek info */
+ char *path; /* give it at least try */
+ int read_fd; /* read channel (double-buffered) */
+ int write_fd; /* write channel (double-buffered) */
+ VBUF read_buf; /* read buffer (double-buffered) */
+ VBUF write_buf; /* write buffer (double-buffered) */
+ pid_t pid; /* vstream_popen/close() */
+ VSTREAM_WAITPID_FN waitpid_fn; /* vstream_popen/close() */
+} VSTREAM;
+
+extern VSTREAM vstream_fstd[]; /* pre-defined streams */
+
+#define VSTREAM_IN (&vstream_fstd[0])
+#define VSTREAM_OUT (&vstream_fstd[1])
+#define VSTREAM_ERR (&vstream_fstd[2])
+
+#define VSTREAM_FLAG_ERR VBUF_FLAG_ERR /* some I/O error */
+#define VSTREAM_FLAG_EOF VBUF_FLAG_EOF /* end of file */
+#define VSTREAM_FLAG_FIXED VBUF_FLAG_FIXED /* fixed-size buffer */
+#define VSTREAM_FLAG_BAD VBUF_FLAG_BAD
+
+#define VSTREAM_FLAG_READ (1<<8) /* read buffer */
+#define VSTREAM_FLAG_WRITE (1<<9) /* write buffer */
+#define VSTREAM_FLAG_SEEK (1<<10) /* seek info valid */
+#define VSTREAM_FLAG_NSEEK (1<<11) /* can't seek this file */
+#define VSTREAM_FLAG_DOUBLE (1<<12) /* double buffer */
+
+#define VSTREAM_BUFSIZE 4096
+
+extern VSTREAM *vstream_fopen(const char *, int, int);
+extern int vstream_fclose(VSTREAM *);
+extern long vstream_fseek(VSTREAM *, long, int);
+extern long vstream_ftell(VSTREAM *);
+extern int vstream_fflush(VSTREAM *);
+extern int vstream_fputs(const char *, VSTREAM *);
+extern VSTREAM *vstream_fdopen(int, int);
+
+#define vstream_fread(v, b, n) vbuf_read(&(v)->buf, (b), (n))
+#define vstream_fwrite(v, b, n) vbuf_write(&(v)->buf, (b), (n))
+
+#define VSTREAM_PUTC(ch, vp) VBUF_PUT(&(vp)->buf, (ch))
+#define VSTREAM_GETC(vp) VBUF_GET(&(vp)->buf)
+#define vstream_ungetc(vp, ch) vbuf_unget(&(vp)->buf, (ch))
+#define VSTREAM_EOF VBUF_EOF
+
+#define VSTREAM_PUTCHAR(ch) VSTREAM_PUTC((ch), VSTREAM_OUT)
+#define VSTREAM_GETCHAR() VSTREAM_GETC(VSTREAM_IN)
+
+#define vstream_fileno(vp) ((vp)->fd)
+#define vstream_ferror(vp) vbuf_error(&(vp)->buf)
+#define vstream_feof(vp) vbuf_eof(&(vp)->buf)
+#define vstream_clearerr(vp) vbuf_clearerr(&(vp)->buf)
+#define VSTREAM_PATH(vp) ((vp)->path ? (vp)->path : "unknown_stream")
+
+extern void vstream_control(VSTREAM *, int,...);
+
+#define VSTREAM_CTL_END 0
+#define VSTREAM_CTL_READ_FN 1
+#define VSTREAM_CTL_WRITE_FN 2
+#define VSTREAM_CTL_PATH 3
+#define VSTREAM_CTL_DOUBLE 4
+#define VSTREAM_CTL_READ_FD 5
+#define VSTREAM_CTL_WRITE_FD 6
+#define VSTREAM_CTL_WAITPID_FN 7
+
+extern VSTREAM *vstream_printf(const char *,...);
+extern VSTREAM *vstream_fprintf(VSTREAM *, const char *,...);
+
+extern VSTREAM *vstream_popen(const char *, int);
+extern VSTREAM *vstream_popen_vargs(int,...);
+extern int vstream_pclose(VSTREAM *);
+
+#define vstream_ispipe(vp) ((vp)->pid != 0)
+
+#define VSTREAM_POPEN_END 0 /* terminator */
+#define VSTREAM_POPEN_COMMAND 1 /* command is string */
+#define VSTREAM_POPEN_ARGV 2 /* command is array */
+#define VSTREAM_POPEN_UID 3 /* privileges */
+#define VSTREAM_POPEN_GID 4 /* privileges */
+#define VSTREAM_POPEN_ENV 5 /* extra environment */
+#define VSTREAM_POPEN_SHELL 6 /* alternative shell */
+#define VSTREAM_POPEN_WAITPID_FN 7 /* child catcher, waitpid() compat. */
+
+extern VSTREAM *vstream_vfprintf(VSTREAM *, const char *, va_list);
+
+extern int vstream_peek(VSTREAM *);
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/vstring.h b/postfix/include/vstring.h
new file mode 100644
index 000000000..4d4a972bf
--- /dev/null
+++ b/postfix/include/vstring.h
@@ -0,0 +1,98 @@
+#ifndef _VSTRING_H_INCLUDED_
+#define _VSTRING_H_INCLUDED_
+
+/*++
+/* NAME
+/* vstring 3h
+/* SUMMARY
+/* arbitrary-length string manager
+/* SYNOPSIS
+/* #include "vstring.h"
+/* DESCRIPTION
+/* .nf
+
+ /*
+ * System library.
+ */
+#include
+
+ /*
+ * Utility library.
+ */
+#include
+
+ /*
+ * We can't allow bare VBUFs in the interface, because VSTRINGs have a
+ * specific initialization and destruction sequence.
+ */
+typedef struct VSTRING {
+ VBUF vbuf;
+ int maxlen;
+} VSTRING;
+
+extern void vstring_init(VSTRING *, int);
+extern void vstring_wipe(VSTRING *);
+extern VSTRING *vstring_alloc(int);
+extern void vstring_ctl(VSTRING *,...);
+extern VSTRING *vstring_truncate(VSTRING *, int);
+extern VSTRING *vstring_free(VSTRING *);
+extern VSTRING *vstring_strcpy(VSTRING *, const char *);
+extern VSTRING *vstring_strncpy(VSTRING *, const char *, int);
+extern VSTRING *vstring_strcat(VSTRING *, const char *);
+extern VSTRING *vstring_strncat(VSTRING *, const char *, int);
+extern VSTRING *vstring_sprintf(VSTRING *, const char *,...);
+extern VSTRING *vstring_sprintf_append(VSTRING *, const char *,...);
+extern char *vstring_export(VSTRING *);
+extern VSTRING *vstring_import(char *);
+
+#define VSTRING_CTL_MAXLEN 1
+#define VSTRING_CTL_END 0
+
+ /*
+ * Macros. Unsafe macros have UPPERCASE names.
+ */
+#define VSTRING_SPACE(vp, len) ((vp)->vbuf.space(&(vp)->vbuf, len))
+#define vstring_str(vp) ((char *) (vp)->vbuf.data)
+#define VSTRING_LEN(vp) ((vp)->vbuf.ptr - (vp)->vbuf.data)
+#define vstring_end(vp) ((char *) (vp)->vbuf.ptr)
+#define VSTRING_TERMINATE(vp) { if ((vp)->vbuf.cnt <= 0) \
+ VSTRING_SPACE((vp),1); \
+ *(vp)->vbuf.ptr = 0; }
+#define VSTRING_RESET(vp) { (vp)->vbuf.ptr = (vp)->vbuf.data; \
+ (vp)->vbuf.cnt = (vp)->vbuf.len; }
+#define VSTRING_ADDCH(vp, ch) VBUF_PUT(&(vp)->vbuf, ch)
+#define VSTRING_SKIP(vp) { while ((vp)->vbuf.cnt > 0 && *(vp)->vbuf.ptr) \
+ (vp)->vbuf.ptr++, (vp)->vbuf.cnt--; }
+#define vstring_avail(vp) ((vp)->vbuf.cnt)
+
+ /*
+ * The following macro is not part of the public interface, because it can
+ * really screw up a buffer by positioning past allocated memory.
+ */
+#define VSTRING_AT_OFFSET(vp, offset) { \
+ (vp)->vbuf.ptr = (vp)->vbuf.data + (offset); \
+ (vp)->vbuf.cnt = (vp)->vbuf.len - (offset); \
+ }
+
+extern VSTRING *vstring_vsprintf(VSTRING *, const char *, va_list);
+extern VSTRING *vstring_vsprintf_append(VSTRING *, const char *, va_list);
+
+/* BUGS
+/* Auto-resizing may change the address of the string data in
+/* a vstring structure. Beware of dangling pointers.
+/* HISTORY
+/* .ad
+/* .fi
+/* A vstring module appears in the UNPROTO software by Wietse Venema.
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/include/vstring_vstream.h b/postfix/include/vstring_vstream.h
new file mode 100644
index 000000000..897167ca6
--- /dev/null
+++ b/postfix/include/vstring_vstream.h
@@ -0,0 +1,54 @@
+#ifndef _VSTRING_VSTREAM_H_INCLUDED_
+#define _VSTRING_VSTREAM_H_INCLUDED_
+
+/*++
+/* NAME
+/* vstring_vstream 3h
+/* SUMMARY
+/* auto-resizing string library
+/* SYNOPSIS
+/* #include
+/* DESCRIPTION
+
+ /*
+ * Utility library.
+ */
+#include
+#include
+
+ /*
+ * External interface.
+ */
+extern int vstring_get(VSTRING *, VSTREAM *);
+extern int vstring_get_nonl(VSTRING *, VSTREAM *);
+extern int vstring_get_null(VSTRING *, VSTREAM *);
+extern int vstring_get_bound(VSTRING *, VSTREAM *, int);
+extern int vstring_get_nonl_bound(VSTRING *, VSTREAM *, int);
+
+ /*
+ * Backwards compatibility for code that still uses the vstring_fgets()
+ * interface. Unfortunately we can't change the macro name to upper case.
+ */
+#define vstring_fgets(s, p) \
+ (vstring_get((s), (p)) == VSTREAM_EOF ? 0 : (s))
+#define vstring_fgets_nonl(s, p) \
+ (vstring_get_nonl((s), (p)) == VSTREAM_EOF ? 0 : (s))
+#define vstring_fgets_null(s, p) \
+ (vstring_get_null((s), (p)) == VSTREAM_EOF ? 0 : (s))
+#define vstring_fgets_bound(s, p, l) \
+ (vstring_get_bound((s), (p), (l)) == VSTREAM_EOF ? 0 : (s))
+#define vstring_fgets_nonl_bound(s, p, l) \
+ (vstring_get_nonl_bound((s), (p), (l)) == VSTREAM_EOF ? 0 : (s))
+
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+#endif
diff --git a/postfix/lib/.pure b/postfix/lib/.pure
new file mode 100644
index 000000000..e69de29bb
diff --git a/postfix/local/feature.c b/postfix/local/feature.c
new file mode 100644
index 000000000..1a1db60f4
--- /dev/null
+++ b/postfix/local/feature.c
@@ -0,0 +1,91 @@
+/*++
+/* NAME
+/* feature 3
+/* SUMMARY
+/* toggle features depending on address
+/* SYNOPSIS
+/* #include "local.h"
+/*
+/* int feature_control(state)
+/* LOCAL_STATE state;
+/* DESCRIPTION
+/* feature_control() breaks the localpart of the recipient
+/* address up into fields, according to the recipient feature
+/* delimiter, and turns on/off the features as encountered.
+/*
+/* Arguments:
+/* .IP state
+/* The attributes that specify the message, recipient and more.
+/* Attributes describing the alias, include or forward expansion.
+/* A table with the results from expanding aliases or lists.
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* IBM T.J. Watson Research
+/* P.O. Box 704
+/* Yorktown Heights, NY 10598, USA
+/*--*/
+
+/* System library. */
+
+#include
+#include
+
+#ifdef STRCASECMP_IN_STRINGS_H
+#include
+#endif
+
+/* Utility library. */
+
+#include
+#include
+#include
+
+/* Global library. */
+
+#include
+
+/* Application-specific. */
+
+#include "local.h"
+
+struct feature_map {
+ char *name;
+ int mask;
+};
+
+static struct feature_map feature_map[] = {
+ "nodelivered", FEATURE_NODELIVERED,
+ 0,
+};
+
+/* feature_control - extract delivery options from recipient localpart */
+
+int feature_control(const char *localpart)
+{
+ struct feature_map *mp;
+ char *saved_localpart;
+ char *ptr;
+ int mask = 0;
+ char *cp;
+
+ if (*var_rcpt_fdelim) {
+ ptr = saved_localpart = mystrdup(localpart);
+ while ((cp = mystrtok(&ptr, var_rcpt_fdelim)) != 0) {
+ for (mp = feature_map; mp->name; mp++)
+ if (strcasecmp(mp->name, cp) == 0) {
+ if (msg_verbose)
+ msg_info("feature: %s", mp->name);
+ mask |= mp->mask;
+ break;
+ }
+ }
+ myfree(saved_localpart);
+ }
+ if (msg_verbose)
+ msg_info("features: 0x%x", mask);
+ return (mask);
+}
diff --git a/postfix/local/local.c b/postfix/local/local.c
index d42223b51..90c6ff84d 100644
--- a/postfix/local/local.c
+++ b/postfix/local/local.c
@@ -43,6 +43,7 @@
/* Characters that may have special meaning to the shell or file system
/* are replaced by underscores. The list of acceptable characters
/* is specified with the \fBforward_expansion_filter\fR configuration
+/* parameter.
/*
/* An alias or ~/.\fBforward\fR file may list any combination of external
/* commands, destination file names, \fB:include:\fR directives, or
diff --git a/postfix/pickup/pickup.c b/postfix/pickup/pickup.c
index c074ae27b..cbcd8ec54 100644
--- a/postfix/pickup/pickup.c
+++ b/postfix/pickup/pickup.c
@@ -231,8 +231,6 @@ static int pickup_copy(VSTREAM *qfile, VSTREAM *cleanup,
* If the segment contains a recipient address, include the optional
* always_bcc recipient.
*/
- info->sender = 0;
- info->rcpt = 0;
if ((status = copy_segment(qfile, cleanup, info, buf, REC_TYPE_ENVELOPE)) != 0)
return (status);
if (info->sender == 0) {
@@ -241,12 +239,10 @@ static int pickup_copy(VSTREAM *qfile, VSTREAM *cleanup,
}
msg_info("%s: uid=%d from=<%s>", info->id,
(int) info->st.st_uid, info->sender);
- myfree(info->sender);
if (info->rcpt) {
if (*var_always_bcc)
rec_fputs(cleanup, REC_TYPE_RCPT, var_always_bcc);
- myfree(info->rcpt);
}
/*
@@ -361,10 +357,31 @@ static int pickup_file(PICKUP_INFO *info)
vstream_fclose(qfile);
vstream_fclose(cleanup);
vstring_free(buf);
- myfree(info->id);
return (status);
}
+/* pickup_init - init info structure */
+
+static void pickup_init(PICKUP_INFO *info)
+{
+ info->id = 0;
+ info->path = 0;
+ info->sender = 0;
+ info->rcpt = 0;
+}
+
+/* pickup_free - wipe info structure */
+
+static void pickup_free(PICKUP_INFO *info)
+{
+#define SAFE_FREE(x) { if (x) myfree(x); }
+
+ SAFE_FREE(info->id);
+ SAFE_FREE(info->path);
+ SAFE_FREE(info->sender);
+ SAFE_FREE(info->rcpt);
+}
+
/* pickup_service - service client */
static void pickup_service(char *unused_buf, int unused_len,
@@ -395,6 +412,7 @@ static void pickup_service(char *unused_buf, int unused_len,
scan = scan_dir_open(queue_name);
while ((id = scan_dir_next(scan)) != 0) {
if (mail_open_ok(queue_name, id, &info.st, &path) == MAIL_OPEN_YES) {
+ pickup_init(&info);
info.path = mystrdup(path);
if (pickup_file(&info) == REMOVE_MESSAGE_FILE) {
if (REMOVE(info.path))
@@ -402,7 +420,7 @@ static void pickup_service(char *unused_buf, int unused_len,
else
file_count++;
}
- myfree(info.path);
+ pickup_free(&info);
}
}
scan_dir_close(scan);
diff --git a/postfix/postalias/postalias.c b/postfix/postalias/postalias.c
index a80d8262d..5a305453f 100644
--- a/postfix/postalias/postalias.c
+++ b/postfix/postalias/postalias.c
@@ -276,7 +276,7 @@ static void postalias(char *map_type, char *path_name,
static NORETURN usage(char *myname)
{
- msg_fatal("usage: %s [-c config_directory] [-i] [-v] [-w] [output_type:]file...",
+ msg_fatal("usage: %s [-c config_dir] [-i] [-v] [-w] [output_type:]file...",
myname);
}
diff --git a/postfix/postconf/extract.sh b/postfix/postconf/extract.sh
new file mode 100644
index 000000000..69323b484
--- /dev/null
+++ b/postfix/postconf/extract.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+# Extract initialization tables from actual source code.
+
+awk '
+/static CONFIG_INT_TABLE/,/};/ {
+ if ($1 ~ /VAR/) {
+ print "int " substr($3,2,length($3)-2) ";" > "int_vars.h"
+ print | "sort -u >int_table.h"
+ }
+}
+/static CONFIG_STR_TABLE/,/};/ {
+ if ($1 ~ /VAR/) {
+ print "char *" substr($3,2,length($3)-2) ";" > "str_vars.h"
+ print | "sort -u >str_table.h"
+ }
+}
+/static CONFIG_BOOL_TABLE/,/};/ {
+ if ($1 ~ /VAR/) {
+ print "int " substr($3,2,length($3)-2) ";" > "bool_vars.h"
+ print | "sort -u >bool_table.h"
+ }
+}
+' $*
diff --git a/postfix/postconf/postconf.c b/postfix/postconf/postconf.c
index 762f23b39..b8cb48fa9 100644
--- a/postfix/postconf/postconf.c
+++ b/postfix/postconf/postconf.c
@@ -18,7 +18,7 @@
/* .IP \fB-d\fR
/* Print default parameter settings instead of actual settings.
/* .IP \fB-h\fR
-/* Show parameter values only, not the ``name ='' label
+/* Show parameter values only, not the ``name = '' label
/* that normally precedes the value.
/* .IP \fB-n\fR
/* Print non-default parameter settings only.
@@ -27,8 +27,6 @@
/* options make the software increasingly verbose.
/* DIAGNOSTICS
/* Problems are reported to the standard error stream.
-/* Fatal error: out of memory, file not found, invalid \fBmain.cf\fR
-/* parameter syntax.
/* LICENSE
/* .ad
/* .fi
@@ -293,8 +291,6 @@ static void print_bool(int mode, CONFIG_BOOL_TABLE *cbt)
show_strval(mode, cbt->name, cbt->defval ? "yes" : "no");
} else {
value = dict_lookup(CONFIG_DICT, cbt->name);
- if (value)
- (void) get_mail_conf_bool(cbt->name, cbt->defval);
if ((mode & SHOW_NONDEF) == 0) {
if (value == 0) {
show_strval(mode, cbt->name, cbt->defval ? "yes" : "no");
@@ -318,8 +314,6 @@ static void print_int(int mode, CONFIG_INT_TABLE *cit)
show_intval(mode, cit->name, cit->defval);
} else {
value = dict_lookup(CONFIG_DICT, cit->name);
- if (value)
- (void) get_mail_conf_int(cit->name, cit->defval, cit->min, cit->max);
if ((mode & SHOW_NONDEF) == 0) {
if (value == 0) {
show_intval(mode, cit->name, cit->defval);
@@ -343,8 +337,6 @@ static void print_str(int mode, CONFIG_STR_TABLE *cst)
show_strval(mode, cst->name, cst->defval);
} else {
value = dict_lookup(CONFIG_DICT, cst->name);
- if (value)
- (void) get_mail_conf_str(cst->name, cst->defval, cst->min, cst->max);
if ((mode & SHOW_NONDEF) == 0) {
if (value == 0) {
show_strval(mode, cst->name, cst->defval);
@@ -520,7 +512,7 @@ int main(int argc, char **argv)
msg_verbose++;
break;
default:
- msg_fatal("usage: %s [-c config_directory] [-d (defaults)] [-h (no names)] [-n (non-defaults)] [-v] name...", argv[0]);
+ msg_fatal("usage: %s [-c config_dir] [-d (defaults)] [-h (no names)] [-n (non-defaults)] [-v] name...", argv[0]);
}
}
diff --git a/postfix/postlock/postlock.c b/postfix/postlock/postlock.c
index 44b2ad142..a4ac5ff7b 100644
--- a/postfix/postlock/postlock.c
+++ b/postfix/postlock/postlock.c
@@ -200,21 +200,21 @@ int main(int argc, char **argv)
#ifdef USE_DOT_LOCK
if (dot_lockfile(folder, why) < 0) {
if (errno == EEXIST) {
- msg_warn("dotlock file %s: %s", folder, vstring_str(why));
+ msg_warn("%s", vstring_str(why));
exit(EX_TEMPFAIL);
}
- msg_fatal("dotlock file %s: %s", folder, vstring_str(why));
+ msg_fatal("%s", vstring_str(why));
}
#endif
if (deliver_flock(fd, why) < 0) {
if (errno == EAGAIN) {
- msg_warn("lock %s: %s", folder, vstring_str(why));
+ msg_warn("file %s: %s", folder, vstring_str(why));
#ifdef USE_DOT_LOCK
dot_unlockfile(folder);
#endif
exit(EX_TEMPFAIL);
}
- msg_fatal("lock %s: %s", folder, vstring_str(why));
+ msg_fatal("file %s: %s", folder, vstring_str(why));
}
/*
diff --git a/postfix/postmap/postmap.c b/postfix/postmap/postmap.c
index 5227bece2..72ddfa44a 100644
--- a/postfix/postmap/postmap.c
+++ b/postfix/postmap/postmap.c
@@ -230,7 +230,7 @@ static void postmap(char *map_type, char *path_name,
static NORETURN usage(char *myname)
{
- msg_fatal("usage: %s [-c config_directory] [-i] [-v] [-w] [output_type:]file...",
+ msg_fatal("usage: %s [-c config_dir] [-i] [-v] [-w] [output_type:]file...",
myname);
}
diff --git a/postfix/qmgr/qmgr_active.c b/postfix/qmgr/qmgr_active.c
index d023ae31a..257dbc4aa 100644
--- a/postfix/qmgr/qmgr_active.c
+++ b/postfix/qmgr/qmgr_active.c
@@ -127,29 +127,28 @@ static void qmgr_active_corrupt(const char *queue_id)
/* qmgr_active_defer - defer queue file */
-static void qmgr_active_defer(QMGR_MESSAGE *message, time_t delay)
+static void qmgr_active_defer(const char *queue_name, const char *queue_id,
+ int delay)
{
char *myname = "qmgr_active_defer";
const char *path;
struct utimbuf tbuf;
if (msg_verbose)
- msg_info("wakeup %s after %ld secs", message->queue_id, (long) delay);
+ msg_info("wakeup %s after %ld secs", queue_id, (long) delay);
tbuf.actime = tbuf.modtime = event_time() + delay;
- path = mail_queue_path((VSTRING *) 0, message->queue_name,
- message->queue_id);
+ path = mail_queue_path((VSTRING *) 0, queue_name, queue_id);
if (utime(path, &tbuf) < 0)
msg_fatal("%s: update %s time stamps: %m", myname, path);
- if (mail_queue_rename(message->queue_id, message->queue_name,
- MAIL_QUEUE_DEFERRED)) {
+ if (mail_queue_rename(queue_id, queue_name, MAIL_QUEUE_DEFERRED)) {
if (errno != ENOENT)
msg_fatal("%s: rename %s from %s to %s: %m", myname,
- message->queue_id, message->queue_name, MAIL_QUEUE_DEFERRED);
+ queue_id, queue_name, MAIL_QUEUE_DEFERRED);
msg_warn("%s: rename %s from %s to %s: %m", myname,
- message->queue_id, message->queue_name, MAIL_QUEUE_DEFERRED);
+ queue_id, queue_name, MAIL_QUEUE_DEFERRED);
} else if (msg_verbose) {
- msg_info("%s: defer %s", myname, message->queue_id);
+ msg_info("%s: defer %s", myname, queue_id);
}
}
@@ -218,7 +217,7 @@ void qmgr_active_feed(QMGR_SCAN *scan_info, const char *queue_id)
scan_info->flags)) == 0) {
qmgr_active_corrupt(queue_id);
} else if (message == QMGR_MESSAGE_LOCKED) {
- qmgr_active_defer(message, (time_t) var_min_backoff_time);
+ qmgr_active_defer(MAIL_QUEUE_ACTIVE, queue_id, var_min_backoff_time);
} else {
/*
@@ -245,7 +244,7 @@ void qmgr_active_done(QMGR_MESSAGE *message)
char *myname = "qmgr_active_done";
struct stat st;
const char *path;
- time_t delay;
+ int delay;
if (msg_verbose)
msg_info("%s: %s", myname, message->queue_id);
@@ -359,7 +358,7 @@ void qmgr_active_done(QMGR_MESSAGE *message)
} else {
delay = var_min_backoff_time;
}
- qmgr_active_defer(message, delay);
+ qmgr_active_defer(message->queue_name, message->queue_id, delay);
}
/*
diff --git a/postfix/qmgr/qmgr_message.c b/postfix/qmgr/qmgr_message.c
index 1e6ec2e25..e47527a62 100644
--- a/postfix/qmgr/qmgr_message.c
+++ b/postfix/qmgr/qmgr_message.c
@@ -672,6 +672,7 @@ QMGR_MESSAGE *qmgr_message_alloc(const char *queue_name, const char *queue_id,
return (0);
}
if (myflock(vstream_fileno(message->fp), QMGR_LOCK_MODE) < 0) {
+ msg_info("%s: skipped, still being delivered", queue_id);
qmgr_message_close(message);
qmgr_message_free(message);
return (QMGR_MESSAGE_LOCKED);
diff --git a/postfix/sendmail/sendmail.c b/postfix/sendmail/sendmail.c
index ae44fb041..865483f82 100644
--- a/postfix/sendmail/sendmail.c
+++ b/postfix/sendmail/sendmail.c
@@ -245,6 +245,7 @@
#include
#include
#include
+#include
/* Global library. */
@@ -596,17 +597,18 @@ int main(int argc, char **argv)
set_mail_conf_str(VAR_PROCNAME, var_procname = mystrdup(argv[0]));
/*
- * Do not set[e]uid(getuid()). This allows the real user to manipulate
- * the process, which is dangerous, because some systems do not reset the
- * saved set-userid unless euid == 0.
+ * Some sites mistakenly install Postfix sendmail as set-uid root. Drop
+ * set-uid privileges only when root, otherwise some systems will not
+ * reset the saved set-userid, which would be a security vulnerability.
*/
-#ifdef WARN_SETXID_SENDMAIL
- if (geteuid() != getuid())
- msg_warn("sendmail is set-uid or is run from a set-uid process");
- if (getegid() != getgid())
- msg_warn("sendmail is set-gid or is run from a set-gid process");
-#endif
+ if (geteuid() == 0 && getuid() != 0) {
+ msg_warn("sendmail is set-uid root, or is run from a set-uid root process");
+ set_ugid(getuid(), getgid());
+ }
+ /*
+ * Further initialization...
+ */
mail_conf_read();
if (chdir(var_queue_dir))
msg_fatal("chdir %s: %m", var_queue_dir);
diff --git a/postfix/smtp/smtp.c b/postfix/smtp/smtp.c
index 801d1820f..1e6c46a51 100644
--- a/postfix/smtp/smtp.c
+++ b/postfix/smtp/smtp.c
@@ -215,7 +215,6 @@ int smtp_errno;
static int deliver_message(DELIVER_REQUEST *request)
{
- char *myname = "deliver_message";
VSTRING *why;
SMTP_STATE *state;
int result;
diff --git a/postfix/smtp/smtp_addr.c b/postfix/smtp/smtp_addr.c
index 86e257268..08a88b483 100644
--- a/postfix/smtp/smtp_addr.c
+++ b/postfix/smtp/smtp_addr.c
@@ -324,8 +324,7 @@ static DNS_RR *smtp_find_self(DNS_RR *addr_list)
/* smtp_truncate_self - truncate address list at self and equivalents */
-static DNS_RR *smtp_truncate_self(DNS_RR *addr_list, unsigned pref,
- char *name, VSTRING *why)
+static DNS_RR *smtp_truncate_self(DNS_RR *addr_list, unsigned pref, char *name)
{
DNS_RR *addr;
DNS_RR *last;
@@ -336,11 +335,6 @@ static DNS_RR *smtp_truncate_self(DNS_RR *addr_list, unsigned pref,
smtp_print_addr("truncated", addr);
dns_rr_free(addr);
if (last == 0) {
- if (*var_bestmx_transp == 0) {
- vstring_sprintf(why, "mail for %s loops back to myself",
- name);
- smtp_errno = SMTP_FAIL;
- }
addr_list = 0;
} else {
last->next = 0;
@@ -368,6 +362,11 @@ DNS_RR *smtp_domain_addr(char *name, VSTRING *why)
unsigned best_pref;
unsigned best_found;
+ /*
+ * Preferences from DNS use 0..32767, fall-backs use 32768+.
+ */
+#define IMPOSSIBLE_PREFERENCE (~0)
+
/*
* Sanity check.
*/
@@ -381,8 +380,19 @@ DNS_RR *smtp_domain_addr(char *name, VSTRING *why)
* preferred than myself. When no MX resource records exist, look up the
* addresses listed for this name.
*
+ * Normally it is OK if an MX host cannot be found in the DNS; we'll just
+ * use a backup one, and silently ignore the better MX host. However, if
+ * the best backup that we can find in the DNS is the local machine, then
+ * we must remember that the local machine is not the primary MX host, or
+ * else we will claim that mail loops back.
+ *
* XXX Optionally do A lookups even when the MX lookup didn't complete.
* Unfortunately with some DNS servers this is not a transient problem.
+ *
+ * XXX Ideally we would perform A lookups only as far as needed. But as long
+ * as we're looking up all the hosts, it would be better to look up the
+ * least preferred host first, so that DNS lookup error messages make
+ * more sense.
*/
switch (dns_lookup(name, T_MX, 0, &mx_names, (VSTRING *) 0, why)) {
default:
@@ -397,20 +407,29 @@ DNS_RR *smtp_domain_addr(char *name, VSTRING *why)
break;
case DNS_OK:
mx_names = dns_rr_sort(mx_names, smtp_compare_mx);
- best_pref = (mx_names ? mx_names->pref : ~0);
+ best_pref = (mx_names ? mx_names->pref : IMPOSSIBLE_PREFERENCE);
addr_list = smtp_addr_list(mx_names, why);
dns_rr_free(mx_names);
- best_found = (addr_list ? addr_list->pref : ~0);
+ best_found = (addr_list ? addr_list->pref : IMPOSSIBLE_PREFERENCE);
if (*var_fallback_relay)
addr_list = smtp_addr_fallback(addr_list);
if (msg_verbose)
smtp_print_addr(name, addr_list);
- if ((self = smtp_find_self(addr_list)) != 0)
- addr_list = smtp_truncate_self(addr_list, self->pref, name, why);
- if (addr_list == 0 && best_pref < best_found) {
- vstring_sprintf(why, "unable to find primary mail relay for %s",
- name);
- smtp_errno = SMTP_RETRY;
+ if ((self = smtp_find_self(addr_list)) != 0) {
+ addr_list = smtp_truncate_self(addr_list, self->pref, name);
+ if (addr_list == 0) {
+ if (best_pref != best_found) {
+ vstring_sprintf(why, "unable to find primary relay for %s",
+ name);
+ smtp_errno = SMTP_RETRY;
+ } else if (*var_bestmx_transp != 0) { /* we're best MX */
+ smtp_errno = SMTP_OK;
+ } else {
+ vstring_sprintf(why, "mail for %s loops back to myself",
+ name);
+ smtp_errno = SMTP_FAIL;
+ }
+ }
}
break;
case DNS_NOTFOUND:
diff --git a/postfix/smtpd/smtpd_check.c b/postfix/smtpd/smtpd_check.c
index 7a091d2c6..7f101a5a8 100644
--- a/postfix/smtpd/smtpd_check.c
+++ b/postfix/smtpd/smtpd_check.c
@@ -125,9 +125,9 @@
/* The \fIrelay_domains_reject_code\fR configuration parameter specifies
/* the reject status code (default: 554).
/* .IP reject_unauth_destination
-/* Allow the request when the resolved recipient domain matches the
-/* \fIrelay_domains\fR configuration parameter. Reject the request
-/* otherwise. Same error code as check_relay_domains.
+/* Reject the request when the resolved recipient domain does not match
+/* the \fIrelay_domains\fR configuration parameter. Same error code as
+/* check_relay_domains.
/* .IP permit_mx_backup
/* Allow the request when the local mail system is mail exchanger
/* for the recipient domain (this includes the case where the local
@@ -688,7 +688,7 @@ static int reject_unauth_destination(SMTPD_STATE *state, char *recipient)
resolve_clnt_query(STR(query), &reply);
/*
- * Permit if destination is local. XXX This must be generalized for
+ * Pass if destination is local. XXX This must be generalized for
* per-domain user tables and for non-UNIX local delivery agents.
*/
if (STR(reply.nexthop)[0] == 0
@@ -697,13 +697,13 @@ static int reject_unauth_destination(SMTPD_STATE *state, char *recipient)
domain += 1;
/*
- * Permit if the destination matches the relay_domains list.
+ * Pass if the destination matches the relay_domains list.
*/
if (domain_list_match(relay_domains, domain))
return (SMTPD_CHECK_DUNNO);
/*
- * Deny relaying between sites that both are not in relay_domains.
+ * Reject relaying to sites that are not listed in relay_domains.
*/
return (smtpd_check_reject(state, MAIL_ERROR_POLICY,
"%d <%s>: Relay access denied",
diff --git a/postfix/util/compat.c b/postfix/util/compat.c
new file mode 100644
index 000000000..e69de29bb
diff --git a/postfix/util/dict_dbm.c b/postfix/util/dict_dbm.c
index 46d9aea3d..e62688177 100644
--- a/postfix/util/dict_dbm.c
+++ b/postfix/util/dict_dbm.c
@@ -166,7 +166,7 @@ static void dict_dbm_update(DICT *dict, const char *name, const char *value)
* Do the update.
*/
if ((status = dbm_store(dict_dbm->dbm, dbm_key, dbm_value,
- (dict->flags & DICT_FLAG_DUP_REPLACE) ? DBM_REPLACE : DBM_INSERT)) < 0)
+ (dict->flags & DICT_FLAG_DUP_REPLACE) ? DBM_REPLACE : DBM_INSERT)) < 0)
msg_fatal("error writing DBM database %s: %m", dict_dbm->path);
if (status) {
if (dict->flags & DICT_FLAG_DUP_IGNORE)
@@ -385,6 +385,8 @@ DICT *dict_dbm_open(const char *path, int open_flags, int dict_flags)
if (fstat(dict_dbm->dict.fd, &st) < 0)
msg_fatal("dict_dbm_open: fstat: %m");
dict_dbm->dict.mtime = st.st_mtime;
+ close_on_exec(dbm_pagfno(dbm), CLOSE_ON_EXEC);
+ close_on_exec(dbm_dirfno(dbm), CLOSE_ON_EXEC);
dict_dbm->dict.flags = dict_flags | DICT_FLAG_FIXED;
if ((dict_flags & (DICT_FLAG_TRY0NULL | DICT_FLAG_TRY1NULL)) == 0)
dict_dbm->dict.flags |= (DICT_FLAG_TRY0NULL | DICT_FLAG_TRY1NULL);
diff --git a/postfix/util/sys_defs.h b/postfix/util/sys_defs.h
index 7a956383b..6665f8d39 100644
--- a/postfix/util/sys_defs.h
+++ b/postfix/util/sys_defs.h
@@ -339,7 +339,6 @@ extern int initgroups(const char *, int);
#define UNIX_DOMAIN_CONNECT_BLOCKS_FOR_ACCEPT
#define PREPEND_PLUS_TO_OPTSTRING
#define HAS_POSIX_REGEXP
-#define WARN_SETXID_SENDMAIL
#endif
/*