masqmail

changeset 205:4fd237550525

REMOVED MAILDIR SUPPORT if you want to deliver to maildir, use an MDA like procmail masqmail can pass mail to an MDA by setting `mda' in masqmail.conf
author meillo@marmaro.de
date Fri, 16 Jul 2010 16:38:50 +0200
parents 5745edd5b769
children 0241aaccfcdb
files INSTALL acconfig.h config.h.in configure configure.ac man/masqmail.conf.5 src/conf.c src/deliver.c src/local.c src/masqmail.c src/masqmail.h
diffstat 11 files changed, 3 insertions(+), 201 deletions(-) [+]
line diff
     1.1 --- a/INSTALL	Fri Jul 16 15:38:53 2010 +0200
     1.2 +++ b/INSTALL	Fri Jul 16 16:38:50 2010 +0200
     1.3 @@ -70,9 +70,6 @@
     1.4  --enable-auth
     1.5  enables ESMTP AUTH support (disabled by default)
     1.6  
     1.7 ---enable-maildir
     1.8 -enables qmail style Maildir support (disabled by default)
     1.9 -
    1.10  --enable-ident
    1.11  enables RFC 1413 support. If you have the libident dynamic library
    1.12  installed, this will be linked, otherwise it will be statically linked
     2.1 --- a/acconfig.h	Fri Jul 16 15:38:53 2010 +0200
     2.2 +++ b/acconfig.h	Fri Jul 16 16:38:50 2010 +0200
     2.3 @@ -10,8 +10,6 @@
     2.4  
     2.5  #undef ENABLE_AUTH
     2.6  
     2.7 -#undef ENABLE_MAILDIR
     2.8 -
     2.9  #undef USE_LIB_CRYPTO
    2.10  
    2.11  #undef ENABLE_IDENT
     3.1 --- a/config.h.in	Fri Jul 16 15:38:53 2010 +0200
     3.2 +++ b/config.h.in	Fri Jul 16 16:38:50 2010 +0200
     3.3 @@ -11,8 +11,6 @@
     3.4  
     3.5  #undef ENABLE_AUTH
     3.6  
     3.7 -#undef ENABLE_MAILDIR
     3.8 -
     3.9  #undef USE_LIB_CRYPTO
    3.10  
    3.11  #undef ENABLE_IDENT
    3.12 @@ -44,9 +42,6 @@
    3.13  /* If ident is enabled */
    3.14  #undef ENABLE_IDENT
    3.15  
    3.16 -/* If Maildirs are enabled */
    3.17 -#undef ENABLE_MAILDIR
    3.18 -
    3.19  /* If the resolver is to be used */
    3.20  #undef ENABLE_RESOLVER
    3.21  
     4.1 --- a/configure	Fri Jul 16 15:38:53 2010 +0200
     4.2 +++ b/configure	Fri Jul 16 16:38:50 2010 +0200
     4.3 @@ -705,7 +705,6 @@
     4.4  with_group
     4.5  enable_debug
     4.6  enable_auth
     4.7 -enable_maildir
     4.8  with_libcrypto
     4.9  enable_ident
    4.10  with_liblockfile
    4.11 @@ -1347,7 +1346,6 @@
    4.12    --disable-resolver      disable resolver support
    4.13    --disable-debug         disable debugging
    4.14    --enable-auth           enable AUTH (RFC 2554) client support
    4.15 -  --enable-maildir        enable qmail style maildir support
    4.16    --enable-ident          enable ident (RFC 1413) support
    4.17  
    4.18  Optional Packages:
    4.19 @@ -5166,19 +5164,6 @@
    4.20  fi
    4.21  
    4.22  
    4.23 -# Check whether --enable-maildir was given.
    4.24 -if test "${enable_maildir+set}" = set; then :
    4.25 -  enableval=$enable_maildir; if test "x$enable_maildir" != 'xno'; then
    4.26 -		maildir_enabled='yes'
    4.27 -	fi
    4.28 -fi
    4.29 -
    4.30 -if test "x$maildir_enabled" = xyes; then
    4.31 -
    4.32 -$as_echo "#define ENABLE_MAILDIR 1" >>confdefs.h
    4.33 -
    4.34 -fi
    4.35 -
    4.36  
    4.37  # Check whether --with-libcrypto was given.
    4.38  if test "${with_libcrypto+set}" = set; then :
     5.1 --- a/configure.ac	Fri Jul 16 15:38:53 2010 +0200
     5.2 +++ b/configure.ac	Fri Jul 16 16:38:50 2010 +0200
     5.3 @@ -137,17 +137,6 @@
     5.4  fi
     5.5  AC_SUBST(BASE64_LIBS)
     5.6  
     5.7 -dnl maildir support (default is to not use it)
     5.8 -AC_ARG_ENABLE(maildir,
     5.9 -	[  --enable-maildir        enable qmail style maildir support],
    5.10 -	if test "x$enable_maildir" != 'xno'; then
    5.11 -		maildir_enabled='yes'
    5.12 -	fi,
    5.13 -	)
    5.14 -if test "x$maildir_enabled" = xyes; then
    5.15 -	AC_DEFINE(ENABLE_MAILDIR, 1, [If Maildirs are enabled])
    5.16 -fi
    5.17 -
    5.18  dnl libcrypto
    5.19  AC_ARG_WITH(libcrypto,
    5.20  	[  --with-libcrypto        use libcrypto],
     6.1 --- a/man/masqmail.conf.5	Fri Jul 16 15:38:53 2010 +0200
     6.2 +++ b/man/masqmail.conf.5	Fri Jul 16 16:38:50 2010 +0200
     6.3 @@ -268,10 +268,9 @@
     6.4  \fBmbox_default = \fIstring\fR
     6.5  
     6.6  The default local delivery method.
     6.7 -Can be one of mbox, mda or maildir (the latter only if maildir support is enabled at compile time).
     6.8 +Can be mbox or mda.
     6.9  Default is mbox.
    6.10 -You can override this for each user by using the \fBmbox_users\fR, \fBmda_users\fR,
    6.11 -or \fBmaildir_users\fR options (see below).
    6.12 +You can override this for each user by using the \fBmbox_users\fR or \fBmda_users\fR (see below).
    6.13  
    6.14  .TP
    6.15  \fBmbox_users = \fIlist\fR
    6.16 @@ -285,13 +284,6 @@
    6.17  You have to set \fBmda\fR (see below) as well.
    6.18  
    6.19  .TP
    6.20 -\fBmaildir_users = \fIlist\fR
    6.21 -
    6.22 -A list of users which wish delivery to a qmail style maildir.
    6.23 -The path to maildir is ~/Maildir/.
    6.24 -The maildir will be created if it does not exist.
    6.25 -
    6.26 -.TP
    6.27  \fBmda = \fIexpand string\fR
    6.28  
    6.29  If you want local delivery to be transferred to an mda (Mail Delivery Agent),
     7.1 --- a/src/conf.c	Fri Jul 16 15:38:53 2010 +0200
     7.2 +++ b/src/conf.c	Fri Jul 16 16:38:50 2010 +0200
     7.3 @@ -497,8 +497,6 @@
     7.4  			conf.mbox_users = parse_list(rval, TRUE);
     7.5  		} else if (strcmp(lval, "mda_users") == 0) {
     7.6  			conf.mda_users = parse_list(rval, TRUE);
     7.7 -		} else if (strcmp(lval, "maildir_users") == 0) {
     7.8 -			conf.maildir_users = parse_list(rval, TRUE);
     7.9  		} else if (strcmp(lval, "mda") == 0) {
    7.10  			conf.mda = g_strdup(rval);
    7.11  		} else if (strcmp(lval, "mda_fromline") == 0) {
     8.1 --- a/src/deliver.c	Fri Jul 16 15:38:53 2010 +0200
     8.2 +++ b/src/deliver.c	Fri Jul 16 16:38:50 2010 +0200
     8.3 @@ -127,8 +127,6 @@
     8.4  				mbox_type = "mbox";
     8.5  			else if (g_list_find_custom (conf.mda_users, user, _g_list_strcasecmp) != NULL)
     8.6  				mbox_type = "mda";
     8.7 -			else if (g_list_find_custom (conf.maildir_users, user, _g_list_strcasecmp) != NULL)
     8.8 -				mbox_type = "maildir";
     8.9  
    8.10  			if (strcmp(mbox_type, "mbox") == 0) {
    8.11  				DEBUG(1) debugf("attempting to deliver %s with mbox\n", msg->uid);
    8.12 @@ -179,23 +177,6 @@
    8.13  					destroy_table(var_table);
    8.14  				} else
    8.15  					logwrite(LOG_ALERT, "mbox type is mda, but no mda command given in configuration\n");
    8.16 -
    8.17 -#ifdef ENABLE_MAILDIR
    8.18 -			} else if (strcmp(mbox_type, "maildir") == 0) {
    8.19 -				DEBUG(1) debugf("attempting to deliver %s with maildir\n", msg->uid);
    8.20 -				if (maildir_out(msg, hdr_list, rcpt->local_part, 0)) {
    8.21 -					if (env_addr != rcpt) {
    8.22 -						logwrite(LOG_NOTICE, "%s => %s@%s <%s@%s> with local\n", msg->uid,
    8.23 -						         rcpt->local_part, rcpt->domain, env_addr->local_part, env_addr->domain);
    8.24 -					} else {
    8.25 -						logwrite(LOG_NOTICE, "%s => <%s@%s> with maildir\n", msg->uid,
    8.26 -						         rcpt->local_part, rcpt->domain);
    8.27 -					}
    8.28 -					addr_mark_delivered(rcpt);
    8.29 -					ok = TRUE;
    8.30 -				} else
    8.31 -					addr_mark_failed(rcpt);
    8.32 -#endif
    8.33  			} else
    8.34  				logwrite(LOG_ALERT, "unknown mbox type '%s'\n", mbox_type);
    8.35  		}
     9.1 --- a/src/local.c	Fri Jul 16 15:38:53 2010 +0200
     9.2 +++ b/src/local.c	Fri Jul 16 16:38:50 2010 +0200
     9.3 @@ -144,132 +144,6 @@
     9.4  	return ok;
     9.5  }
     9.6  
     9.7 -#ifdef ENABLE_MAILDIR
     9.8 -gboolean
     9.9 -maildir_out(message * msg, GList * hdr_list, gchar * user, guint flags)
    9.10 -{
    9.11 -	struct passwd *pw;
    9.12 -	gboolean ok = FALSE;
    9.13 -
    9.14 -	/* headers may be special for a local delivery */
    9.15 -	if (hdr_list == NULL)
    9.16 -		hdr_list = msg->hdr_list;
    9.17 -
    9.18 -	if ((pw = getpwnam(user))) {
    9.19 -		uid_t saved_uid = geteuid();
    9.20 -		gid_t saved_gid = getegid();
    9.21 -		gboolean uid_ok = TRUE, gid_ok = TRUE;
    9.22 -
    9.23 -		if (!conf.run_as_user) {
    9.24 -			uid_ok = (seteuid(0) == 0);
    9.25 -			if (uid_ok) {
    9.26 -				gid_ok = (setegid(conf.mail_gid) == 0);
    9.27 -				uid_ok = (seteuid(pw->pw_uid) == 0);
    9.28 -			}
    9.29 -		}
    9.30 -
    9.31 -		DEBUG(5) debugf("running as euid %d, egid %d\n", geteuid(), getegid());
    9.32 -
    9.33 -		if (uid_ok && gid_ok) {
    9.34 -			char *path = g_strdup_printf("%s/Maildir", pw->pw_dir);
    9.35 -			struct stat statbuf;
    9.36 -			int ret;
    9.37 -
    9.38 -			DEBUG(5) debugf("  path = %s\n", path);
    9.39 -
    9.40 -			ok = TRUE;
    9.41 -			ret = stat(path, &statbuf);
    9.42 -			if (ret != 0) {
    9.43 -				ok = FALSE;
    9.44 -				if (errno == ENOENT) {
    9.45 -					logwrite(LOG_NOTICE, "directory %s does not exist, creating\n", path);
    9.46 -					if (mkdir(path, 0700) == 0)
    9.47 -						ok = TRUE;
    9.48 -				} else
    9.49 -					logwrite(LOG_ALERT, "stat of %s failed: %s\n", path, strerror(errno));
    9.50 -			}
    9.51 -			if (ok) {
    9.52 -				ok = FALSE;
    9.53 -				ret = stat(path, &statbuf);
    9.54 -				if (S_ISDIR(statbuf.st_mode)) {
    9.55 -					gchar *subdirs[] = { "tmp", "new", "cur" };
    9.56 -					int i;
    9.57 -					for (i = 0; i < 3; i++) {
    9.58 -						char *path1 = g_strdup_printf("%s/%s", path, subdirs[i]);
    9.59 -						ret = stat(path1, &statbuf);
    9.60 -						if (ret != 0) {
    9.61 -							if (errno == ENOENT) {
    9.62 -								logwrite(LOG_NOTICE, "directory %s does not exist, creating\n", path1);
    9.63 -								if (mkdir(path1, 0700) != 0)
    9.64 -									break;
    9.65 -							}
    9.66 -						}
    9.67 -						g_free(path1);
    9.68 -					}
    9.69 -					if (i == 3) {
    9.70 -						FILE *out;
    9.71 -						mode_t saved_mode = umask(066);
    9.72 -						/* the qmail style unique works only if delivering with different process.
    9.73 -						   We do not fork for each delivery, so our uid is more unique.
    9.74 -						   Hope it is compatible with all MUAs.
    9.75 -						 */
    9.76 -						gchar *filename = g_strdup_printf("%s/tmp/%s.%s", path, msg->uid, conf.host_name);
    9.77 -
    9.78 -						DEBUG(5) debugf("filename = %s\n", filename);
    9.79 -
    9.80 -						if ((out = fopen(filename, "w"))) {
    9.81 -							gchar *newname = g_strdup_printf("%s/new/%s.%s", path, msg->uid, conf.host_name);
    9.82 -							message_stream(out, msg, hdr_list, flags);
    9.83 -							ok = TRUE;
    9.84 -							if (fflush(out) == EOF)
    9.85 -								ok = FALSE;
    9.86 -							else if (fdatasync(fileno(out)) != 0) {
    9.87 -								if (errno != EINVAL)
    9.88 -									/* some fs do not support this..  I hope this also means that it is not necessary */
    9.89 -									ok = FALSE;
    9.90 -							}
    9.91 -							fclose(out);
    9.92 -							if (rename(filename, newname) != 0) {
    9.93 -								ok = FALSE;
    9.94 -								logwrite(LOG_ALERT, "moving %s to %s failed: %s", filename, newname, strerror(errno));
    9.95 -							}
    9.96 -							g_free(newname);
    9.97 -						}
    9.98 -						umask(saved_mode);
    9.99 -						g_free(filename);
   9.100 -					}
   9.101 -				} else {
   9.102 -					logwrite(LOG_ALERT, "%s is not a directory\n", path);
   9.103 -					errno = ENOTDIR;
   9.104 -				}
   9.105 -			}
   9.106 -			if (!conf.run_as_user) {
   9.107 -				uid_ok = (seteuid(0) == 0);
   9.108 -				if (uid_ok) {
   9.109 -					gid_ok = (setegid(saved_gid) == 0);
   9.110 -					uid_ok = (seteuid(saved_uid) == 0);
   9.111 -				}
   9.112 -			}
   9.113 -			if (!uid_ok || !gid_ok) {
   9.114 -				/* FIXME: if this fails we HAVE to exit, because we shall not run
   9.115 -				   with some users id. But we do not return, and so this message
   9.116 -				   will not be finished, so the user will get the message again
   9.117 -				   next time a delivery is attempted... */
   9.118 -				logwrite(LOG_ALERT, "could not set back uid or gid after local delivery: %s\n", strerror(errno));
   9.119 -				exit(EXIT_FAILURE);
   9.120 -			}
   9.121 -			g_free(path);
   9.122 -		} else {
   9.123 -			logwrite(LOG_ALERT, "could not set uid or gid for local delivery, uid = %d: %s\n", pw->pw_uid, strerror(errno));
   9.124 -		}
   9.125 -	} else {
   9.126 -		logwrite(LOG_ALERT, "could not find password entry for user %s\n", user);
   9.127 -		errno = ENOENT;  /* getpwnam does not set errno correctly */
   9.128 -	}
   9.129 -	return ok;
   9.130 -}
   9.131 -#endif
   9.132 -
   9.133  gboolean
   9.134  pipe_out(message * msg, GList * hdr_list, address * rcpt, gchar * cmd, guint flags)
   9.135  {
    10.1 --- a/src/masqmail.c	Fri Jul 16 15:38:53 2010 +0200
    10.2 +++ b/src/masqmail.c	Fri Jul 16 16:38:50 2010 +0200
    10.3 @@ -499,7 +499,6 @@
    10.4  	if (mta_mode == MODE_VERSION) {
    10.5  		gchar *with_resolver = "";
    10.6  		gchar *with_auth = "";
    10.7 -		gchar *with_maildir = "";
    10.8  		gchar *with_ident = "";
    10.9  
   10.10  #ifdef ENABLE_RESOLVER
   10.11 @@ -508,15 +507,11 @@
   10.12  #ifdef ENABLE_AUTH
   10.13  		with_auth = " +auth";
   10.14  #endif
   10.15 -#ifdef ENABLE_MAILDIR
   10.16 -		with_maildir = " +maildir";
   10.17 -#endif
   10.18  #ifdef ENABLE_IDENT
   10.19  		with_ident = " +ident";
   10.20  #endif
   10.21  
   10.22 -		printf("%s %s%s%s%s%s\n", PACKAGE, VERSION, with_resolver,
   10.23 -		       with_auth, with_maildir, with_ident);
   10.24 +		printf("%s %s%s%s%s\n", PACKAGE, VERSION, with_resolver, with_auth, with_ident);
   10.25  
   10.26  		exit(EXIT_SUCCESS);
   10.27  	}
    11.1 --- a/src/masqmail.h	Fri Jul 16 15:38:53 2010 +0200
    11.2 +++ b/src/masqmail.h	Fri Jul 16 16:38:50 2010 +0200
    11.3 @@ -168,7 +168,6 @@
    11.4  	gchar *mbox_default;
    11.5  	GList *mbox_users;
    11.6  	GList *mda_users;
    11.7 -	GList *maildir_users;
    11.8  
    11.9  	gchar *mda;
   11.10  	gboolean mda_fromline;
   11.11 @@ -452,7 +451,6 @@
   11.12  
   11.13  /* local.c */
   11.14  gboolean append_file(message * msg, GList * hdr_list, gchar * user);
   11.15 -gboolean maildir_out(message * msg, GList * hdr_list, gchar * user, guint flags);
   11.16  gboolean pipe_out(message * msg, GList * hdr_list, address * rcpt, gchar * cmd, guint flags);
   11.17  
   11.18  /* log.c */