vdukhovni/postfix Documentation

repository·master·Indexed 20 days ago

https://github.com/vdukhovni/postfix

A repository containing auxiliary tools for Postfix, including scripts like collate.pl and tlstype.pl for analyzing log files, debugging, and security auditing. It also includes documentation on Postfix compilation using makedefs, managing alias databases with postalias, and viewing queue files with postcat.

Tokens
122.4K
Snippets
311
Records
559
Agent score
68%

What's inside vdukhovni/postfix

  1. Overview of the Postfix QMQP server (qmqpd)

    master

    The qmqpd daemon is a Postfix QMQP (Quick Mail Queue Protocol) server. It is designed to receive one message per connection, pipe it through the cleanup daemon, and place it into the incoming queue as a single queue file.

    Key Characteristics:

    • Execution Model: It is intended to be run from the master process manager.
    • Access Policy: It implements a strict access policy where only explicitly authorized client hosts are allowed to use the service.
    • Security: The server is moderately security-sensitive as it communicates with QMQP clients and DNS servers. It can be run in a chroot at a fixed low privilege level.
    • Protocol Limitations: The QMQP protocol provides only one server reply per message delivery, meaning individual recipients cannot be rejected. The server must receive the entire message before replying; if a message is malformed or a netstring component is too long, the server replies immediately and closes the connection.
  2. Use qmqp-sink as a parallelized QMQP test server

    master

    The qmqp-sink utility is a parallelized test server used to measure QMQP client performance. It listens on a specified host/port or UNIX-domain socket and receives messages from the network, which it then discards. It is designed to be used as the complement to the qmqp-source program.

    Note: This is an unsupported test program. Compatibility between successive versions is not guaranteed.

    # Example: Listen on a network host and port with a backlog of 128
    qmqp-sink inet:localhost:10025 128
    
    # Example: Listen on a UNIX-domain socket with a backlog of 128
    qmqp-sink unix:/tmp/qmqp.sock 128
  3. Use postsuper for Postfix queue maintenance

    master

    The postsuper command is used by the superuser to perform maintenance tasks on the Postfix mail queue. While unprivileged users can use postqueue for listing or flushing, postsuper is required for destructive or structural operations like deleting, holding, or requeueing messages.

    By default, operations like -s (structure check) or -p (purge) apply to all Postfix queue directories, including incoming, active, deferred, hold, bounce, defer, trace, and flush.

  4. Use qshape to analyze Postfix queue distribution

    master

    The qshape program provides administrators with a distribution of Postfix queue messages based on time (age) and by sender or recipient domain.

    Permissions Requirement: Because qshape must read queue directories and files, it must be run as the superuser or as the mail_owner specified in main.cf (typically postfix).

    Basic Usage: By default, qshape displays the combined distribution of the incoming and active queues, categorized by recipient domain using a geometric age sequence.

  5. Manage Postfix lookup tables with postmap

    master

    The postmap command is used to create, query, or update Postfix lookup tables. It can transform a plain text source file into a database format (like hash:, btree:, or lmdb:) or perform direct queries against existing maps.

    Basic Usage Patterns:

    • Create/Update a table: postmap [options] [file_type:]file_name
    • Query a single key: postmap -q key file_type:file_name
    • List all elements: postmap -s file_type:file_name
    • Remove an entry: postmap -d key file_type:file_name

    When updating a table, postmap places an exclusive advisory lock on the entire table to prevent issues with concurrent processes.

    postmap hash:/etc/postfix/access
  6. What is the Postfix flush server?

    master

    The flush server is a Postfix daemon that maintains a record of deferred mail organized by destination. This mechanism improves the performance of SMTP ETRN requests and their command-line equivalents (sendmail -qR or postqueue -f) by allowing the system to quickly identify which destinations have queued mail without scanning the entire queue.

    Key Concepts:

    • Destination: Defined as the part on the right-hand side of the right-most @ in an email address.
    • Logfiles: The server uses per-destination, append-only logfiles located in /var/spool/postfix/flush. These files contain the queue IDs of deferred mail. A logfile is truncated when delivery is requested for that destination.
    • Eligibility: Only destinations specified in the fast_flush_domains parameter are tracked.
    • Execution: This program is designed to be managed by the master process manager.
  7. What is a Postfix generic table and when to use it

    master

    A generic table specifies address mappings used during mail delivery. It is primarily used by the smtp client to transform local mail addresses (e.g., user@localdomain.local) into valid Internet mail addresses when sending mail across the Internet. This is particularly useful for systems that do not have a valid Internet domain name.

    Unlike canonical mappings (which apply when mail is received), generic mappings apply when mail is sent and affect both message header addresses and message envelope addresses.

  8. What is tlsmgr and how does it work?

    master

    The tlsmgr(8) daemon is a persistent Postfix process that manages two primary functions:

    1. TLS Session Cache Management: It stores and retrieves TLS session cache entries requested by smtpd(8) (server) and smtp(8) (client) processes. It also handles the periodic removal of expired entries.
    2. PRNG Pool Management: It manages the Pseudo Random Number Generator (PRNG) pool. It provides entropy to seed the internal PRNG pools of smtpd and smtp processes. The pool is seeded from an external source (like /dev/urandom or an EGD), updated with data from TLS cache entries and the time of day, and its state is periodically saved to an exchange file.

    Security Note: tlsmgr is not considered security-sensitive. It does not "trust" the data it manipulates, and it does not touch the actual contents of cached TLS entries, except for using them to seed the PRNG pool.

  9. Overview of the Anvil server

    master

    The Anvil server is a Postfix component designed to maintain statistics about client connection counts and request rates. It is used to defend against clients that attempt to overwhelm the server with too many simultaneous sessions or too many successive requests within a specific time interval.

    Anvil is designed to run under the control of the Postfix master server and maintains an in-memory table of recent client requests. It does not keep persistent state. To reduce memory usage on high-traffic systems, you can decrease the time unit over which state is kept.

  10. What is postlogd and how does it work?

    master

    postlogd is the Postfix internal log server. It is responsible for logging events on behalf of other Postfix programs when the maillog_file configuration parameter is set to a non-empty value.

    Instead of every Postfix program writing directly to a file, they send their logs to postlogd, which manages the centralized log file. This allows Postfix to handle logging to a specific file even when individual programs are running with restricted permissions.

  11. What is tlsproxy and how does it work?

    master

    The tlsproxy(8) server is a two-way TLS proxy used by Postfix to handle encrypted communications.

    Core Functions:

    • postscreen(8) integration: It allows postscreen to perform SMTP-over-TLS with remote clients that are not allowlisted.
    • smtp(8) support: It enables TLS connection reuse for the SMTP client.
    • Protocol Agnostic: While primarily used for SMTP, it can work with non-SMTP protocols.

    How the protocol flow works (e.g., with postscreen):

    1. A remote client sends a STARTTLS command.
    2. postscreen sends the client endpoint, the requested role (server), and a timeout to tlsproxy.
    3. tlsproxy indicates if TLS is available.
    4. If available, postscreen sends the client's file descriptor to tlsproxy and sends a plaintext 220 greeting to the client.
    5. tlsproxy performs the TLS handshake with the client and then translates between the plaintext sent by postscreen and the ciphertext sent to the client.