~ubuntu-branches/ubuntu/jaunty/nginx/jaunty-updates

« back to all changes in this revision

Viewing changes to src/mail/ngx_mail_parse.c

  • Committer: Bazaar Package Importer
  • Author(s): Jose Parrella
  • Date: 2007-12-08 11:27:54 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20071208112754-23ohg2b1zshkdayw
Tags: 0.5.33-1
* New stable upstream release (Closes: #451173)
* nginx now provides httpd, httpd-cgi virtual packages
  (Closes: #439468, #452025)
* sites-enabled/default link is now provided only on fresh 
  installations (Closes: #432961)
* Updated code for online upgrading of nginx (Closes: #445246)
* Reviewed maintainer scripts for correct behaviour on updates
  (Closes: #452787, #435965)
* Removed debian/nginx.links and debian/preinst.
* Changing Maintainer address to bureado@debian.org.
* Welcoming Fabio Tranchitella <kobold@debian.org> as an nginx 
  uploader for Debian. Thanks for your patches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
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
16
    u_char      ch, *p, *c, c0, c1, c2, c3;
16
17
    ngx_str_t  *arg;
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
214
    u_char      ch, *p, *c;
213
215
    ngx_str_t  *arg;
354
356
                    }
355
357
                    break;
356
358
 
 
359
                case 12:
 
360
                    if ((c[0] == 'A'|| c[0] == 'a')
 
361
                        && (c[1] == 'U'|| c[1] == 'u')
 
362
                        && (c[2] == 'T'|| c[2] == 't')
 
363
                        && (c[3] == 'H'|| c[3] == 'h')
 
364
                        && (c[4] == 'E'|| c[4] == 'e')
 
365
                        && (c[5] == 'N'|| c[5] == 'n')
 
366
                        && (c[6] == 'T'|| c[6] == 't')
 
367
                        && (c[7] == 'I'|| c[7] == 'i')
 
368
                        && (c[8] == 'C'|| c[8] == 'c')
 
369
                        && (c[9] == 'A'|| c[9] == 'a')
 
370
                        && (c[10] == 'T'|| c[10] == 't')
 
371
                        && (c[11] == 'E'|| c[11] == 'e'))
 
372
                    {
 
373
                        s->command = NGX_IMAP_AUTHENTICATE;
 
374
 
 
375
                    } else {
 
376
                        goto invalid;
 
377
                    }
 
378
                    break;
 
379
 
357
380
                default:
358
381
                    goto invalid;
359
382
                }
413
436
            break;
414
437
 
415
438
        case sw_argument:
 
439
            if (ch == ' ' && s->quoted) {
 
440
                break;
 
441
            }
 
442
 
416
443
            switch (ch) {
417
444
            case '"':
418
445
                if (!s->quoted) {
573
600
        s->literal_len = 0;
574
601
    }
575
602
 
576
 
    s->state = sw_start;
 
603
    s->state = (s->command != NGX_IMAP_AUTHENTICATE) ? sw_start : sw_argument;
577
604
 
578
605
    return NGX_OK;
579
606
 
588
615
}
589
616
 
590
617
 
591
 
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)
592
620
{
593
621
    u_char      ch, *p, *c, c0, c1, c2, c3;
594
622
    ngx_str_t  *arg;
646
674
                    {
647
675
                        s->command = NGX_SMTP_RSET;
648
676
 
649
 
                    } else {
650
 
                        goto invalid;
651
 
                    }
652
 
 
 
677
                    } else if (c0 == 'R' && c1 == 'C' && c2 == 'P' && c3 == 'T')
 
678
                    {
 
679
                        s->command = NGX_SMTP_RCPT;
 
680
 
 
681
                    } else if (c0 == 'V' && c1 == 'R' && c2 == 'F' && c3 == 'Y')
 
682
                    {
 
683
                        s->command = NGX_SMTP_VRFY;
 
684
 
 
685
                    } else if (c0 == 'E' && c1 == 'X' && c2 == 'P' && c3 == 'N')
 
686
                    {
 
687
                        s->command = NGX_SMTP_EXPN;
 
688
 
 
689
                    } else if (c0 == 'H' && c1 == 'E' && c2 == 'L' && c3 == 'P')
 
690
                    {
 
691
                        s->command = NGX_SMTP_HELP;
 
692
 
 
693
                    } else {
 
694
                        goto invalid;
 
695
                    }
 
696
#if (NGX_MAIL_SSL)
 
697
                } else if (p - c == 8) {
 
698
 
 
699
                    if ((c[0] == 'S'|| c[0] == 's')
 
700
                        && (c[1] == 'T'|| c[1] == 't')
 
701
                        && (c[2] == 'A'|| c[2] == 'a')
 
702
                        && (c[3] == 'R'|| c[3] == 'r')
 
703
                        && (c[4] == 'T'|| c[4] == 't')
 
704
                        && (c[5] == 'T'|| c[5] == 't')
 
705
                        && (c[6] == 'L'|| c[6] == 'l')
 
706
                        && (c[7] == 'S'|| c[7] == 's'))
 
707
                    {
 
708
                        s->command = NGX_SMTP_STARTTLS;
 
709
 
 
710
                    } else {
 
711
                        goto invalid;
 
712
                    }
 
713
#endif
653
714
                } else {
654
715
                    goto invalid;
655
716
                }
764
825
 
765
826
    return NGX_MAIL_PARSE_INVALID_COMMAND;
766
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
}