]> jfr.im git - irc/evilnet/x3.git/blobdiff - src/sendmail.c
This needs more testing *hint hint* rubin :P I diff'ed srvx 1.3.1 to 1.3 then picked...
[irc/evilnet/x3.git] / src / sendmail.c
index 63fe69b9afe11acd3a245033dd8531eb7e411c9a..755d66a00624fc7fed17255cd5f82bad639b1f08 100644 (file)
@@ -1,7 +1,7 @@
 /* sendmail.c - mail sending utilities
  * Copyright 2002-2004 srvx Development Team
  *
- * This file is part of srvx.
+ * This file is part of x3.
  *
  * srvx is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -34,7 +34,9 @@ static const struct message_entry msgtab[] = {
     { "MAILMSG_EMAIL_BANNED", "Email to %s has been forbidden." },
     { "MAILMSG_EMAIL_NOT_BANNED", "Email to %s was not forbidden." },
     { "MAILMSG_EMAIL_UNBANNED", "Email to %s is now allowed." },
+    { "MAILMSG_PROHIBITED_EMAIL_HEADER", "$bBanned Email Address Masks$b" },
     { "MAILMSG_PROHIBITED_EMAIL", "%s: %s" },
+    { "MAILMSG_PROHIBITED_EMAIL_END", "-------End of Banned Address Masks------" },
     { "MAILMSG_NO_PROHIBITED_EMAIL", "All email addresses are accepted." },
     { NULL, NULL }
 };
@@ -83,7 +85,7 @@ send_flowed_text(FILE *where, const char *para)
             break;
         } else if (eol && (eol < para + (80 - shift))) {
             /* Newline inside paragraph, no need to wrap. */
-            fprintf(where, "%.*s\n", eol - para, para);
+            fprintf(where, "%.*s\n", (int)(eol - para), para);
             para = eol + 1;
         } else {
             int pos;
@@ -98,6 +100,24 @@ send_flowed_text(FILE *where, const char *para)
     }
 }
 
+/* moved to tools.c 
+int 
+valid_email(email)
+{
+    for (i=0;i<strlen(email);i++)
+    {
+        if(!isalnum(to->email_addr[i]) &&
+               to->email_addr[i] != '.' &&
+               to->email_addr[i] != '@' &&
+               to->email_addr[i] != '-' &&
+               to->email_addr[i] != '+' &&
+               to->email_addr[i] != '_' )
+            return false;
+    }
+    return true;
+}
+*/
+
 void
 sendmail(struct userNode *from, struct handle_info *to, const char *subject, const char *body, int first_time)
 {
@@ -225,6 +245,12 @@ sendmail(struct userNode *from, struct handle_info *to, const char *subject, con
             argv[argc++] = "-f";
             argv[argc++] = fromaddr;
         }
+        if(!valid_email(to->email_addr))
+        {
+                log_module(MAIN_LOG, LOG_ERROR, "email address contained illegal chars. Refusing to execv() sendmail.");
+                _exit(1);
+        }
+
         argv[argc++] = to->email_addr;
         argv[argc++] = NULL;
         if (execv(mpath, (char**)argv) < 0) {
@@ -272,6 +298,8 @@ static MODCMD_FUNC(cmd_stats_email) {
     dict_iterator_t it;
     int found = 0;
 
+    reply("MAILMSG_PROHIBITED_EMAIL_HEADER");
+    reply("MSG_BAR");
     for (it=dict_first(prohibited_addrs); it; it=iter_next(it)) {
         reply("MAILMSG_PROHIBITED_EMAIL", iter_key(it), (const char*)iter_data(it));
         found = 1;
@@ -282,6 +310,8 @@ static MODCMD_FUNC(cmd_stats_email) {
     }
     if (!found)
         reply("MAILMSG_NO_PROHIBITED_EMAIL");
+    else
+        reply("MAILMSG_PROHIBITED_EMAIL_END");
     return 0;
 }