Mercurial > hg > nginx
diff src/mail/ngx_mail_parse.c @ 1621:ed9cd1702f7a stable-0.5
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
r1487, r1488, r1494, r1495, r1499 merge:
*) ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
*) smtp_client_buffer and smtp_greeting_delay
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 07 Nov 2007 14:24:55 +0000 |
parents | b19709ee1f52 |
children |
line wrap: on
line diff
--- a/src/mail/ngx_mail_parse.c +++ b/src/mail/ngx_mail_parse.c @@ -10,7 +10,8 @@ #include <ngx_mail.h> -ngx_int_t ngx_pop3_parse_command(ngx_mail_session_t *s) +ngx_int_t +ngx_mail_pop3_parse_command(ngx_mail_session_t *s) { u_char ch, *p, *c, c0, c1, c2, c3; ngx_str_t *arg; @@ -207,7 +208,8 @@ invalid: } -ngx_int_t ngx_imap_parse_command(ngx_mail_session_t *s) +ngx_int_t +ngx_mail_imap_parse_command(ngx_mail_session_t *s) { u_char ch, *p, *c; ngx_str_t *arg; @@ -613,7 +615,8 @@ invalid: } -ngx_int_t ngx_smtp_parse_command(ngx_mail_session_t *s) +ngx_int_t +ngx_mail_smtp_parse_command(ngx_mail_session_t *s) { u_char ch, *p, *c, c0, c1, c2, c3; ngx_str_t *arg; @@ -822,3 +825,56 @@ invalid: return NGX_MAIL_PARSE_INVALID_COMMAND; } + + +ngx_int_t +ngx_mail_auth_parse(ngx_mail_session_t *s, ngx_connection_t *c) +{ + ngx_str_t *arg; + +#if (NGX_MAIL_SSL) + if (ngx_mail_starttls_only(s, c)) { + return NGX_MAIL_PARSE_INVALID_COMMAND; + } +#endif + + arg = s->args.elts; + + if (arg[0].len == 5) { + + if (ngx_strncasecmp(arg[0].data, (u_char *) "LOGIN", 5) == 0) { + + if (s->args.nelts == 1) { + return NGX_MAIL_AUTH_LOGIN; + } + + return NGX_MAIL_PARSE_INVALID_COMMAND; + } + + if (ngx_strncasecmp(arg[0].data, (u_char *) "PLAIN", 5) == 0) { + + if (s->args.nelts == 1) { + return NGX_MAIL_AUTH_PLAIN; + } + + if (s->args.nelts == 2) { + return ngx_mail_auth_plain(s, c, 1); + } + } + + return NGX_MAIL_PARSE_INVALID_COMMAND; + } + + if (arg[0].len == 8) { + + if (s->args.nelts != 1) { + return NGX_MAIL_PARSE_INVALID_COMMAND; + } + + if (ngx_strncasecmp(arg[0].data, (u_char *) "CRAM-MD5", 8) == 0) { + return NGX_MAIL_AUTH_CRAM_MD5; + } + } + + return NGX_MAIL_PARSE_INVALID_COMMAND; +}