* citmail.c: changes to citmail to make it usable as a /usr/sbin/sendmail
authorArt Cancro <ajc@citadel.org>
Wed, 13 Apr 2005 20:42:45 +0000 (20:42 +0000)
committerArt Cancro <ajc@citadel.org>
Wed, 13 Apr 2005 20:42:45 +0000 (20:42 +0000)
  replacement; i.e. /bin/mail calls /usr/sbin/sendmail which sends mail
  through Citadel.

citadel/ChangeLog
citadel/citmail.c
citadel/serv_smtp.c

index ee0b43eeaa2c433a3c5ef70c42b590b527ec0fd2..501bb3e8e4cc0493e9531bc0acee7aace7ecc7b9 100644 (file)
@@ -1,4 +1,9 @@
  $Log$
+ Revision 645.4  2005/04/13 20:42:44  ajc
+ * citmail.c: changes to citmail to make it usable as a /usr/sbin/sendmail
+   replacement; i.e. /bin/mail calls /usr/sbin/sendmail which sends mail
+   through Citadel.
+
  Revision 645.3  2005/04/13 17:03:07  ajc
  * Reverted database changes because the cull_logs function wasn't working
    with the separate log directory.
@@ -6591,3 +6596,4 @@ 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 e51428187929df17d6acf18d1d21e6d2d2762204..50704818d68e40b8bef2247b9c5cd9ae8d7d1601 100644 (file)
@@ -173,6 +173,8 @@ int main(int argc, char **argv) {
        FILE *fp;
        int i;
        struct passwd *pw;
+       int from_header = 0;
+       int in_body = 0;
 
        get_config();
 
@@ -185,10 +187,19 @@ int main(int argc, char **argv) {
                config.c_fqdn
        );
        while (fgets(buf, 1024, stdin) != NULL) {
-               fprintf(fp, "%s", buf);
+               if ( ( (buf[0] == 13) || (buf[0] == 10)) && (in_body == 0) ) {
+                       in_body = 1;
+                       if (from_header == 0) {
+                               fprintf(fp, "%s%s", fromline, buf);
+                       }
+               }
                if (!strncasecmp(buf, "From:", 5)) {
                        strcpy(fromline, buf);
+                       if (in_body == 0) {
+                               from_header = 1;
+                       }
                }
+               fprintf(fp, "%s", buf);
        }
        strip_trailing_nonprint(fromline);
 
index c628aa4d98f134a7df764b3f0f7accadfdf9e3a2..6c46264e9c8c6b1065b591a93cee2e02a7cfbbf1 100644 (file)
@@ -519,7 +519,9 @@ void smtp_mail(char *argbuf) {
 
        strcpy(SMTP->from, &argbuf[5]);
        striplt(SMTP->from);
-       stripallbut(SMTP->from, '<', '>');
+       if (haschar(SMTP->from, '<') > 0) {
+               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