diff options
| author | beatrice <beatrice@dangofactory.net> | 2026-11-22 19:19:03 +0900 |
|---|---|---|
| committer | beatrice <beatrice@dangofactory.net> | 2026-11-22 19:19:03 +0900 |
| commit | bd4611555e18fca7c66afaef0f094e15038b0459 (patch) | |
| tree | 1b1a9109567b61ac259ead146f4bef21a0f886df /src/smtp/smtp_state.c | |
| parent | 2324a9e97a727bf95690c9fb8fdca0f52301940e (diff) | |
| download | postfix-master.tar.gz postfix-master.zip | |
Release tarball postfix-3.11.7.tar.gz (dist-generated files / local differences from tag)HEADlocal/postfixmaster
Diffstat (limited to 'src/smtp/smtp_state.c')
| -rw-r--r-- | src/smtp/smtp_state.c | 147 |
1 files changed, 147 insertions, 0 deletions
diff --git a/src/smtp/smtp_state.c b/src/smtp/smtp_state.c new file mode 100644 index 000000000..34fa70c6b --- /dev/null +++ b/src/smtp/smtp_state.c @@ -0,0 +1,147 @@ +/*++ +/* NAME +/* smtp_state 3 +/* SUMMARY +/* initialize/cleanup shared state +/* SYNOPSIS +/* #include "smtp.h" +/* +/* SMTP_STATE *smtp_state_alloc() +/* +/* void smtp_state_free(state) +/* SMTP_STATE *state; +/* DESCRIPTION +/* smtp_state_init() initializes the shared state, and allocates +/* memory for buffers etc. +/* +/* smtp_cleanup() destroys memory allocated by smtp_state_init(). +/* STANDARDS +/* DIAGNOSTICS +/* BUGS +/* SEE ALSO +/* 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 +/* +/* Wietse Venema +/* Google, Inc. +/* 111 8th Avenue +/* New York, NY 10011, USA +/*--*/ + +/* System library. */ + +#include <sys_defs.h> + +/* Utility library. */ + +#include <mymalloc.h> +#include <vstring.h> +#include <msg.h> + +/* Global library. */ + +#include <mail_params.h> +#include <debug_peer.h> + + /* + * TLS library. + */ +#if defined(USE_TLS) && defined(USE_TLSRPT) +#include <tlsrpt_wrapper.h> +#endif + +/* Application-specific. */ + +#include "smtp.h" +#include "smtp_sasl.h" + +/* smtp_state_alloc - initialize */ + +SMTP_STATE *smtp_state_alloc(void) +{ + SMTP_STATE *state = (SMTP_STATE *) mymalloc(sizeof(*state)); + + state->misc_flags = 0; + state->src = 0; + state->service = 0; + state->request = 0; + state->session = 0; + state->status = 0; + state->space_left = 0; + state->iterator->request_nexthop = vstring_alloc(100); + state->iterator->dest = vstring_alloc(100); + state->iterator->host = vstring_alloc(100); + state->iterator->addr = vstring_alloc(100); + state->iterator->saved_dest = vstring_alloc(100); +#ifdef USE_TLSRPT + state->tlsrpt = 0; +#endif +#ifdef USE_TLS + state->reqtls_level = SMTP_REQTLS_POLICY_ACT_DISABLE; + if (var_log_tls_feature_status) + state->tls_stats = pol_stats_create(); + else +#endif + state->tls_stats = 0; + if (var_smtp_cache_conn) { + state->dest_label = vstring_alloc(10); + state->dest_prop = vstring_alloc(10); + state->endp_label = vstring_alloc(10); + state->endp_prop = vstring_alloc(10); + state->cache_used = htable_create(1); + } else { + state->dest_label = 0; + state->dest_prop = 0; + state->endp_label = 0; + state->endp_prop = 0; + state->cache_used = 0; + } + state->why = dsb_create(); + state->debug_peer_per_nexthop = 0; + state->logged_line_length_limit = 0; + return (state); +} + +/* smtp_state_free - destroy state */ + +void smtp_state_free(SMTP_STATE *state) +{ +#ifdef USE_TLS + /* The TLS policy cache lifetime is one delivery. */ + smtp_tls_policy_cache_flush(); + if (state->tls_stats) + pol_stats_free(state->tls_stats); +#endif + vstring_free(state->iterator->request_nexthop); + vstring_free(state->iterator->dest); + vstring_free(state->iterator->host); + vstring_free(state->iterator->addr); + vstring_free(state->iterator->saved_dest); +#ifdef USE_TLSRPT + if (state->tlsrpt) + trw_free(state->tlsrpt); +#endif + if (state->dest_label) + vstring_free(state->dest_label); + if (state->dest_prop) + vstring_free(state->dest_prop); + if (state->endp_label) + vstring_free(state->endp_label); + if (state->endp_prop) + vstring_free(state->endp_prop); + if (state->cache_used) + htable_free(state->cache_used, (void (*) (void *)) 0); + if (state->why) + dsb_free(state->why); + if (state->debug_peer_per_nexthop) + debug_peer_restore(); + + myfree((void *) state); +} |
