]> code.citadel.org Git - citadel.git/blobdiff - citadel/serv_smtp.c
*** empty log message ***
[citadel.git] / citadel / serv_smtp.c
index 87ab1b80963b4ade4fcb9ebdc674a433e3f437e4..b150272d88027fa881aa5ff2d65bfe9a9cdaa8aa 100644 (file)
@@ -62,7 +62,7 @@
 struct citsmtp {               /* Information about the current session */
        int command_state;
        char helo_node[SIZ];
-       struct usersupp vrfy_buffer;
+       struct user vrfy_buffer;
        int vrfy_count;
        char vrfy_match[SIZ];
        char from[SIZ];
@@ -136,7 +136,7 @@ void smtp_hello(char *argbuf, int is_esmtp) {
                cprintf("250-HELP\r\n");
                cprintf("250-SIZE %ld\r\n", config.c_maxmsglen);
                cprintf("250-PIPELINING\r\n");
-               cprintf("250 AUTH=LOGIN\r\n");
+               cprintf("250-AUTH=LOGIN\r\n");
                cprintf("250 ENHANCEDSTATUSCODES\r\n");
        }
 }
@@ -192,7 +192,7 @@ void smtp_get_pass(char *argbuf) {
        CtdlDecodeBase64(password, argbuf, SIZ);
        lprintf(9, "Trying <%s>\n", password);
        if (CtdlTryPassword(password) == pass_ok) {
-               cprintf("235 2.0.0 Hello, %s\r\n", CC->usersupp.fullname);
+               cprintf("235 2.0.0 Hello, %s\r\n", CC->user.fullname);
                lprintf(9, "SMTP authenticated login successful\n");
                CC->internal_pgm = 0;
                CC->cs_flags &= ~CS_STEALTH;
@@ -230,11 +230,11 @@ void smtp_auth(char *argbuf) {
 /*
  * Back end for smtp_vrfy() command
  */
-void smtp_vrfy_backend(struct usersupp *us, void *data) {
+void smtp_vrfy_backend(struct user *us, void *data) {
 
        if (!fuzzy_match(us, SMTP->vrfy_match)) {
                ++SMTP->vrfy_count;
-               memcpy(&SMTP->vrfy_buffer, us, sizeof(struct usersupp));
+               memcpy(&SMTP->vrfy_buffer, us, sizeof(struct user));
        }
 }
 
@@ -269,7 +269,7 @@ void smtp_vrfy(char *argbuf) {
 /*
  * Back end for smtp_expn() command
  */
-void smtp_expn_backend(struct usersupp *us, void *data) {
+void smtp_expn_backend(struct user *us, void *data) {
 
        if (!fuzzy_match(us, SMTP->vrfy_match)) {
 
@@ -281,7 +281,7 @@ void smtp_expn_backend(struct usersupp *us, void *data) {
                }
 
                ++SMTP->vrfy_count;
-               memcpy(&SMTP->vrfy_buffer, us, sizeof(struct usersupp));
+               memcpy(&SMTP->vrfy_buffer, us, sizeof(struct user));
        }
 }
 
@@ -366,9 +366,14 @@ void smtp_mail(char *argbuf) {
        striplt(SMTP->from);
        stripallbut(SMTP->from, '<', '>');
 
+       /* We used to reject empty sender names, until it was brought to our
+        * attention that RFC1123 5.2.9 requires that this be allowed.  So now
+        * we allow it, but replace the empty string with a fake
+        * address so we don't have to contend with the empty string causing
+        * other code to fail when it's expecting something there.
+        */
        if (strlen(SMTP->from) == 0) {
-               cprintf("501 5.1.7 Empty sender name is not permitted\r\n");
-               return;
+               strcpy(SMTP->from, "someone@somewhere.org");
        }
 
        /* If this SMTP connection is from a logged-in user, force the 'from'
@@ -376,7 +381,7 @@ void smtp_mail(char *argbuf) {
         */
        if (CC->logged_in) {
                strcpy(SMTP->from, CC->cs_inet_email);
-               cprintf("250 2.0.0 Sender ok <%s>\r\n", SMTP->from);
+               cprintf("250 2.1.0 Sender ok <%s>\r\n", SMTP->from);
                SMTP->message_originated_locally = 1;
                return;
        }
@@ -445,13 +450,13 @@ void smtp_rcpt(char *argbuf) {
 
        if (valid->num_internet > 0) {
                if (SMTP->message_originated_locally == 0) {
-                       cprintf("551 5.7.1 Relaying denied <%s>\r\n", recp);
+                       cprintf("551 5.7.1 <%s> - relaying denied\r\n", recp);
                        phree(valid);
                        return;
                }
        }
 
-       cprintf("250 2.0.0 RCPT ok <%s>\r\n", recp);
+       cprintf("250 2.1.5 RCPT ok <%s>\r\n", recp);
        if (strlen(SMTP->recipients) > 0) {
                strcat(SMTP->recipients, ",");
        }
@@ -483,7 +488,7 @@ void smtp_data(void) {
                return;
        }
 
-       cprintf("354 Transmit message now; terminate with '.' by itself\r\n");
+       cprintf("354 Transmit message now - terminate with '.' by itself\r\n");
        
        datestring(nowstamp, sizeof nowstamp, time(NULL), DATESTRING_RFC822);
        body = mallok(4096);
@@ -525,7 +530,7 @@ void smtp_data(void) {
                if (msg->cm_fields['H'] != NULL) phree(msg->cm_fields['H']);
                if (msg->cm_fields['F'] != NULL) phree(msg->cm_fields['F']);
                if (msg->cm_fields['O'] != NULL) phree(msg->cm_fields['O']);
-               msg->cm_fields['A'] = strdoop(CC->usersupp.fullname);
+               msg->cm_fields['A'] = strdoop(CC->user.fullname);
                msg->cm_fields['N'] = strdoop(config.c_nodename);
                msg->cm_fields['H'] = strdoop(config.c_humannode);
                msg->cm_fields['F'] = strdoop(CC->cs_inet_email);
@@ -758,7 +763,8 @@ void smtp_try(const char *key, const char *addr, int *status,
                return;
        }
 
-       for (mx=0; mx<num_mxhosts; ++mx) {
+       sock = (-1);
+       for (mx=0; (mx<num_mxhosts && sock < 0); ++mx) {
                extract(buf, mxhosts, mx);
                lprintf(9, "Trying <%s>\n", buf);
                sock = sock_connect(buf, "25", "tcp");
@@ -1342,7 +1348,7 @@ void smtp_do_queue(void) {
         */
        lprintf(7, "SMTP: processing outbound queue\n");
 
-       if (getroom(&CC->quickroom, SMTP_SPOOLOUT_ROOM) != 0) {
+       if (getroom(&CC->room, SMTP_SPOOLOUT_ROOM) != 0) {
                lprintf(3, "Cannot find room <%s>\n", SMTP_SPOOLOUT_ROOM);
                return;
        }
@@ -1401,7 +1407,7 @@ void cmd_smtp(char *argbuf) {
  * Initialize the SMTP outbound queue
  */
 void smtp_init_spoolout(void) {
-       struct quickroom qrbuf;
+       struct room qrbuf;
 
        /*
         * Create the room.  This will silently fail if the room already