⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qmail-maildir++.patch

📁 相当优秀的 UNIX 进程管理工具
💻 PATCH
📖 第 1 页 / 共 3 页
字号:
                                                                       6/9/2002This patch adds maildirquota (Maildir++) support to qmail-pop3d andqmail-local.  It was created because when vpopmail switched to maildirquotas,a user's quota usage was not decreased after deleting mail via qmail-pop3d.Also, because .qmail files would allow qmail-local to write directly to aMaildir whithout piping through vdelivermail first, quotas were not effectivefor aliases.  Actually, this was the case with vpopmail's old quota system aswell.This patch is not specific to vpopmail.  If you use qmail with other agents thatsupport Maildir++, this should work for you.The functions used in this patch are taken from maildrop 1.3.9 and courier'spop daemon, by Sam Varshavchik (www.courier-mta.org).  The Maildir++specification, also by Sam, can be viewed here:http://inter7.com/courierimap/README.maildirquota.htmlHowever, Sam had NOTHING to do with this patch, so please don't bug him aboutit.  Either bug me directly, or the vpopmail list (vchkpw@inter7.com), whoactually requested it.Cheers,Bill Shupphostmaster@shupp.orgwww.shupp.orgdiff -crN ../qmail-1.03/Makefile ./Makefile*** ../qmail-1.03/Makefile	Mon Jun 15 05:53:16 1998--- ./Makefile	Mon Jun 10 13:25:46 2002****************** 890,895 ****--- 890,927 ----  readwrite.h open.h headerbody.h maildir.h strerr.h  	./compile maildirwatch.c  + maildirgetquota.o: \+ compile maildirgetquota.c maildirgetquota.h maildirmisc.h+ 	./compile maildirgetquota.c+ + maildirflags.o: \+ compile maildirflags.c+ 	./compile maildirflags.c+ + maildiropen.o: \+ compile maildiropen.c maildirmisc.h+ 	./compile maildiropen.c+ + maildirparsequota.o: \+ compile maildirparsequota.c+ 	./compile maildirparsequota.c+ + maildirquota.o: \+ compile maildirquota.c maildirquota.h maildirmisc.h numlib.h+ 	./compile maildirquota.c+ + overmaildirquota.o: \+ compile overmaildirquota.c + 	./compile overmaildirquota.c+ + strtimet.o: \+ compile strtimet.c + 	./compile strtimet.c+ + strpidt.o: \+ compile strpidt.c + 	./compile strpidt.c+   mailsubj: \  warn-auto.sh mailsubj.sh conf-qmail conf-break conf-split  	cat warn-auto.sh mailsubj.sh \****************** 1174,1185 ****  load qmail-local.o qmail.o quote.o now.o gfrom.o myctime.o \  slurpclose.o case.a getln.a getopt.a sig.a open.a seek.a lock.a fd.a \  wait.a env.a stralloc.a alloc.a strerr.a substdio.a error.a str.a \! fs.a datetime.a auto_qmail.o auto_patrn.o socket.lib  	./load qmail-local qmail.o quote.o now.o gfrom.o myctime.o \  	slurpclose.o case.a getln.a getopt.a sig.a open.a seek.a \  	lock.a fd.a wait.a env.a stralloc.a alloc.a strerr.a \  	substdio.a error.a str.a fs.a datetime.a auto_qmail.o \! 	auto_patrn.o  `cat socket.lib`    qmail-local.0: \  qmail-local.8--- 1206,1220 ----  load qmail-local.o qmail.o quote.o now.o gfrom.o myctime.o \  slurpclose.o case.a getln.a getopt.a sig.a open.a seek.a lock.a fd.a \  wait.a env.a stralloc.a alloc.a strerr.a substdio.a error.a str.a \! fs.a datetime.a auto_qmail.o auto_patrn.o socket.lib maildirquota.o \! maildirgetquota.o maildiropen.o maildirparsequota.o overmaildirquota.o \! strtimet.o strpidt.o  	./load qmail-local qmail.o quote.o now.o gfrom.o myctime.o \  	slurpclose.o case.a getln.a getopt.a sig.a open.a seek.a \  	lock.a fd.a wait.a env.a stralloc.a alloc.a strerr.a \  	substdio.a error.a str.a fs.a datetime.a auto_qmail.o \! 	auto_patrn.o  `cat socket.lib` maildirquota.o maildirgetquota.o \!     maildiropen.o maildirparsequota.o overmaildirquota.o strtimet.o strpidt.o    qmail-local.0: \  qmail-local.8****************** 1269,1279 ****  qmail-pop3d: \  load qmail-pop3d.o commands.o case.a timeoutread.o timeoutwrite.o \  maildir.o prioq.o now.o env.a strerr.a sig.a open.a getln.a \! stralloc.a alloc.a substdio.a error.a str.a fs.a socket.lib  	./load qmail-pop3d commands.o case.a timeoutread.o \  	timeoutwrite.o maildir.o prioq.o now.o env.a strerr.a sig.a \  	open.a getln.a stralloc.a alloc.a substdio.a error.a str.a \! 	fs.a  `cat socket.lib`    qmail-pop3d.0: \  qmail-pop3d.8--- 1304,1316 ----  qmail-pop3d: \  load qmail-pop3d.o commands.o case.a timeoutread.o timeoutwrite.o \  maildir.o prioq.o now.o env.a strerr.a sig.a open.a getln.a \! stralloc.a alloc.a substdio.a error.a str.a fs.a socket.lib maildirquota.o \! maildirparsequota.o maildirflags.o maildiropen.o strtimet.o strpidt.o  	./load qmail-pop3d commands.o case.a timeoutread.o \  	timeoutwrite.o maildir.o prioq.o now.o env.a strerr.a sig.a \  	open.a getln.a stralloc.a alloc.a substdio.a error.a str.a \! 	fs.a  `cat socket.lib` maildirquota.o maildirgetquota.o \!     maildirparsequota.o maildirflags.o maildiropen.o strtimet.o strpidt.o    qmail-pop3d.0: \  qmail-pop3d.8diff -crN ../qmail-1.03/TARGETS ./TARGETS*** ../qmail-1.03/TARGETS	Mon Jun 15 05:53:16 1998--- ./TARGETS	Mon Jun 10 13:25:46 2002****************** 15,20 ****--- 15,28 ----  slurpclose.o  make-makelib  makelib+ maildirflags.o+ maildirparsequota.o+ maildiropen.o+ maildirgetquota.o+ maildirquota.o+ overmaildirquota.o+ strtimet.o+ strpidt.o  case_diffb.o  case_diffs.o  case_lowerb.odiff -crN ../qmail-1.03/maildirflags.c ./maildirflags.c*** ../qmail-1.03/maildirflags.c	Wed Dec 31 18:00:00 1969--- ./maildirflags.c	Mon Jun 10 13:25:46 2002****************** 0 ****--- 1,23 ----+ /*+ ** Copyright 2000 Double Precision, Inc.+ ** See COPYING for distribution information.+ */+ + #include	<sys/types.h>+ #include	<string.h>+ + static const char rcsid[]="$Id: qmail-maildir++.patch,v 1.1.1.1 2003/09/10 20:43:16 tomcollins Exp $";+ + int maildir_hasflag(const char *filename, char flag)+ {+ 	const char *p=strrchr(filename, '/');+ + 	if (p)+ 		filename=p+1;+ + 	p=strrchr(p, ':');+ 	if (p && strncmp(p, ":2,", 3) == 0 &&+ 	    strchr(p+3, flag))+ 		return (1);+ 	return (0);+ }diff -crN ../qmail-1.03/maildirgetquota.c ./maildirgetquota.c*** ../qmail-1.03/maildirgetquota.c	Wed Dec 31 18:00:00 1969--- ./maildirgetquota.c	Mon Jun 10 13:25:46 2002****************** 0 ****--- 1,50 ----+ /*+ ** Copyright 1998 - 2000 Double Precision, Inc.+ ** See COPYING for distribution information.+ */+ + #include	"maildirgetquota.h"+ #include	"maildirmisc.h"+ #if	HAVE_UNISTD_H+ #include	<unistd.h>+ #endif+ #include	<stdlib.h>+ #include	<string.h>+ #include	<fcntl.h>+ #include	<sys/types.h>+ #include	<sys/stat.h>+ + int	maildir_getquota(const char *dir, char buf[QUOTABUFSIZE])+ {+ char	*p;+ struct	stat	stat_buf;+ int	n;+ int	l;+ + 	p=(char *)malloc(strlen(dir)+sizeof("/maildirfolder"));+ 	if (!p)	return (-1);+ + 	strcat(strcpy(p, dir), "/maildirfolder");+ 	if (stat(p, &stat_buf) == 0)+ 	{+ 		strcat(strcpy(p, dir), "/..");+ 		n=maildir_getquota(p, buf);+ 		free(p);+ 		return (n);+ 	}+ + 	strcat(strcpy(p, dir), "/maildirsize");+ 	n=maildir_safeopen(p, O_RDONLY, 0);+ 	free(p);+ 	if (n < 0)	return (n);+ 	if ((l=read(n, buf, QUOTABUFSIZE-1)) < 0)+ 	{+ 		close(n);+ 		return (-1);+ 	}+ 	close(n);+ 	for (n=0; n<l; n++)+ 		if (buf[n] == '\n')	break;+ 	buf[n]=0;+ 	return (0);+ }diff -crN ../qmail-1.03/maildirgetquota.h ./maildirgetquota.h*** ../qmail-1.03/maildirgetquota.h	Wed Dec 31 18:00:00 1969--- ./maildirgetquota.h	Mon Jun 10 13:25:46 2002****************** 0 ****--- 1,30 ----+ #ifndef	maildirgetquota_h+ #define	maildirgetquota_h+ + /*+ ** Copyright 1998 - 1999 Double Precision, Inc.+ ** See COPYING for distribution information.+ */+ + #if	HAVE_CONFIG_H+ #include	"config.h"+ #endif+ + #include	<sys/types.h>+ #include	<stdio.h>+ + #ifdef  __cplusplus+ extern "C" {+ #endif+ + static const char maildirgetquota_h_rcsid[]="$Id: qmail-maildir++.patch,v 1.1.1.1 2003/09/10 20:43:16 tomcollins Exp $";+ + #define	QUOTABUFSIZE	256+ + int maildir_getquota(const char *, char [QUOTABUFSIZE]);+ + #ifdef  __cplusplus+ }+ #endif+ + #endifdiff -crN ../qmail-1.03/maildirmisc.h ./maildirmisc.h*** ../qmail-1.03/maildirmisc.h	Wed Dec 31 18:00:00 1969--- ./maildirmisc.h	Mon Jun 10 13:25:46 2002****************** 0 ****--- 1,145 ----+ #ifndef	maildirmisc_h+ #define	maildirmisc_h+ + /*+ ** Copyright 2000 Double Precision, Inc.+ ** See COPYING for distribution information.+ */+ + #if	HAVE_CONFIG_H+ #include	"config.h"+ #endif+ + #ifdef  __cplusplus+ extern "C" {+ #endif+ + static const char maildirmisc_h_rcsid[]="$Id: qmail-maildir++.patch,v 1.1.1.1 2003/09/10 20:43:16 tomcollins Exp $";+ + /*+ **+ ** Miscellaneous maildir-related code+ **+ */+ + /* Some special folders */+ + #define	INBOX	"INBOX"+ #define	DRAFTS	"Drafts"+ #define	SENT	"Sent"+ #define	TRASH	"Trash"+ + #define	SHAREDSUBDIR	"shared-folders"+ + char *maildir_folderdir(const char *,		/* maildir */+ 	const char *);				/* folder name */+ 	/* Returns the directory corresponding to foldername (foldername is+ 	** checked to make sure that it's a valid name, else we set errno+ 	** to EINVAL, and return (0).+ 	*/+ + char *maildir_filename(const char *,		/* maildir */+ 	const char *,				/* folder */+ 	const char *);				/* filename */+ 	/*+ 	** Builds the filename to this message, suitable for opening.+ 	** If the file doesn't appear to be there, search the maildir to+ 	** see if someone changed the flags, and return the current filename.+ 	*/+ + int maildir_safeopen(const char *,		/* filename */+ 	int,				/* mode */+ 	int);				/* perm */+ + /*+ **	Same arguments as open().  When we're accessing a shared maildir,+ **	prevent someone from playing cute and dumping a bunch of symlinks+ **	in there.  This function will open the indicate file only if the+ **	last component is not a symlink.+ **	This is implemented by opening the file with O_NONBLOCK (to prevent+ **	a DOS attack of someone pointing the symlink to a pipe, causing+ **	the open to hang), clearing O_NONBLOCK, then stat-int the file+ **	descriptor, lstating the filename, and making sure that dev/ino+ **	match.+ */+ + int maildir_semisafeopen(const char *,	/* filename */+ 	int,				/* mode */+ 	int);				/* perm */+ + /*+ ** Same thing, except that we allow ONE level of soft link indirection,+ ** because we're reading from our own maildir, which points to the+ ** message in the sharable maildir.+ */+ + int maildir_mkdir(const char *);	/* directory */+ /*+ ** Create maildir including all subdirectories in the path (like mkdir -p)+ */+ + void maildir_purgetmp(const char *);		/* maildir */+ 	/* purges old stuff out of tmp */+ + void maildir_purge(const char *,		/* directory */+ 	unsigned);				/* time_t to purge */+ + void maildir_getnew(const char *,		/* maildir */+ 	const char *);				/* folder */+ 	/* move messages from new to cur */+ + int maildir_deletefolder(const char *,		/* maildir */+ 	const char *);				/* folder */+ 	/* deletes a folder */+ + int maildir_mddelete(const char *);	/* delete a maildir folder by path */+ + void maildir_list_sharable(const char *,	/* maildir */+ 	void (*)(const char *, void *),		/* callback function */+ 	void *);				/* 2nd arg to callback func */+ 	/* list sharable folders */+ + int maildir_shared_subscribe(const char *,	/* maildir */+ 		const char *);			/* folder */+ 	/* subscribe to a shared folder */+ + void maildir_list_shared(const char *,		/* maildir */+ 	void (*)(const char *, void *),		/* callback function */+ 	void *);			/* 2nd arg to the callback func */+ 	/* list subscribed folders */+ + int maildir_shared_unsubscribe(const char *,	/* maildir */+ 		const char *);			/* folder */+ 	/* unsubscribe from a shared folder */+ + char *maildir_shareddir(const char *,		/* maildir */+ 	const char *);				/* folder */+ 	/*+ 	** Validate and return a path to a shared folder.  folderdir must be+ 	** a name of a valid shared folder.+ 	*/+ + void maildir_shared_sync(const char *);		/* maildir */+ 	/* "sync" the shared folder */+ + int maildir_sharedisro(const char *);		/* maildir */+ 	/* maildir is a shared read-only folder */+ + int maildir_unlinksharedmsg(const char *);	/* filename */+ 	/* Remove a message from a shared folder */+ + /* Internal function that reads a symlink */+ + char *maildir_getlink(const char *);+ + 	/* Determine whether the maildir filename has a certain flag */+ + int maildir_hasflag(const char *filename, char);+ + #define	MAILDIR_DELETED(f)	maildir_hasflag((f), 'T')+ + #ifdef  __cplusplus+ }+ #endif+ + #endifdiff -crN ../qmail-1.03/maildiropen.c ./maildiropen.c*** ../qmail-1.03/maildiropen.c	Wed Dec 31 18:00:00 1969--- ./maildiropen.c	Mon Jun 10 13:25:46 2002****************** 0 ****--- 1,133 ----+ /*+ ** Copyright 2000 Double Precision, Inc.+ ** See COPYING for distribution information.+ */+ + #if HAVE_CONFIG_H+ #include "config.h"+ #endif+ + #include	<sys/types.h>+ #include	<sys/stat.h>+ #include	<string.h>+ #include	<stdlib.h>+ #include	<time.h>+ #if	HAVE_UNISTD_H+ #include	<unistd.h>+ #endif+ #include	<stdio.h>+ #include	<ctype.h>+ #include	<errno.h>+ #include	<fcntl.h>+ + #include	"maildirmisc.h"+ + static const char rcsid[]="$Id: qmail-maildir++.patch,v 1.1.1.1 2003/09/10 20:43:16 tomcollins Exp $";+ + char *maildir_getlink(const char *filename)+ {+ #if     HAVE_READLINK+ size_t	bufsiz;+ char	*buf;+ + 	bufsiz=0;+ 	buf=0;+ + 	for (;;)+ 	{+ 	int	n;+ + 		if (buf)	free(buf);+ 		bufsiz += 256;+ 		if ((buf=malloc(bufsiz)) == 0)+ 		{+ 			perror("malloc");+ 			return (0);+ 		}+ 		if ((n=readlink(filename, buf, bufsiz)) < 0)+ 		{+ 			free(buf);+ 			return (0);+ 		}+ 		if (n < bufsiz)+ 		{+ 			buf[n]=0;+ 			break;+ 		}+ 	}+ 	return (buf);+ #else+ 	return (0);+ #endif+ }+ + int maildir_semisafeopen(const char *path, int mode, int perm)+ {+ + #if	HAVE_READLINK+ + char	*l=maildir_getlink(path);+ + 	if (l)+ 	{+ 	int	f;+ + 		if (*l != '/')+ 		{+ 		char	*q=malloc(strlen(path)+strlen(l)+2);+ 		char	*s;+ + 			if (!q)+ 			{+ 				free(l);+ 				return (-1);+ 			}+ + 			strcpy(q, path);+ 			if ((s=strchr(q, '/')) != 0)+ 				s[1]=0;+ 			else	*q=0;+ 			strcat(q, l);+ 			free(l);+ 			l=q;+ 		}+ + 		f=maildir_safeopen(l, mode, perm);+ + 		free(l);+ 		return (f);+ 	}+ #endif+ + 	return (maildir_safeopen(path, mode, perm));+ }+ 		+ int maildir_safeopen(const char *path, int mode, int perm)+ {+ struct	stat	stat1, stat2;+ + int	fd=open(path, mode+ #ifdef	O_NONBLOCK+ 			| O_NONBLOCK+ #else+ 			| O_NDELAY+ #endif+ 				, perm);+ + 	if (fd < 0)	return (fd);+ 	if (fcntl(fd, F_SETFL, (mode & O_APPEND)) || fstat(fd, &stat1)+ 	    || lstat(path, &stat2))+ 	{+ 		close(fd);+ 		return (-1);+ 	}+ + 	if (stat1.st_dev != stat2.st_dev || stat1.st_ino != stat2.st_ino)+ 	{+ 		close(fd);+ 		errno=ENOENT;+ 		return (-1);+ 	}+ + 	return (fd);+ }diff -crN ../qmail-1.03/maildirparsequota.c ./maildirparsequota.c*** ../qmail-1.03/maildirparsequota.c	Wed Dec 31 18:00:00 1969--- ./maildirparsequota.c	Mon Jun 10 13:25:46 2002****************** 0 ****--- 1,44 ----+ /*+ ** Copyright 1998 - 1999 Double Precision, Inc.+ ** See COPYING for distribution information.+ */+ + #if HAVE_CONFIG_H+ #include "config.h"+ #endif+ #include	"maildirquota.h"+ #include	<stdlib.h>+ #include	<string.h>+ + static const char rcsid[]="$Id: qmail-maildir++.patch,v 1.1.1.1 2003/09/10 20:43:16 tomcollins Exp $";+ + int maildir_parsequota(const char *n, unsigned long *s)+ {+ const char *o;+ int	yes;+ + 	if ((o=strrchr(n, '/')) == 0)	o=n;+ + 	for (; *o; o++)+ 		if (*o == ':')	break;+ 	yes=0;+ 	for ( ; o >= n; --o)+ 	{+ 		if (*o == '/')	break;+ + 		if (*o == ',' && o[1] == 'S' && o[2] == '=')+ 		{+ 			yes=1;+ 			o += 3;+ 			break;+ 		}+ 	}+ 	if (yes)+ 	{+ 		*s=0;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -