Mercurial > hg > nginx-quic
diff src/mail/ngx_mail_core_module.c @ 1136:68f30ab68bb7
Many changes:
*) rename imap to mail, sort pop3/imap functions
*) smtp auth support
*) pop3 starttls only
*) fix segfault if cram-md5 was used without apop
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 19 Mar 2007 13:36:56 +0000 |
parents | src/imap/ngx_imap_core_module.c@a0310ac2814f |
children | 6be5ee17d80b |
line wrap: on
line diff
copy from src/imap/ngx_imap_core_module.c copy to src/mail/ngx_mail_core_module.c --- a/src/imap/ngx_imap_core_module.c +++ b/src/mail/ngx_mail_core_module.c @@ -7,24 +7,25 @@ #include <ngx_config.h> #include <ngx_core.h> #include <ngx_event.h> -#include <ngx_imap.h> +#include <ngx_mail.h> -static void *ngx_imap_core_create_main_conf(ngx_conf_t *cf); -static void *ngx_imap_core_create_srv_conf(ngx_conf_t *cf); -static char *ngx_imap_core_merge_srv_conf(ngx_conf_t *cf, void *parent, +static void *ngx_mail_core_create_main_conf(ngx_conf_t *cf); +static void *ngx_mail_core_create_srv_conf(ngx_conf_t *cf); +static char *ngx_mail_core_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child); -static char *ngx_imap_core_server(ngx_conf_t *cf, ngx_command_t *cmd, +static char *ngx_mail_core_server(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); -static char *ngx_imap_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, +static char *ngx_mail_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); -static char *ngx_imap_core_capability(ngx_conf_t *cf, ngx_command_t *cmd, +static char *ngx_mail_core_capability(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); -static ngx_conf_enum_t ngx_imap_core_procotol[] = { - { ngx_string("pop3"), NGX_IMAP_POP3_PROTOCOL }, - { ngx_string("imap"), NGX_IMAP_IMAP_PROTOCOL }, +static ngx_conf_enum_t ngx_mail_core_procotol[] = { + { ngx_string("pop3"), NGX_MAIL_POP3_PROTOCOL }, + { ngx_string("imap"), NGX_MAIL_IMAP_PROTOCOL }, + { ngx_string("smtp"), NGX_MAIL_SMTP_PROTOCOL }, { ngx_null_string, 0 } }; @@ -45,14 +46,30 @@ static ngx_str_t ngx_imap_default_capab }; -static ngx_conf_bitmask_t ngx_imap_auth_methods[] = { - { ngx_string("plain"), NGX_IMAP_AUTH_PLAIN_ENABLED }, - { ngx_string("apop"), NGX_IMAP_AUTH_APOP_ENABLED }, - { ngx_string("cram-md5"), NGX_IMAP_AUTH_CRAM_MD5_ENABLED }, +static ngx_conf_bitmask_t ngx_pop3_auth_methods[] = { + { ngx_string("plain"), NGX_MAIL_AUTH_PLAIN_ENABLED }, + { ngx_string("apop"), NGX_MAIL_AUTH_APOP_ENABLED }, + { ngx_string("cram-md5"), NGX_MAIL_AUTH_CRAM_MD5_ENABLED }, { ngx_null_string, 0 } }; +static ngx_conf_bitmask_t ngx_smtp_auth_methods[] = { + { ngx_string("plain"), NGX_MAIL_AUTH_PLAIN_ENABLED }, + { ngx_string("login"), NGX_MAIL_AUTH_LOGIN_ENABLED }, + { ngx_string("cram-md5"), NGX_MAIL_AUTH_CRAM_MD5_ENABLED }, + { ngx_null_string, 0 } +}; + + +static ngx_str_t ngx_smtp_auth_methods_names[] = { + ngx_string("PLAIN"), + ngx_string("LOGIN"), + ngx_null_string, /* APOP */ + ngx_string("CRAM-MD5") +}; + + static ngx_str_t ngx_pop3_auth_plain_capability = ngx_string("+OK methods supported:" CRLF "LOGIN" CRLF @@ -69,96 +86,117 @@ static ngx_str_t ngx_pop3_auth_cram_md5 -static ngx_command_t ngx_imap_core_commands[] = { +static ngx_command_t ngx_mail_core_commands[] = { { ngx_string("server"), - NGX_IMAP_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS, - ngx_imap_core_server, + NGX_MAIL_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS, + ngx_mail_core_server, 0, 0, NULL }, { ngx_string("listen"), - NGX_IMAP_SRV_CONF|NGX_CONF_TAKE12, - ngx_imap_core_listen, + NGX_MAIL_SRV_CONF|NGX_CONF_TAKE12, + ngx_mail_core_listen, 0, 0, NULL }, { ngx_string("protocol"), - NGX_IMAP_SRV_CONF|NGX_CONF_TAKE1, + NGX_MAIL_SRV_CONF|NGX_CONF_TAKE1, ngx_conf_set_enum_slot, - NGX_IMAP_SRV_CONF_OFFSET, - offsetof(ngx_imap_core_srv_conf_t, protocol), - &ngx_imap_core_procotol }, + NGX_MAIL_SRV_CONF_OFFSET, + offsetof(ngx_mail_core_srv_conf_t, protocol), + &ngx_mail_core_procotol }, { ngx_string("imap_client_buffer"), - NGX_IMAP_MAIN_CONF|NGX_IMAP_SRV_CONF|NGX_CONF_TAKE1, + NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_TAKE1, ngx_conf_set_size_slot, - NGX_IMAP_SRV_CONF_OFFSET, - offsetof(ngx_imap_core_srv_conf_t, imap_client_buffer_size), + NGX_MAIL_SRV_CONF_OFFSET, + offsetof(ngx_mail_core_srv_conf_t, imap_client_buffer_size), NULL }, { ngx_string("so_keepalive"), - NGX_IMAP_MAIN_CONF|NGX_IMAP_SRV_CONF|NGX_CONF_FLAG, + NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_FLAG, ngx_conf_set_flag_slot, - NGX_IMAP_SRV_CONF_OFFSET, - offsetof(ngx_imap_core_srv_conf_t, so_keepalive), + NGX_MAIL_SRV_CONF_OFFSET, + offsetof(ngx_mail_core_srv_conf_t, so_keepalive), NULL }, { ngx_string("timeout"), - NGX_IMAP_MAIN_CONF|NGX_IMAP_SRV_CONF|NGX_CONF_TAKE1, + NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_TAKE1, ngx_conf_set_msec_slot, - NGX_IMAP_SRV_CONF_OFFSET, - offsetof(ngx_imap_core_srv_conf_t, timeout), + NGX_MAIL_SRV_CONF_OFFSET, + offsetof(ngx_mail_core_srv_conf_t, timeout), NULL }, { ngx_string("pop3_capabilities"), - NGX_IMAP_MAIN_CONF|NGX_IMAP_SRV_CONF|NGX_CONF_1MORE, - ngx_imap_core_capability, - NGX_IMAP_SRV_CONF_OFFSET, - offsetof(ngx_imap_core_srv_conf_t, pop3_capabilities), + NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_1MORE, + ngx_mail_core_capability, + NGX_MAIL_SRV_CONF_OFFSET, + offsetof(ngx_mail_core_srv_conf_t, pop3_capabilities), NULL }, { ngx_string("imap_capabilities"), - NGX_IMAP_MAIN_CONF|NGX_IMAP_SRV_CONF|NGX_CONF_1MORE, - ngx_imap_core_capability, - NGX_IMAP_SRV_CONF_OFFSET, - offsetof(ngx_imap_core_srv_conf_t, imap_capabilities), + NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_1MORE, + ngx_mail_core_capability, + NGX_MAIL_SRV_CONF_OFFSET, + offsetof(ngx_mail_core_srv_conf_t, imap_capabilities), + NULL }, + + { ngx_string("smtp_capabilities"), + NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_1MORE, + ngx_mail_core_capability, + NGX_MAIL_SRV_CONF_OFFSET, + offsetof(ngx_mail_core_srv_conf_t, smtp_capabilities), NULL }, { ngx_string("server_name"), - NGX_IMAP_MAIN_CONF|NGX_IMAP_SRV_CONF|NGX_CONF_TAKE1, + NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_TAKE1, ngx_conf_set_str_slot, - NGX_IMAP_SRV_CONF_OFFSET, - offsetof(ngx_imap_core_srv_conf_t, server_name), + NGX_MAIL_SRV_CONF_OFFSET, + offsetof(ngx_mail_core_srv_conf_t, server_name), NULL }, { ngx_string("auth"), - NGX_IMAP_MAIN_CONF|NGX_IMAP_SRV_CONF|NGX_CONF_1MORE, + NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_1MORE, + ngx_conf_set_bitmask_slot, + NGX_MAIL_SRV_CONF_OFFSET, + offsetof(ngx_mail_core_srv_conf_t, pop3_auth_methods), + &ngx_pop3_auth_methods }, + + { ngx_string("pop3_auth"), + NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_1MORE, ngx_conf_set_bitmask_slot, - NGX_IMAP_SRV_CONF_OFFSET, - offsetof(ngx_imap_core_srv_conf_t, auth_methods), - &ngx_imap_auth_methods }, + NGX_MAIL_SRV_CONF_OFFSET, + offsetof(ngx_mail_core_srv_conf_t, pop3_auth_methods), + &ngx_pop3_auth_methods }, + + { ngx_string("smtp_auth"), + NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_1MORE, + ngx_conf_set_bitmask_slot, + NGX_MAIL_SRV_CONF_OFFSET, + offsetof(ngx_mail_core_srv_conf_t, smtp_auth_methods), + &ngx_smtp_auth_methods }, ngx_null_command }; -static ngx_imap_module_t ngx_imap_core_module_ctx = { - ngx_imap_core_create_main_conf, /* create main configuration */ +static ngx_mail_module_t ngx_mail_core_module_ctx = { + ngx_mail_core_create_main_conf, /* create main configuration */ NULL, /* init main configuration */ - ngx_imap_core_create_srv_conf, /* create server configuration */ - ngx_imap_core_merge_srv_conf /* merge server configuration */ + ngx_mail_core_create_srv_conf, /* create server configuration */ + ngx_mail_core_merge_srv_conf /* merge server configuration */ }; -ngx_module_t ngx_imap_core_module = { +ngx_module_t ngx_mail_core_module = { NGX_MODULE_V1, - &ngx_imap_core_module_ctx, /* module context */ - ngx_imap_core_commands, /* module directives */ - NGX_IMAP_MODULE, /* module type */ + &ngx_mail_core_module_ctx, /* module context */ + ngx_mail_core_commands, /* module directives */ + NGX_MAIL_MODULE, /* module type */ NULL, /* init master */ NULL, /* init module */ NULL, /* init process */ @@ -171,23 +209,23 @@ ngx_module_t ngx_imap_core_module = { static void * -ngx_imap_core_create_main_conf(ngx_conf_t *cf) +ngx_mail_core_create_main_conf(ngx_conf_t *cf) { - ngx_imap_core_main_conf_t *cmcf; + ngx_mail_core_main_conf_t *cmcf; - cmcf = ngx_pcalloc(cf->pool, sizeof(ngx_imap_core_main_conf_t)); + cmcf = ngx_pcalloc(cf->pool, sizeof(ngx_mail_core_main_conf_t)); if (cmcf == NULL) { return NGX_CONF_ERROR; } if (ngx_array_init(&cmcf->servers, cf->pool, 4, - sizeof(ngx_imap_core_srv_conf_t *)) + sizeof(ngx_mail_core_srv_conf_t *)) != NGX_OK) { return NGX_CONF_ERROR; } - if (ngx_array_init(&cmcf->listen, cf->pool, 4, sizeof(ngx_imap_listen_t)) + if (ngx_array_init(&cmcf->listen, cf->pool, 4, sizeof(ngx_mail_listen_t)) != NGX_OK) { return NGX_CONF_ERROR; @@ -198,11 +236,11 @@ ngx_imap_core_create_main_conf(ngx_conf_ static void * -ngx_imap_core_create_srv_conf(ngx_conf_t *cf) +ngx_mail_core_create_srv_conf(ngx_conf_t *cf) { - ngx_imap_core_srv_conf_t *cscf; + ngx_mail_core_srv_conf_t *cscf; - cscf = ngx_pcalloc(cf->pool, sizeof(ngx_imap_core_srv_conf_t)); + cscf = ngx_pcalloc(cf->pool, sizeof(ngx_mail_core_srv_conf_t)); if (cscf == NULL) { return NULL; } @@ -224,32 +262,46 @@ ngx_imap_core_create_srv_conf(ngx_conf_t return NULL; } + if (ngx_array_init(&cscf->smtp_capabilities, cf->pool, 4, sizeof(ngx_str_t)) + != NGX_OK) + { + return NULL; + } + return cscf; } static char * -ngx_imap_core_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child) +ngx_mail_core_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child) { - ngx_imap_core_srv_conf_t *prev = parent; - ngx_imap_core_srv_conf_t *conf = child; + ngx_mail_core_srv_conf_t *prev = parent; + ngx_mail_core_srv_conf_t *conf = child; u_char *p; - size_t size; + size_t size, stls_only_size; ngx_str_t *c, *d; - ngx_uint_t i; + ngx_uint_t i, m; ngx_conf_merge_size_value(conf->imap_client_buffer_size, prev->imap_client_buffer_size, (size_t) ngx_pagesize); ngx_conf_merge_msec_value(conf->timeout, prev->timeout, 60000); ngx_conf_merge_uint_value(conf->protocol, prev->protocol, - NGX_IMAP_IMAP_PROTOCOL); + NGX_MAIL_IMAP_PROTOCOL); ngx_conf_merge_value(conf->so_keepalive, prev->so_keepalive, 0); - ngx_conf_merge_bitmask_value(conf->auth_methods, prev->auth_methods, - (NGX_CONF_BITMASK_SET|NGX_IMAP_AUTH_PLAIN_ENABLED)); + ngx_conf_merge_bitmask_value(conf->pop3_auth_methods, + prev->pop3_auth_methods, + (NGX_CONF_BITMASK_SET + |NGX_MAIL_AUTH_PLAIN_ENABLED)); + + ngx_conf_merge_bitmask_value(conf->smtp_auth_methods, + prev->smtp_auth_methods, + (NGX_CONF_BITMASK_SET + |NGX_MAIL_AUTH_PLAIN_ENABLED + |NGX_MAIL_AUTH_LOGIN_ENABLED)); ngx_conf_merge_str_value(conf->server_name, prev->server_name, ""); @@ -291,12 +343,20 @@ ngx_imap_core_merge_srv_conf(ngx_conf_t size = sizeof("+OK Capability list follows" CRLF) - 1 + sizeof("." CRLF) - 1; + stls_only_size = size + sizeof("STLS" CRLF) - 1; + c = conf->pop3_capabilities.elts; for (i = 0; i < conf->pop3_capabilities.nelts; i++) { size += c[i].len + sizeof(CRLF) - 1; + + if (ngx_strcasecmp(c[i].data, (u_char *) "USER") == 0) { + continue; + } + + stls_only_size += c[i].len + sizeof(CRLF) - 1; } - if (conf->auth_methods & NGX_IMAP_AUTH_CRAM_MD5_ENABLED) { + if (conf->pop3_auth_methods & NGX_MAIL_AUTH_CRAM_MD5_ENABLED) { size += sizeof("SASL LOGIN PLAIN CRAM-MD5" CRLF) - 1; } else { @@ -319,7 +379,7 @@ ngx_imap_core_merge_srv_conf(ngx_conf_t *p++ = CR; *p++ = LF; } - if (conf->auth_methods & NGX_IMAP_AUTH_CRAM_MD5_ENABLED) { + if (conf->pop3_auth_methods & NGX_MAIL_AUTH_CRAM_MD5_ENABLED) { p = ngx_cpymem(p, "SASL LOGIN PLAIN CRAM-MD5" CRLF, sizeof("SASL LOGIN PLAIN CRAM-MD5" CRLF) - 1); @@ -348,7 +408,7 @@ ngx_imap_core_merge_srv_conf(ngx_conf_t *p++ = '.'; *p++ = CR; *p = LF; - if (conf->auth_methods & NGX_IMAP_AUTH_CRAM_MD5_ENABLED) { + if (conf->pop3_auth_methods & NGX_MAIL_AUTH_CRAM_MD5_ENABLED) { conf->pop3_auth_capability = ngx_pop3_auth_cram_md5_capability; } else { @@ -356,6 +416,30 @@ ngx_imap_core_merge_srv_conf(ngx_conf_t } + p = ngx_palloc(cf->pool, stls_only_size); + if (p == NULL) { + return NGX_CONF_ERROR; + } + + conf->pop3_starttls_only_capability.len = stls_only_size; + conf->pop3_starttls_only_capability.data = p; + + p = ngx_cpymem(p, "+OK Capability list follows" CRLF, + sizeof("+OK Capability list follows" CRLF) - 1); + + for (i = 0; i < conf->pop3_capabilities.nelts; i++) { + if (ngx_strcasecmp(c[i].data, (u_char *) "USER") == 0) { + continue; + } + + p = ngx_cpymem(p, c[i].data, c[i].len); + *p++ = CR; *p++ = LF; + } + + p = ngx_cpymem(p, "STLS" CRLF, sizeof("STLS" CRLF) - 1); + *p++ = '.'; *p++ = CR; *p = LF; + + if (conf->imap_capabilities.nelts == 0) { conf->imap_capabilities = prev->imap_capabilities; } @@ -372,7 +456,7 @@ ngx_imap_core_merge_srv_conf(ngx_conf_t } } - size = sizeof("* CAPABILITY") - 1 + sizeof(CRLF) - 1; + size = sizeof("* CAPABILITY" CRLF) - 1; c = conf->imap_capabilities.elts; for (i = 0; i < conf->imap_capabilities.nelts; i++) { @@ -429,40 +513,125 @@ ngx_imap_core_merge_srv_conf(ngx_conf_t *p++ = CR; *p = LF; + size = sizeof("220 ESMTP ready" CRLF) - 1 + conf->server_name.len; + + p = ngx_palloc(cf->pool, size); + if (p == NULL) { + return NGX_CONF_ERROR; + } + + conf->smtp_greeting.len = size; + conf->smtp_greeting.data = p; + + *p++ = '2'; *p++ = '2'; *p++ = '0'; *p++ = ' '; + p = ngx_cpymem(p, conf->server_name.data, conf->server_name.len); + ngx_memcpy(p, " ESMTP ready" CRLF, sizeof(" ESMTP ready" CRLF) - 1); + + + size = sizeof("250 " CRLF) - 1 + conf->server_name.len; + + p = ngx_palloc(cf->pool, size); + if (p == NULL) { + return NGX_CONF_ERROR; + } + + conf->smtp_server_name.len = size; + conf->smtp_server_name.data = p; + + *p++ = '2'; *p++ = '5'; *p++ = '0'; *p++ = ' '; + p = ngx_cpymem(p, conf->server_name.data, conf->server_name.len); + *p++ = CR; *p = LF; + + + if (conf->smtp_capabilities.nelts == 0) { + conf->smtp_capabilities = prev->smtp_capabilities; + } + + size = sizeof("250-") - 1 + conf->server_name.len + sizeof(CRLF) - 1 + + sizeof("250 AUTH") - 1 + sizeof(CRLF) - 1; + + c = conf->smtp_capabilities.elts; + for (i = 0; i < conf->smtp_capabilities.nelts; i++) { + size += sizeof("250 ") - 1 + c[i].len + sizeof(CRLF) - 1; + } + + for (m = NGX_MAIL_AUTH_PLAIN_ENABLED, i = 0; + m <= NGX_MAIL_AUTH_CRAM_MD5_ENABLED; + m <<= 1, i++) + { + if (m & conf->smtp_auth_methods) { + size += 1 + ngx_smtp_auth_methods_names[i].len; + } + } + + p = ngx_palloc(cf->pool, size); + if (p == NULL) { + return NGX_CONF_ERROR; + } + + conf->smtp_capability.len = size; + conf->smtp_capability.data = p; + + *p++ = '2'; *p++ = '5'; *p++ = '0'; *p++ = '-'; + p = ngx_cpymem(p, conf->server_name.data, conf->server_name.len); + *p++ = CR; *p++ = LF; + + for (i = 0; i < conf->smtp_capabilities.nelts; i++) { + *p++ = '2'; *p++ = '5'; *p++ = '0'; *p++ = '-'; + p = ngx_cpymem(p, c[i].data, c[i].len); + *p++ = CR; *p++ = LF; + } + + *p++ = '2'; *p++ = '5'; *p++ = '0'; *p++ = ' '; + *p++ = 'A'; *p++ = 'U'; *p++ = 'T'; *p++ = 'H'; + + for (m = NGX_MAIL_AUTH_PLAIN_ENABLED, i = 0; + m <= NGX_MAIL_AUTH_CRAM_MD5_ENABLED; + m <<= 1, i++) + { + if (m & conf->smtp_auth_methods) { + *p++ = ' '; + p = ngx_cpymem(p, ngx_smtp_auth_methods_names[i].data, + ngx_smtp_auth_methods_names[i].len); + } + } + + *p++ = CR; *p = LF; + return NGX_CONF_OK; } static char * -ngx_imap_core_server(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) +ngx_mail_core_server(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { char *rv; void *mconf; ngx_uint_t m; ngx_conf_t pcf; - ngx_imap_module_t *module; - ngx_imap_conf_ctx_t *ctx, *imap_ctx; - ngx_imap_core_srv_conf_t *cscf, **cscfp; - ngx_imap_core_main_conf_t *cmcf; + ngx_mail_module_t *module; + ngx_mail_conf_ctx_t *ctx, *mail_ctx; + ngx_mail_core_srv_conf_t *cscf, **cscfp; + ngx_mail_core_main_conf_t *cmcf; - ctx = ngx_pcalloc(cf->pool, sizeof(ngx_imap_conf_ctx_t)); + ctx = ngx_pcalloc(cf->pool, sizeof(ngx_mail_conf_ctx_t)); if (ctx == NULL) { return NGX_CONF_ERROR; } - imap_ctx = cf->ctx; - ctx->main_conf = imap_ctx->main_conf; + mail_ctx = cf->ctx; + ctx->main_conf = mail_ctx->main_conf; /* the server{}'s srv_conf */ - ctx->srv_conf = ngx_pcalloc(cf->pool, sizeof(void *) * ngx_imap_max_module); + ctx->srv_conf = ngx_pcalloc(cf->pool, sizeof(void *) * ngx_mail_max_module); if (ctx->srv_conf == NULL) { return NGX_CONF_ERROR; } for (m = 0; ngx_modules[m]; m++) { - if (ngx_modules[m]->type != NGX_IMAP_MODULE) { + if (ngx_modules[m]->type != NGX_MAIL_MODULE) { continue; } @@ -480,10 +649,10 @@ ngx_imap_core_server(ngx_conf_t *cf, ngx /* the server configuration context */ - cscf = ctx->srv_conf[ngx_imap_core_module.ctx_index]; + cscf = ctx->srv_conf[ngx_mail_core_module.ctx_index]; cscf->ctx = ctx; - cmcf = ctx->main_conf[ngx_imap_core_module.ctx_index]; + cmcf = ctx->main_conf[ngx_mail_core_module.ctx_index]; cscfp = ngx_array_push(&cmcf->servers); if (cscfp == NULL) { @@ -497,7 +666,7 @@ ngx_imap_core_server(ngx_conf_t *cf, ngx pcf = *cf; cf->ctx = ctx; - cf->cmd_type = NGX_IMAP_SRV_CONF; + cf->cmd_type = NGX_MAIL_SRV_CONF; rv = ngx_conf_parse(cf, NULL); @@ -510,13 +679,13 @@ ngx_imap_core_server(ngx_conf_t *cf, ngx /* AF_INET only */ static char * -ngx_imap_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) +ngx_mail_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { ngx_str_t *value; ngx_url_t u; ngx_uint_t i; - ngx_imap_listen_t *imls; - ngx_imap_core_main_conf_t *cmcf; + ngx_mail_listen_t *imls; + ngx_mail_core_main_conf_t *cmcf; value = cf->args->elts; @@ -535,7 +704,7 @@ ngx_imap_core_listen(ngx_conf_t *cf, ngx return NGX_CONF_ERROR; } - cmcf = ngx_imap_conf_get_module_main_conf(cf, ngx_imap_core_module); + cmcf = ngx_mail_conf_get_module_main_conf(cf, ngx_mail_core_module); imls = cmcf->listen.elts; @@ -555,7 +724,7 @@ ngx_imap_core_listen(ngx_conf_t *cf, ngx return NGX_CONF_ERROR; } - ngx_memzero(imls, sizeof(ngx_imap_listen_t)); + ngx_memzero(imls, sizeof(ngx_mail_listen_t)); imls->addr = u.addr.in_addr; imls->port = u.port; @@ -578,7 +747,7 @@ ngx_imap_core_listen(ngx_conf_t *cf, ngx static char * -ngx_imap_core_capability(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) +ngx_mail_core_capability(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { char *p = conf;