[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Nmh-commits] nmh ChangeLog sbr/mts.c uip/whom.c mts/smtp/smtp.c
From: |
Earl Hood |
Subject: |
[Nmh-commits] nmh ChangeLog sbr/mts.c uip/whom.c mts/smtp/smtp.c |
Date: |
Wed, 03 Feb 2010 05:56:57 +0000 |
CVSROOT: /cvsroot/nmh
Module name: nmh
Changes by: Earl Hood <ehood> 10/02/03 05:56:57
Modified files:
. : ChangeLog
sbr : mts.c
uip : whom.c
mts/smtp : smtp.c
Log message:
* mts/smtp/smtp.c: added SASL support if mts configuration
setting is set to "sendmail". This is useful if sendmail
conf option is to a custom script that creates a proxy
connection to an smtp server.
* sbr/mts.c: added support for MHMTSCONF and MHMTSUSERCONF
envvars. The former specifies an alternative system
mts.conf to use. The later specifies a user-specific
mts.conf to use. This one will be read after the system
conf, so the user's conf only needs to set options they
want to override. The MHMTSUSERCONF allows a user to set
personal alternative mail submission methods w/o affecting
other users on the system.
* uip/whom.c: added SASL-based options so address checking
can work against a server that requires SASL.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/nmh/ChangeLog?cvsroot=nmh&r1=1.308&r2=1.309
http://cvs.savannah.gnu.org/viewcvs/nmh/sbr/mts.c?cvsroot=nmh&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/nmh/uip/whom.c?cvsroot=nmh&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/nmh/mts/smtp/smtp.c?cvsroot=nmh&r1=1.28&r2=1.29
Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/nmh/nmh/ChangeLog,v
retrieving revision 1.308
retrieving revision 1.309
diff -u -b -r1.308 -r1.309
--- ChangeLog 30 Dec 2009 01:42:45 -0000 1.308
+++ ChangeLog 3 Feb 2010 05:56:56 -0000 1.309
@@ -1,3 +1,21 @@
+2010-02-02 Earl Hood <address@hidden>
+ * mts/smtp/smtp.c: added SASL support if mts configuration
+ setting is set to "sendmail". This is useful if sendmail
+ conf option is to a custom script that creates a proxy
+ connection to an smtp server.
+
+ * sbr/mts.c: added support for MHMTSCONF and MHMTSUSERCONF
+ envvars. The former specifies an alternative system
+ mts.conf to use. The later specifies a user-specific
+ mts.conf to use. This one will be read after the system
+ conf, so the user's conf only needs to set options they
+ want to override. The MHMTSUSERCONF allows a user to set
+ personal alternative mail submission methods w/o affecting
+ other users on the system.
+
+ * uip/whom.c: added SASL-based options so address checking
+ can work against a server that requires SASL.
+
2009-12-29 David Levine <address@hidden>
* uip/mhlistsbr.c, uip/mhlsbr.c, uip/picksbr.c: cast
Index: sbr/mts.c
===================================================================
RCS file: /cvsroot/nmh/nmh/sbr/mts.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- sbr/mts.c 16 Jan 2009 02:28:55 -0000 1.6
+++ sbr/mts.c 3 Feb 2010 05:56:56 -0000 1.7
@@ -2,7 +2,7 @@
/*
* mts.c -- definitions for the mail transport system
*
- * $Id: mts.c,v 1.6 2009/01/16 02:28:55 kenh Exp $
+ * $Id: mts.c,v 1.7 2010/02/03 05:56:56 ehood Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -33,6 +33,9 @@
*/
static char *tailor_value (unsigned char *);
static void getuserinfo (void);
+static const char *get_mtsconf_pathname(void);
+static const char *get_mtsuserconf_pathname(void);
+static void mts_read_conf_file (FILE *fp);
/*
* *mmdfldir and *uucpldir are the maildrop directories. If maildrops
@@ -172,35 +175,21 @@
void
mts_init (char *name)
{
- unsigned char *bp;
- char *cp, buffer[BUFSIZ];
- struct bind *b;
+ const char *cp;
FILE *fp;
static int inited = 0;
- if (inited++ || (fp = fopen (mtsconf, "r")) == NULL)
+ if (inited++ || (fp = fopen (get_mtsconf_pathname(), "r")) == NULL)
return;
+ mts_read_conf_file(fp);
+ fclose (fp);
- while (fgets (buffer, sizeof(buffer), fp)) {
- if (!(cp = strchr(buffer, '\n')))
- break;
- *cp = 0;
- if (*buffer == '#' || *buffer == '\0')
- continue;
- if (!(bp = strchr(buffer, ':')))
- break;
- *bp++ = 0;
- while (isspace (*bp))
- *bp++ = 0;
-
- for (b = binds; b->keyword; b++)
- if (!strcmp (buffer, b->keyword))
- break;
- if (b->keyword && (cp = tailor_value (bp)))
- *b->value = cp;
- }
-
+ cp = get_mtsuserconf_pathname();
+ if (cp != NULL &&
+ ((fp = fopen (get_mtsuserconf_pathname(), "r")) != NULL)) {
+ mts_read_conf_file(fp);
fclose (fp);
+ }
Everyone = atoi (everyone);
@@ -529,3 +518,50 @@
return;
}
+
+static const char*
+get_mtsconf_pathname (void)
+{
+ const char *cp = getenv ( "MHMTSCONF ");
+ if (cp != NULL && *cp != '\0') {
+ return cp;
+ }
+ return mtsconf;
+}
+
+static const char*
+get_mtsuserconf_pathname (void)
+{
+ const char *cp = getenv ( "MHMTSUSERCONF" );
+ if (cp != NULL && *cp != '\0') {
+ return cp;
+ }
+ return NULL;
+}
+
+static void
+mts_read_conf_file (FILE *fp)
+{
+ unsigned char *bp;
+ char *cp, buffer[BUFSIZ];
+ struct bind *b;
+
+ while (fgets (buffer, sizeof(buffer), fp)) {
+ if (!(cp = strchr(buffer, '\n')))
+ break;
+ *cp = 0;
+ if (*buffer == '#' || *buffer == '\0')
+ continue;
+ if (!(bp = strchr(buffer, ':')))
+ break;
+ *bp++ = 0;
+ while (isspace (*bp))
+ *bp++ = 0;
+
+ for (b = binds; b->keyword; b++)
+ if (!strcmp (buffer, b->keyword))
+ break;
+ if (b->keyword && (cp = tailor_value (bp)))
+ *b->value = cp;
+ }
+}
Index: uip/whom.c
===================================================================
RCS file: /cvsroot/nmh/nmh/uip/whom.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- uip/whom.c 2 Jul 2002 22:09:15 -0000 1.4
+++ uip/whom.c 3 Feb 2010 05:56:56 -0000 1.5
@@ -2,7 +2,7 @@
/*
* whom.c -- report to whom a message would be sent
*
- * $Id: whom.c,v 1.4 2002/07/02 22:09:15 kenh Exp $
+ * $Id: whom.c,v 1.5 2010/02/03 05:56:56 ehood Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -13,6 +13,12 @@
#include <h/signals.h>
#include <signal.h>
+#ifndef CYRUS_SASL
+# define SASLminc(a) (a)
+#else /* CYRUS_SASL */
+# define SASLminc(a) 0
+#endif /* CYRUS_SASL */
+
static struct swit switches[] = {
#define ALIASW 0
{ "alias aliasfile", 0 },
@@ -38,6 +44,14 @@
{ "server host", -6 },
#define SNOOPSW 11
{ "snoop", -5 },
+#define SASLSW 12
+ { "sasl", SASLminc(4) },
+#define SASLMECHSW 13
+ { "saslmech mechanism", SASLminc(-5) },
+#define USERSW 14
+ { "user username", SASLminc(-4) },
+#define PORTSW 15
+ { "port server port name/number", 4 },
{ NULL, 0 }
};
@@ -88,6 +102,7 @@
case CHKSW:
case NOCHKSW:
case SNOOPSW:
+ case SASLSW:
vec[vecp++] = --cp;
continue;
@@ -117,6 +132,9 @@
case ALIASW:
case CLIESW:
case SERVSW:
+ case USERSW:
+ case PORTSW:
+ case SASLMECHSW:
vec[vecp++] = --cp;
if (!(cp = *argp++) || *cp == '-')
adios (NULL, "missing argument to %s", argp[-2]);
Index: mts/smtp/smtp.c
===================================================================
RCS file: /cvsroot/nmh/nmh/mts/smtp/smtp.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -b -r1.28 -r1.29
--- mts/smtp/smtp.c 21 Dec 2009 17:18:04 -0000 1.28
+++ mts/smtp/smtp.c 3 Feb 2010 05:56:57 -0000 1.29
@@ -1,7 +1,7 @@
/*
* smtp.c -- nmh SMTP interface
*
- * $Id: smtp.c,v 1.28 2009/12/21 17:18:04 levine Exp $
+ * $Id: smtp.c,v 1.29 2010/02/03 05:56:57 ehood Exp $
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
@@ -128,7 +128,8 @@
*/
static int smtp_init (char *, char *, char *, int, int, int, int, int, int,
char *, char *);
-static int sendmail_init (char *, char *, int, int, int, int, int);
+static int sendmail_init (char *, char *, int, int, int, int, int, int,
+ char *, char *);
static int rclient (char *, char *);
static int sm_ierror (char *fmt, ...);
@@ -165,13 +166,13 @@
debug, onex, queued, sasl, saslmech, user);
else
return sendmail_init (client, server, watch, verbose,
- debug, onex, queued);
+ debug, onex, queued, sasl, saslmech, user);
}
static int
smtp_init (char *client, char *server, char *port, int watch, int verbose,
- int debug, int onex, int queued, int sasl, char *saslmech,
- char *user)
+ int debug, int onex, int queued,
+ int sasl, char *saslmech, char *user)
{
#ifdef CYRUS_SASL
char *server_mechs;
@@ -299,8 +300,12 @@
int
sendmail_init (char *client, char *server, int watch, int verbose,
- int debug, int onex, int queued)
+ int debug, int onex, int queued,
+ int sasl, char *saslmech, char *user)
{
+#ifdef CYRUS_SASL
+ char *server_mechs;
+#endif /* CYRUS_SASL */
int i, result, vecp;
int pdi[2], pdo[2];
char *vec[15];
@@ -426,6 +431,35 @@
}
}
+#ifdef CYRUS_SASL
+ /*
+ * If the user asked for SASL, then check to see if the SMTP server
+ * supports it. Otherwise, error out (because the SMTP server
+ * might have been spoofed; we don't want to just silently not
+ * do authentication
+ */
+
+ if (sasl) {
+ if (! (server_mechs = EHLOset("AUTH"))) {
+ sm_end(NOTOK);
+ return sm_ierror("SMTP server does not support SASL");
+ }
+
+ if (saslmech && stringdex(saslmech, server_mechs) == -1) {
+ sm_end(NOTOK);
+ return sm_ierror("Requested SASL mech \"%s\" is not in the "
+ "list of supported mechanisms:\n%s",
+ saslmech, server_mechs);
+ }
+
+ if (sm_auth_sasl(user, saslmech ? saslmech : server_mechs,
+ server) != RP_OK) {
+ sm_end(NOTOK);
+ return NOTOK;
+ }
+ }
+#endif /* CYRUS_SASL */
+
#ifndef ZMAILER
if (onex)
smtalk (SM_HELO, "ONEX");
@@ -454,7 +488,7 @@
int
sm_winit (int mode, char *from)
{
- char *smtpcom;
+ char *smtpcom = NULL;
switch (mode) {
case S_MAIL:
@@ -472,6 +506,10 @@
case S_SAML:
smtpcom = "SAML";
break;
+
+ default:
+ /* Hopefully, we do not get here. */
+ break;
}
switch (smtalk (SM_MAIL, "%s FROM:<%s>", smtpcom, from)) {
@@ -1173,7 +1211,7 @@
int i, code, cont, bc, rc, more;
unsigned char *bp;
char *rp;
- char **ehlo, buffer[BUFSIZ];
+ char **ehlo = NULL, buffer[BUFSIZ];
if (doingEHLO) {
static int at_least_once = 0;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Nmh-commits] nmh ChangeLog sbr/mts.c uip/whom.c mts/smtp/smtp.c,
Earl Hood <=