Opened 16 years ago

Closed 16 years ago

Last modified 9 years ago

#138 closed enhancement (fixed)

Add ability to specify smtp port

Reported by: lucas@… Owned by: rainer
Priority: minor Milestone: 2.5.3
Component: main Version:
Keywords: Cc:

Description

This patch allows Samhain to send mail to the configured smtp port instead of port 25. This is necessary on my system because port 25 is restricted ssl/tls connections to maintain pci compliance. Limitations in postfix prevent us from allowing local non-ssl mail on the same port and unfortunately samhain has no ssl support.

Change History (3)

comment:1 by lucas@…, 16 years ago

Tried to attach as a file but trac seems to be configured to not allow attachments. I'll try pasting here since it's not too big.

Index: src/sh_readconf.c
===================================================================
--- src/sh_readconf.c	(revision 211)
+++ src/sh_readconf.c	(working copy)
@@ -1101,6 +1101,8 @@
     sh_mail_setaddress },
   { N_("setmailrelay"),      SH_SECTION_MAIL,  SH_SECTION_MISC, 
     sh_mail_set_relay },
+  { N_("setmailport"),       SH_SECTION_MAIL,  SH_SECTION_MISC,
+    sh_mail_set_port },
   { N_("mailsingle"),        SH_SECTION_MAIL,  SH_SECTION_MISC, 
     sh_mail_setFlag },
   { N_("mailsubject"),       SH_SECTION_MAIL,  SH_SECTION_MISC, 
Index: src/sh_mail.c
===================================================================
--- src/sh_mail.c	(revision 211)
+++ src/sh_mail.c	(working copy)
@@ -1273,6 +1273,22 @@
   SL_RETURN( 0, _("sh_mail_set_relay"));
 }
 
+static int mail_port = IPPORT_SMTP;
+
+int sh_mail_set_port (const char * str)
+{
+  int i = atoi (str);
+
+  SL_ENTER(_("sh_mail_set_port"));
+
+  if (i >= 0 && i < 65535) 
+    mail_port = i;
+  else 
+    SL_RETURN ((-1), _("sh_mail_setNum"));
+
+  SL_RETURN( (0), _("sh_mail_setNum"));
+}
+
 static char * mail_sender = NULL;
 
 int sh_mail_set_sender (const char *str)
@@ -1379,7 +1395,7 @@
       (void) sl_strlcpy (ma_machine, relay_host, sizeof(ma_machine));
       TPT((0, FIL__, __LINE__, _("msg=<user %s machine %s>\n"), 
 	   ma_user, ma_machine)); 
-      fd = connect_port (ma_machine, IPPORT_SMTP, 
+      fd = connect_port (ma_machine, mail_port, 
 			 error_call, &error_num, error_msg, 256);
     }
   else
@@ -1396,7 +1412,7 @@
 	      TPT((0, FIL__, __LINE__, 
 		   _("msg=<user %s mx %s pref %d>\n"), 
 		   ma_user, ma_machine, result[i].pref));
-	      fd = connect_port (ma_machine, IPPORT_SMTP, 
+	      fd = connect_port (ma_machine, mail_port, 
 				 error_call, &error_num, error_msg, 256);
 	      if (fd >= 0)
 		break;
Index: include/sh_mail.h
===================================================================
--- include/sh_mail.h	(revision 211)
+++ include/sh_mail.h	(working copy)
@@ -27,6 +27,10 @@
  */
 int sh_mail_set_relay (const char * str_s);
 
+/* set the mail port
+ */
+int sh_mail_set_port (const char * str);
+
 /* send to all recpts. in one mail
  */
 int sh_mail_setFlag (const char * str);

comment:2 by rainer, 16 years ago

Milestone: 2.5.3
Status: newassigned

comment:3 by rainer, 16 years ago

Resolution: fixed
Status: assignedclosed

Fixed in changeset [216].

Note: See TracTickets for help on using tickets.