#138 closed enhancement (fixed)
Add ability to specify smtp port
| Reported by: | 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 , 17 years ago
comment:2 by , 17 years ago
| Milestone: | → 2.5.3 |
|---|---|
| Status: | new → assigned |
Note:
See TracTickets
for help on using tickets.
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);