masqmail

changeset 422:bdbedce60247

Remove `input' dir in spool dir. Spooled files are in spool dir directly now. There's no more need to have any sub directories in the spool dir at all.
author markus schnalke <meillo@marmaro.de>
date Wed, 30 May 2012 10:27:10 +0200
parents f37384470855
children 196dfb2a3056
files INSTALL Makefile.am Makefile.in configure configure.ac man/masqmail.conf.5 src/queue.c src/spool.c
diffstat 8 files changed, 18 insertions(+), 24 deletions(-) [+]
line diff
     1.1 --- a/INSTALL	Wed May 30 09:38:38 2012 +0200
     1.2 +++ b/INSTALL	Wed May 30 10:27:10 2012 +0200
     1.3 @@ -97,7 +97,7 @@
     1.4  Check that 'make install' worked correctly. The following command:
     1.5  
     1.6  	ls -ld /usr/local/sbin/masqmail /etc/masqmail /var/log/masqmail/ \
     1.7 -	       /var/spool/masqmail/ /var/spool/masqmail/*
     1.8 +	       /var/spool/masqmail/
     1.9  
    1.10  should give output similar to
    1.11  
    1.12 @@ -105,7 +105,6 @@
    1.13  	drwxr-xr-x 2 root root      4096 May 10 12:34 /etc/masqmail
    1.14  	drwxr-xr-x 2 mail mail      4096 May 10 12:34 /var/log/masqmail
    1.15  	drwxr-xr-x 5 mail mail      4096 May 10 12:34 /var/spool/masqmail
    1.16 -	drwxr-xr-x 2 mail mail      4096 May 10 12:34 /var/spool/masqmail/input
    1.17  
    1.18  Important are the set-user-id bit for /usr/local/sbin/masqmail and
    1.19  the ownership of the directories.
     2.1 --- a/Makefile.am	Wed May 30 09:38:38 2012 +0200
     2.2 +++ b/Makefile.am	Wed May 30 10:27:10 2012 +0200
     2.3 @@ -46,12 +46,10 @@
     2.4  
     2.5  spool_dir:
     2.6  	install -d -o @with_user@ -g @with_group@ $(DESTDIR)@with_spooldir@
     2.7 -	install -d -o @with_user@ -g @with_group@ $(DESTDIR)@with_spooldir@/input
     2.8  
     2.9  rm-spool_dir:
    2.10  	: # removal fails if the dirs are non-empty
    2.11  	: # this prevents losing spooled files
    2.12 -	rmdir $(DESTDIR)@with_spooldir@/input
    2.13  	rmdir $(DESTDIR)@with_spooldir@
    2.14  
    2.15  rmail:
     3.1 --- a/Makefile.in	Wed May 30 09:38:38 2012 +0200
     3.2 +++ b/Makefile.in	Wed May 30 10:27:10 2012 +0200
     3.3 @@ -730,12 +730,10 @@
     3.4  
     3.5  spool_dir:
     3.6  	install -d -o @with_user@ -g @with_group@ $(DESTDIR)@with_spooldir@
     3.7 -	install -d -o @with_user@ -g @with_group@ $(DESTDIR)@with_spooldir@/input
     3.8  
     3.9  rm-spool_dir:
    3.10  	: # removal fails if the dirs are non-empty
    3.11  	: # this prevents losing spooled files
    3.12 -	rmdir $(DESTDIR)@with_spooldir@/input
    3.13  	rmdir $(DESTDIR)@with_spooldir@
    3.14  
    3.15  rmail:
     4.1 --- a/configure	Wed May 30 09:38:38 2012 +0200
     4.2 +++ b/configure	Wed May 30 10:27:10 2012 +0200
     4.3 @@ -5254,7 +5254,7 @@
     4.4  if test "${with_logdir+set}" = set; then :
     4.5    withval=$with_logdir;
     4.6  else
     4.7 -  with_logdir='/var/log/masqmail/'
     4.8 +  with_logdir='/var/log/masqmail'
     4.9  
    4.10  fi
    4.11  
    4.12 @@ -5270,7 +5270,7 @@
    4.13  if test "${with_spooldir+set}" = set; then :
    4.14    withval=$with_spooldir;
    4.15  else
    4.16 -  with_spooldir='/var/spool/masqmail/'
    4.17 +  with_spooldir='/var/spool/masqmail'
    4.18  
    4.19  fi
    4.20  
     5.1 --- a/configure.ac	Wed May 30 09:38:38 2012 +0200
     5.2 +++ b/configure.ac	Wed May 30 10:27:10 2012 +0200
     5.3 @@ -166,7 +166,7 @@
     5.4  AC_ARG_WITH(logdir,
     5.5  	[  --with-logdir=DIR       set log directory [/var/log/masqmail]],
     5.6  	,
     5.7 -        with_logdir='/var/log/masqmail/'
     5.8 +        with_logdir='/var/log/masqmail'
     5.9  	)
    5.10  AC_DEFINE_UNQUOTED(LOG_DIR, "${with_logdir}", [The log directory])
    5.11  AC_SUBST(with_logdir)
    5.12 @@ -174,7 +174,7 @@
    5.13  AC_ARG_WITH(spooldir,
    5.14  	[  --with-spooldir=DIR     set spool directory [/var/spool/masqmail]],
    5.15  	,
    5.16 -	with_spooldir='/var/spool/masqmail/'
    5.17 +	with_spooldir='/var/spool/masqmail'
    5.18  	)
    5.19  AC_DEFINE_UNQUOTED(SPOOL_DIR, "${with_spooldir}", [The spool directory])
    5.20  AC_SUBST(with_spooldir)
     6.1 --- a/man/masqmail.conf.5	Wed May 30 09:38:38 2012 +0200
     6.2 +++ b/man/masqmail.conf.5	Wed May 30 10:27:10 2012 +0200
     6.3 @@ -93,7 +93,6 @@
     6.4  
     6.5  The directory where masqmail stores its spool files
     6.6  (and lock files if \fIrun_as_user\fP).
     6.7 -It must have a subdirectory \fIinput\fR.
     6.8  Masqmail needs read and write permissions for this directory.
     6.9  \fIfile\fR must be an absolute path.
    6.10  
     7.1 --- a/src/queue.c	Wed May 30 09:38:38 2012 +0200
     7.2 +++ b/src/queue.c	Wed May 30 10:27:10 2012 +0200
     7.3 @@ -54,7 +54,7 @@
     7.4  	**  Escaping the question marks prevents them from being
     7.5  	**  interpreted as trigraphs
     7.6  	*/
     7.7 -	pattern = g_strdup_printf("%s/input/?????\?-??\?-?\?-H", conf.spool_dir);
     7.8 +	pattern = g_strdup_printf("%s/?????\?-??\?-?\?-H", conf.spool_dir);
     7.9  	gl.gl_offs = 0;
    7.10  	glob(pattern, 0, NULL, &gl);
    7.11  
    7.12 @@ -73,9 +73,9 @@
    7.13  	for (i = 0; i < gl.gl_pathc; i++) {
    7.14  		gchar *uid;
    7.15  
    7.16 -		/* copy 13 chars, offset spooldir path + 7 chars for /input/ */
    7.17 +		/* copy 13 chars, offset spooldir path + 1 char for / */
    7.18  		/* uid length = 6 chars + '-' + 3 chars + '-' + 2 = 13 chars */
    7.19 -		uid = g_strndup(&(gl.gl_pathv[idx_arr[i]][strlen(conf.spool_dir) + 7]), 13);
    7.20 +		uid = g_strndup(&(gl.gl_pathv[idx_arr[i]][strlen(conf.spool_dir) + 1]), 13);
    7.21  
    7.22  		DEBUG(5) debugf("uid: %s\n", uid);
    7.23  
    7.24 @@ -196,8 +196,8 @@
    7.25  {
    7.26  	gboolean hdr_ok = TRUE;
    7.27  	gboolean dat_ok = TRUE;
    7.28 -	gchar *hdr_name = g_strdup_printf("%s/input/%s-H", conf.spool_dir, uid);
    7.29 -	gchar *dat_name = g_strdup_printf("%s/input/%s-D", conf.spool_dir, uid);
    7.30 +	gchar *hdr_name = g_strdup_printf("%s/%s-H", conf.spool_dir, uid);
    7.31 +	gchar *dat_name = g_strdup_printf("%s/%s-D", conf.spool_dir, uid);
    7.32  	struct stat stat_buf;
    7.33  
    7.34  	if (!spool_lock(uid)) {
     8.1 --- a/src/spool.c	Wed May 30 09:38:38 2012 +0200
     8.2 +++ b/src/spool.c	Wed May 30 10:27:10 2012 +0200
     8.3 @@ -96,7 +96,7 @@
     8.4  	gchar *spool_file;
     8.5  
     8.6  	DEBUG(5) debugf("spool_read_data entered\n");
     8.7 -	spool_file = g_strdup_printf("%s/input/%s-D", conf.spool_dir, msg->uid);
     8.8 +	spool_file = g_strdup_printf("%s/%s-D", conf.spool_dir, msg->uid);
     8.9  	DEBUG(5) debugf("reading data spool file '%s'\n", spool_file);
    8.10  	in = fopen(spool_file, "r");
    8.11  	if (!in) {
    8.12 @@ -127,7 +127,7 @@
    8.13  	gchar *spool_file;
    8.14  
    8.15  	/* header spool: */
    8.16 -	spool_file = g_strdup_printf("%s/input/%s-H", conf.spool_dir, msg->uid);
    8.17 +	spool_file = g_strdup_printf("%s/%s-H", conf.spool_dir, msg->uid);
    8.18  	in = fopen(spool_file, "r");
    8.19  	if (!in) {
    8.20  		logwrite(LOG_ALERT, "could not open spool header file %s: %s\n",
    8.21 @@ -232,7 +232,7 @@
    8.22  	gboolean ok = TRUE;
    8.23  
    8.24  	/* header spool: */
    8.25 -	tmp_file = g_strdup_printf("%s/input/%d-H.tmp", conf.spool_dir, getpid());
    8.26 +	tmp_file = g_strdup_printf("%s/%d-H.tmp", conf.spool_dir, getpid());
    8.27  	DEBUG(4) debugf("tmp_file = %s\n", tmp_file);
    8.28  
    8.29  	if ((out = fopen(tmp_file, "w"))) {
    8.30 @@ -282,7 +282,7 @@
    8.31  		}
    8.32  		fclose(out);
    8.33  		if (ok) {
    8.34 -			spool_file = g_strdup_printf("%s/input/%s-H", conf.spool_dir, msg->uid);
    8.35 +			spool_file = g_strdup_printf("%s/%s-H", conf.spool_dir, msg->uid);
    8.36  			DEBUG(4) debugf("spool_file = %s\n", spool_file);
    8.37  			ok = (rename(tmp_file, spool_file) != -1);
    8.38  			g_free(spool_file);
    8.39 @@ -319,7 +319,7 @@
    8.40  
    8.41  	if (ok && do_write_data) {
    8.42  		/* data spool: */
    8.43 -		tmp_file = g_strdup_printf("%s/input/%d-D.tmp", conf.spool_dir, getpid());
    8.44 +		tmp_file = g_strdup_printf("%s/%d-D.tmp", conf.spool_dir, getpid());
    8.45  		DEBUG(4) debugf("tmp_file = %s\n", tmp_file);
    8.46  
    8.47  		if ((out = fopen(tmp_file, "w"))) {
    8.48 @@ -338,7 +338,7 @@
    8.49  			}
    8.50  			fclose(out);
    8.51  			if (ok) {
    8.52 -				spool_file = g_strdup_printf("%s/input/%s-D", conf.spool_dir, msg->uid);
    8.53 +				spool_file = g_strdup_printf("%s/%s-D", conf.spool_dir, msg->uid);
    8.54  				DEBUG(4) debugf("spool_file = %s\n", spool_file);
    8.55  				ok = (rename(tmp_file, spool_file) != -1);
    8.56  				g_free(spool_file);
    8.57 @@ -428,14 +428,14 @@
    8.58  	}
    8.59  
    8.60  	/* header spool: */
    8.61 -	spool_file = g_strdup_printf("%s/input/%s-H", conf.spool_dir, msg->uid);
    8.62 +	spool_file = g_strdup_printf("%s/%s-H", conf.spool_dir, msg->uid);
    8.63  	if (unlink(spool_file) != 0) {
    8.64  		logwrite(LOG_ALERT, "could not delete spool file %s: %s\n", spool_file, strerror(errno));
    8.65  	}
    8.66  	g_free(spool_file);
    8.67  
    8.68  	/* data spool: */
    8.69 -	spool_file = g_strdup_printf("%s/input/%s-D", conf.spool_dir, msg->uid);
    8.70 +	spool_file = g_strdup_printf("%s/%s-D", conf.spool_dir, msg->uid);
    8.71  	if (unlink(spool_file) != 0) {
    8.72  		logwrite(LOG_ALERT, "could not delete spool file %s: %s\n", spool_file, strerror(errno));
    8.73  	}