/*++ /* NAME /* single_server 3 /* SUMMARY /* skeleton single-threaded mail subsystem /* SYNOPSIS /* #include <mail_server.h> /* /* NORETURN single_server_main(argc, argv, service, key, value, ...) /* int argc; /* char **argv; /* void (*service)(VSTREAM *stream, char *service_name, char **argv); /* int key; /* DESCRIPTION /* This module implements a skeleton for single-threaded /* mail subsystems: mail subsystem programs that service one /* client at a time. The resulting program expects to be run /* from the \fBmaster\fR process. /* /* single_server_main() is the skeleton entry point. It should be /* called from the application main program. The skeleton does the /* generic command-line options processing, initialization of /* configurable parameters, and connection management. /* The skeleton never returns. /* /* Arguments: /* .IP "void (*service)(VSTREAM *fp, char *service_name, char **argv)" /* A pointer to a function that is called by the skeleton each time /* a client connects to the program's service port. The function is /* run after the program has irrevocably dropped its privileges. /* The stream initial state is non-blocking mode. /* Optional connection attributes are provided as a hash that /* is attached as stream context. /* The service name argument corresponds to the service name in the /* master.cf file. /* The argv argument specifies command-line arguments left over /* after options processing. /* .PP /* Optional arguments are specified as a null-terminated list /* with macros that have zero or more arguments: /* .IP "CA_MAIL_SERVER_INT_TABLE(CONFIG_INT_TABLE *)" /* A table with configurable parameters, to be loaded from the /* global Postfix configuration file. Tables are loaded in the /* order as specified, and multiple instances of the same type /* are allowed. /* .IP "CA_MAIL_SERVER_LONG_TABLE(CONFIG_LONG_TABLE *)" /* A table with configurable parameters, to be loaded from the /* global Postfix configuration file. Tables are loaded in the /* order as specified, and multiple instances of the same type /* are allowed. /* .IP "CA_MAIL_SERVER_STR_TABLE(CONFIG_STR_TABLE *)" /* A table with configurable parameters, to be loaded from the /* global Postfix configuration file. Tables are loaded in the /* order as specified, and multiple instances of the same type /* are allowed. /* .IP "CA_MAIL_SERVER_BOOL_TABLE(CONFIG_BOOL_TABLE *)" /* A table with configurable parameters, to be loaded from the /* global Postfix configuration file. Tables are loaded in the /* order as specified, and multiple instances of the same type /* are allowed. /* .IP "CA_MAIL_SERVER_TIME_TABLE(CONFIG_TIME_TABLE *)" /* A table with configurable parameters, to be loaded from the /* global Postfix configuration file. Tables are loaded in the /* order as specified, and multiple instances of the same type /* are allowed. /* .IP "CA_MAIL_SERVER_RAW_TABLE(CONFIG_RAW_TABLE *)" /* A table with configurable parameters, to be loaded from the /* global Postfix configuration file. Tables are loaded in the /* order as specified, and multiple instances of the same type /* are allowed. Raw parameters are not subjected to $name /* evaluation. /* .IP "CA_MAIL_SERVER_NINT_TABLE(CONFIG_NINT_TABLE *)" /* A table with configurable parameters, to be loaded from the /* global Postfix configuration file. Tables are loaded in the /* order as specified, and multiple instances of the same type /* are allowed. /* .IP "CA_MAIL_SERVER_NBOOL_TABLE(CONFIG_NBOOL_TABLE *)" /* A table with configurable parameters, to be loaded from the /* global Postfix configuration file. Tables are loaded in the /* order as specified, and multiple instances of the same type /* are allowed. /* .IP "CA_MAIL_SERVER_PRE_INIT(void *(char *service_name, char **argv))" /* A pointer to a function that is called once /* by the skeleton after it has read the global configuration file /* and after it has processed command-line arguments, but before /* the skeleton has optionally relinquished the process privileges. /* .sp /* Only the last instance of this parameter type is remembered. /* .IP "CA_MAIL_SERVER_POST_INIT(void *(char *service_name, char **argv))" /* A pointer to a function that is called once /* by the skeleton after it has optionally relinquished the process /* privileges, but before servicing client connection requests. /* .sp /* Only the last instance of this parameter type is remembered. /* .IP "CA_MAIL_SERVER_LOOP(int *(char *service_name, char **argv))" /* A pointer to function that is executed from /* within the event loop, whenever an I/O or timer event has happened, /* or whenever nothing has happened for a specified amount of time. /* The result value of the function specifies how long to wait until /* the next event. Specify -1 to wait for "as long as it takes". /* .sp /* Only the last instance of this parameter type is remembered. /* .IP "CA_MAIL_SERVER_EXIT(void *(void))" /* A pointer to function that is executed immediately before normal /* process termination. /* .sp /* Only the last instance of this parameter type is remembered. /* .IP "CA_MAIL_SERVER_PRE_ACCEPT(void *(char *service_name, char **argv))" /* Function to be executed prior to accepting a new connection. /* .sp /* Only the last instance of this parameter type is remembered. /* .IP "CA_MAIL_SERVER_IN_FLOW_DELAY(none)" /* Pause $in_flow_delay seconds when no "mail flow control token" /* is available. A token is consumed for each connection request. /* .IP CA_MAIL_SERVER_SOLITARY /* This service must be configured with process limit of 1. /* .IP CA_MAIL_SERVER_UNLIMITED /* This service must be configured with process limit of 0. /* .IP CA_MAIL_SERVER_PRIVILEGED /* This service must be configured as privileged. /* .IP "CA_MAIL_SERVER_BOUNCE_INIT(const char *, const char **)" /* Initialize the DSN filter for the bounce/defer service /* clients with the specified map source and map names. /* .IP "CA_MAIL_SERVER_RETIRE_ME" /* Prevent a process from being reused indefinitely. After /* (var_max_use * var_max_idle) seconds or some sane constant, /* terminate voluntarily when the process becomes idle. /* .PP /* The var_use_limit variable limits the number of clients /* that a server can service before it commits suicide. This /* value is taken from the global \fBmain.cf\fR configuration /* file. Setting \fBvar_use_limit\fR to zero disables the /* client limit. /* /* The var_idle_limit variable limits the time that a service /* receives no client connection requests before it commits suicide. /* Do not change this setting before calling single_server_main(). /* This value is taken from the global \fBmain.cf\fR configuration /* file. Setting \fBvar_idle_limit\fR to zero disables the idle limit. /* DIAGNOSTICS /* Problems and transactions are logged to \fBsyslogd\fR(8) /* or \fBpostlogd\fR(8). /* BUGS /* SEE ALSO /* master(8), master process /* postlogd(8), Postfix logging /* syslogd(8), system logging /* 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
/*--*/
/* *Ifnotconnectedtostdin,stdinmustnotbeaterminal.
*/ if (daemon_mode && stream == 0 && isatty(STDIN_FILENO)) {
msg_vstream_init(var_procname, VSTREAM_ERR);
msg_fatal("do not run this command by hand");
}
/* *Application-specificinitialization.
*/
va_start(ap, service); while ((key = va_arg(ap, int)) != 0) { switch (key) { case MAIL_SERVER_INT_TABLE:
get_mail_conf_int_table(va_arg(ap, CONFIG_INT_TABLE *)); break; case MAIL_SERVER_LONG_TABLE:
get_mail_conf_long_table(va_arg(ap, CONFIG_LONG_TABLE *)); break; case MAIL_SERVER_STR_TABLE:
get_mail_conf_str_table(va_arg(ap, CONFIG_STR_TABLE *)); break; case MAIL_SERVER_BOOL_TABLE:
get_mail_conf_bool_table(va_arg(ap, CONFIG_BOOL_TABLE *)); break; case MAIL_SERVER_TIME_TABLE:
get_mail_conf_time_table(va_arg(ap, CONFIG_TIME_TABLE *)); break; case MAIL_SERVER_RAW_TABLE:
get_mail_conf_raw_table(va_arg(ap, CONFIG_RAW_TABLE *)); break; case MAIL_SERVER_NINT_TABLE:
get_mail_conf_nint_table(va_arg(ap, CONFIG_NINT_TABLE *)); break; case MAIL_SERVER_NBOOL_TABLE:
get_mail_conf_nbool_table(va_arg(ap, CONFIG_NBOOL_TABLE *)); break; case MAIL_SERVER_PRE_INIT:
pre_init = va_arg(ap, MAIL_SERVER_INIT_FN); break; case MAIL_SERVER_POST_INIT:
post_init = va_arg(ap, MAIL_SERVER_INIT_FN); break; case MAIL_SERVER_LOOP:
loop = va_arg(ap, MAIL_SERVER_LOOP_FN); break; case MAIL_SERVER_EXIT:
single_server_onexit = va_arg(ap, MAIL_SERVER_EXIT_FN); break; case MAIL_SERVER_PRE_ACCEPT:
single_server_pre_accept = va_arg(ap, MAIL_SERVER_ACCEPT_FN); break; case MAIL_SERVER_IN_FLOW_DELAY:
single_server_in_flow_delay = 1; break; case MAIL_SERVER_SOLITARY: if (stream == 0 && !alone)
msg_fatal("service %s requires a process limit of 1",
service_name); break; case MAIL_SERVER_UNLIMITED: if (stream == 0 && !zerolimit)
msg_fatal("service %s requires a process limit of 0",
service_name); break; case MAIL_SERVER_PRIVILEGED: if (user_name)
msg_fatal("service %s requires privileged operation",
service_name); break; case MAIL_SERVER_BOUNCE_INIT:
dsn_filter_title = va_arg(ap, constchar *);
dsn_filter_maps = va_arg(ap, constchar **);
bounce_client_init(dsn_filter_title, *dsn_filter_maps); break; case MAIL_SERVER_RETIRE_ME: if (retire_me_from_flags > 0)
retire_me = retire_me_from_flags; elseif (var_idle_limit == 0 || var_use_limit == 0
|| var_idle_limit > 18000 / var_use_limit)
retire_me = 18000; else
retire_me = var_idle_limit * var_use_limit; break; default:
msg_panic("%s: unknown argument type: %d", myname, key);
}
}
va_end(ap);
if (root_dir)
root_dir = var_queue_dir; if (user_name)
user_name = var_mail_owner;
/* *Canoptionsberequired?
*/ if (stream == 0) { if (transport == 0)
msg_fatal("no transport type specified"); if (strcasecmp(transport, MASTER_XPORT_NAME_INET) == 0)
single_server_accept = single_server_accept_inet; elseif (strcasecmp(transport, MASTER_XPORT_NAME_UNIX) == 0)
single_server_accept = single_server_accept_local; #ifdef MASTER_XPORT_NAME_PASS elseif (strcasecmp(transport, MASTER_XPORT_NAME_PASS) == 0)
single_server_accept = single_server_accept_pass; #endif else
msg_fatal("unsupported transport type: %s", transport);
}
/* *Retrieveprocessgenerationfromenvironment.
*/ if ((generation = getenv(MASTER_GEN_NAME)) != 0) { if (!alldig(generation))
msg_fatal("bad generation: %s", generation);
OCTAL_TO_UNSIGNED(single_server_generation, generation); if (msg_verbose)
msg_info("process generation: %s (%o)",
generation, single_server_generation);
}
/* *Optionallystartthedebuggeronourself.
*/ if (debug_me)
debug_process();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.