comparison src/mail/ngx_mail_parse.c @ 336:1c519aff5c0c NGINX_0_6_12

nginx 0.6.12 *) Change: mail proxy was split on three modules: pop3, imap and smtp. *) Feature: the --without-mail_pop3_module, --without-mail_imap_module, and --without-mail_smtp_module configuration parameters. *) Feature: the "smtp_greeting_delay" and "smtp_client_buffer" directives of the ngx_mail_smtp_module. *) Bugfix: the trailing wildcards did not work; bug appeared in 0.6.9. *) Bugfix: nginx could not start on Solaris if the shared PCRE library located in non-standard place was used. *) Bugfix: the "proxy_hide_header" and "fastcgi_hide_header" directives did not hide response header lines whose name was longer than 32 characters. Thanks to Manlio Perillo.
author Igor Sysoev <http://sysoev.ru>
date Fri, 21 Sep 2007 00:00:00 +0400
parents 390b8f8309d6
children ad0a34a8efa6
comparison
equal deleted inserted replaced
335:9a32ae248b7a 336:1c519aff5c0c
8 #include <ngx_core.h> 8 #include <ngx_core.h>
9 #include <ngx_event.h> 9 #include <ngx_event.h>
10 #include <ngx_mail.h> 10 #include <ngx_mail.h>
11 11
12 12
13 ngx_int_t ngx_pop3_parse_command(ngx_mail_session_t *s) 13 ngx_int_t
14 ngx_mail_pop3_parse_command(ngx_mail_session_t *s)
14 { 15 {
15 u_char ch, *p, *c, c0, c1, c2, c3; 16 u_char ch, *p, *c, c0, c1, c2, c3;
16 ngx_str_t *arg; 17 ngx_str_t *arg;
17 enum { 18 enum {
18 sw_start = 0, 19 sw_start = 0,
205 206
206 return NGX_MAIL_PARSE_INVALID_COMMAND; 207 return NGX_MAIL_PARSE_INVALID_COMMAND;
207 } 208 }
208 209
209 210
210 ngx_int_t ngx_imap_parse_command(ngx_mail_session_t *s) 211 ngx_int_t
212 ngx_mail_imap_parse_command(ngx_mail_session_t *s)
211 { 213 {
212 u_char ch, *p, *c; 214 u_char ch, *p, *c;
213 ngx_str_t *arg; 215 ngx_str_t *arg;
214 enum { 216 enum {
215 sw_start = 0, 217 sw_start = 0,
611 613
612 return NGX_MAIL_PARSE_INVALID_COMMAND; 614 return NGX_MAIL_PARSE_INVALID_COMMAND;
613 } 615 }
614 616
615 617
616 ngx_int_t ngx_smtp_parse_command(ngx_mail_session_t *s) 618 ngx_int_t
619 ngx_mail_smtp_parse_command(ngx_mail_session_t *s)
617 { 620 {
618 u_char ch, *p, *c, c0, c1, c2, c3; 621 u_char ch, *p, *c, c0, c1, c2, c3;
619 ngx_str_t *arg; 622 ngx_str_t *arg;
620 enum { 623 enum {
621 sw_start = 0, 624 sw_start = 0,
820 s->state = sw_start; 823 s->state = sw_start;
821 s->arg_start = NULL; 824 s->arg_start = NULL;
822 825
823 return NGX_MAIL_PARSE_INVALID_COMMAND; 826 return NGX_MAIL_PARSE_INVALID_COMMAND;
824 } 827 }
828
829
830 ngx_int_t
831 ngx_mail_auth_parse(ngx_mail_session_t *s, ngx_connection_t *c)
832 {
833 ngx_str_t *arg;
834
835 #if (NGX_MAIL_SSL)
836 if (ngx_mail_starttls_only(s, c)) {
837 return NGX_MAIL_PARSE_INVALID_COMMAND;
838 }
839 #endif
840
841 arg = s->args.elts;
842
843 if (arg[0].len == 5) {
844
845 if (ngx_strncasecmp(arg[0].data, (u_char *) "LOGIN", 5) == 0) {
846
847 if (s->args.nelts == 1) {
848 return NGX_MAIL_AUTH_LOGIN;
849 }
850
851 return NGX_MAIL_PARSE_INVALID_COMMAND;
852 }
853
854 if (ngx_strncasecmp(arg[0].data, (u_char *) "PLAIN", 5) == 0) {
855
856 if (s->args.nelts == 1) {
857 return NGX_MAIL_AUTH_PLAIN;
858 }
859
860 if (s->args.nelts == 2) {
861 return ngx_mail_auth_plain(s, c, 1);
862 }
863 }
864
865 return NGX_MAIL_PARSE_INVALID_COMMAND;
866 }
867
868 if (arg[0].len == 8) {
869
870 if (s->args.nelts != 1) {
871 return NGX_MAIL_PARSE_INVALID_COMMAND;
872 }
873
874 if (ngx_strncasecmp(arg[0].data, (u_char *) "CRAM-MD5", 8) == 0) {
875 return NGX_MAIL_AUTH_CRAM_MD5;
876 }
877 }
878
879 return NGX_MAIL_PARSE_INVALID_COMMAND;
880 }