]> code.citadel.org Git - citadel.git/commitdiff
* smtp FROM command now validates sender using the validate_recipients() loop
authorArt Cancro <ajc@citadel.org>
Sat, 26 Jan 2002 04:59:58 +0000 (04:59 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 26 Jan 2002 04:59:58 +0000 (04:59 +0000)
  (yeah, it's good for that too) making it directory-aware

citadel/ChangeLog
citadel/msgbase.c
citadel/serv_smtp.c

index 65eec83a5b44901cfb1a74d783f209ec805639db..8f651de43c6021ff5228c024e66e9b3e8ab12ec9 100644 (file)
@@ -1,4 +1,8 @@
  $Log$
+ Revision 590.89  2002/01/26 04:59:57  ajc
+ * smtp FROM command now validates sender using the validate_recipients() loop
+   (yeah, it's good for that too) making it directory-aware
+
  Revision 590.88  2002/01/26 04:01:10  error
  * Formatter now uses more of the available screen width
 
@@ -3244,4 +3248,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import 
-
index 47b3a6fa854a09423fbcdb15887017d98dc9c0ba..8eba07ce4cb0ce865fb998794b8dc158c54385f9 100644 (file)
@@ -2211,6 +2211,8 @@ struct recptypes *validate_recipients(char *recipients) {
                striplt(this_recp);
                lprintf(9, "Evaluating recipient #%d <%s>\n", i, this_recp);
                mailtype = alias(this_recp);
+               mailtype = alias(this_recp);
+               mailtype = alias(this_recp);
                invalid = 0;
                switch(mailtype) {
                        case MES_LOCAL:
@@ -2287,6 +2289,13 @@ struct recptypes *validate_recipients(char *recipients) {
                strcpy(ret->errormsg, "No recipients specified.");
        }
 
+       lprintf(9, "validate_recipients()\n");
+       lprintf(9, " local: %d <%s>\n", ret->num_local, ret->recp_local);
+       lprintf(9, "  room: %d <%s>\n", ret->num_room, ret->recp_room);
+       lprintf(9, "  inet: %d <%s>\n", ret->num_internet, ret->recp_internet);
+       lprintf(9, " ignet: %d <%s>\n", ret->num_ignet, ret->recp_ignet);
+       lprintf(9, " error: %d <%s>\n", ret->num_error, ret->errormsg);
+
        return(ret);
 }
 
index dad23b4c63b4230b3ab7e8e6780ecf16265c9a4a..e7ac6a00f095c12c61b966452d7ab4d6daa92fbe 100644 (file)
@@ -336,7 +336,8 @@ void smtp_data_clear(void) {
 void smtp_mail(char *argbuf) {
        char user[SIZ];
        char node[SIZ];
-       int cvt;
+       char name[SIZ];
+       struct recptypes *valid;
 
        if (strlen(SMTP->from) != 0) {
                cprintf("503 Only one sender permitted\r\n");
@@ -350,37 +351,39 @@ void smtp_mail(char *argbuf) {
 
        strcpy(SMTP->from, &argbuf[5]);
        striplt(SMTP->from);
+       stripallbut(SMTP->from, '<', '>');
 
        if (strlen(SMTP->from) == 0) {
                cprintf("501 Empty sender name is not permitted\r\n");
                return;
        }
 
-
        /* If this SMTP connection is from a logged-in user, make sure that
         * the user only sends email from his/her own address.
         */
        if (CC->logged_in) {
-               cvt = convert_internet_address(user, node, SMTP->from);
-               lprintf(9, "cvt=%d, citaddr=<%s@%s>\n", cvt, user, node);
-               if ( (cvt != 0) || (strcasecmp(user, CC->usersupp.fullname))) {
+               valid = validate_recipients(SMTP->from);
+               if ( (valid->num_local == 1) &&
+                  (!strcasecmp(valid->recp_local, CC->usersupp.fullname)) ) {
+                       cprintf("250 Sender ok <%s>\r\n", valid->recp_local);
+                       SMTP->message_originated_locally = 1;
+               }
+               else {
                        cprintf("550 <%s> is not your address.\r\n",
                                SMTP->from);
                        strcpy(SMTP->from, "");
-                       return;
-               }
-               else {
-                       SMTP->message_originated_locally = 1;
                }
+               phree(valid);
+               return;
        }
 
+
        /* Otherwise, make sure outsiders aren't trying to forge mail from
         * this system.
         */
        else {
-               cvt = convert_internet_address(user, node, SMTP->from);
-               lprintf(9, "cvt=%d, citaddr=<%s@%s>\n", cvt, user, node);
-               if (CtdlHostAlias(node) == hostalias_localhost) {
+               process_rfc822_addr(SMTP->from, user, node, name);
+               if (CtdlHostAlias(node) != hostalias_nomatch) {
                        cprintf("550 You must log in to send mail from %s\r\n",
                                node);
                        strcpy(SMTP->from, "");