Update to the last stable release, 5.4.13. In the process:

- temporarily disable the SpamAssassin patch, since vdelivermail was
  reorganized a bit;
- fix a couple of potential buffer bound problems;
- remove the unconditional -fPIC; we handle this ourselves for amd64.
This commit is contained in:
Peter Pentchev 2006-06-16 13:00:57 +00:00
parent 7747738da3
commit deb73f82b0
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=165574
5 changed files with 103 additions and 212 deletions

View file

@ -6,8 +6,7 @@
#
PORTNAME= vpopmail
PORTVERSION= 5.4.10
PORTREVISION= 9
PORTVERSION= 5.4.13
CATEGORIES= mail
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE}
MASTER_SITE_SUBDIR= ${PORTNAME}
@ -58,7 +57,6 @@ CONFIGURE_TARGET= --build=${MACHINE_ARCH}-portbld-freebsd${OSREL}
# WITH_FILE_SYNC - enables immediate synching (may decrease performance)
# WITHOUT_USERS_BIG_DIR - disables using big directories for users
# WITHOUT_SEEKABLE - disables vdelivermail's attempt to make its input seekable
# WITH_DOMAIN_QUOTAS - enable domain quotas
# WITH_SPAMASSASSIN - enable SpamAssassin checks before Maildir delivery
# WITH_SUID_VCHKPW - set the setuid bit on the vchkpw program
# WITH_SMTP_AUTH_PATCH - apply an SMTP authentcation fix
@ -284,14 +282,11 @@ CONFIGURE_ARGS+= --disable-users-big-dir
CONFIGURE_ARGS+= --disable-make-seekable
.endif
.if defined(WITH_DOMAIN_QUOTAS)
CONFIGURE_ARGS+= --enable-domainquotas
.endif
.if defined(WITH_SPAMASSASSIN)
BUILD_DEPENDS+= spamc:${PORTSDIR}/mail/p5-Mail-SpamAssassin
CONFIGURE_ARGS+= --enable-spamassassin=${LOCALBASE}/bin/spamc \
--enable-spam-threshold=${SPAM_THRESHOLD}
#BUILD_DEPENDS+= spamc:${PORTSDIR}/mail/p5-Mail-SpamAssassin
#CONFIGURE_ARGS+= --enable-spamassassin=${LOCALBASE}/bin/spamc \
# --enable-spam-threshold=${SPAM_THRESHOLD}
IGNORE= The SpamAssassin patch is not yet ready for the slightly reorganized vpopmail code
.endif
#

View file

@ -1,3 +1,3 @@
MD5 (vpopmail-5.4.10.tar.gz) = 6709827f515f632424c2223c964698a1
SHA256 (vpopmail-5.4.10.tar.gz) = 985054943b7382d4135094b5e282c87c0fef8527f6a6bf6477b59849970bb508
SIZE (vpopmail-5.4.10.tar.gz) = 432341
MD5 (vpopmail-5.4.13.tar.gz) = da0bf4dd773ec725171dc6d41ee4b3cd
SHA256 (vpopmail-5.4.13.tar.gz) = 0cb13c797ef1dbfa858c237ed7002d9b943901d0fd8884b73d82f71936be5b97
SIZE (vpopmail-5.4.13.tar.gz) = 434719

View file

@ -1,15 +1,23 @@
--- Makefile.in.old Fri Nov 28 09:45:59 2003
+++ Makefile.in Fri Nov 28 09:46:37 2003
@@ -723,6 +723,8 @@
echo "-I@vpopmaildir@/include" > @vpopmaildir@/etc/inc_deps
echo "-L@vpopmaildir@/lib -lvpopmail @auth_libs@ @LIBS@" > @vpopmaildir@/etc/lib_deps
--- Makefile.in.orig Sat Sep 17 02:37:34 2005
+++ Makefile.in Thu Jun 15 16:58:59 2006
@@ -101,7 +101,6 @@
libvpopmail_a_SOURCES = $(COMMONSOURCES)
libvpopmail_a_LIBADD = cdb/*.o
-libvpopmail_a_CFLAGS = -fPIC
vpopmailbindir = @vpopmaildir@/bin
vpopmailbin_PROGRAMS = vchkpw vdelivermail clearopensmtp vadddomain \
@@ -861,6 +860,8 @@
echo "-L@vpopmaildir@/lib -lvpopmail @auth_libs@ @LIBS@" > \
$(DESTDIR)@vpopmaildir@/etc/lib_deps
+ $(INSTALL) -o @vpopuser@ -m 0644 -g @vpopgroup@ \
+ vlimits.default $(VLIMITS)-dist; \
if test ! -r $(VLIMITS); then \
$(INSTALL) -o @vpopuser@ -m 0644 -g @vpopgroup@ \
vlimits.default $(VLIMITS); \
@@ -740,7 +742,6 @@
@@ -878,7 +879,6 @@
echo "# settings for each line:" >> $(MYSQLCONF); \
echo "# host|port|user|password|database" >> $(MYSQLCONF); \
echo "#" >> $(MYSQLCONF); \

View file

@ -0,0 +1,11 @@
--- cdb/Makefile.orig Thu Jun 15 17:00:43 2006
+++ cdb/Makefile Thu Jun 15 17:01:23 2006
@@ -43,7 +43,7 @@
compile: \
warn-auto.sh conf-cc
( cat warn-auto.sh; \
- echo exec "`head -1 conf-cc`" -fPIC '-c $${1+"$$@"}' \
+ echo exec "`head -1 conf-cc`" '-c $${1+"$$@"}' \
) > compile
chmod 755 compile

View file

@ -1,25 +1,15 @@
--- vdelivermail.c.orig Thu May 27 03:31:09 2004
+++ vdelivermail.c Fri Jul 1 19:20:25 2005
@@ -62,6 +62,7 @@
#define FILE_SIZE 156
char hostname[FILE_SIZE];
char loop_buf[FILE_SIZE];
+char spam_buf[FILE_SIZE];
--- vdelivermail.c.orig Fri Sep 2 21:47:29 2005
+++ vdelivermail.c Thu Jun 15 16:50:36 2006
@@ -201,7 +201,7 @@
if ( is_domain_valid(TheDomain) != 0 )
vexiterr (EXIT_BOUNCE, "invalid domain name");
#define MSG_BUF_SIZE 5000
char msgbuf[MSG_BUF_SIZE];
@@ -89,6 +90,10 @@
void usernotfound(void);
int is_loop_match( char *dt, char *address);
int deliver_quota_warning(const char *dir, const char *q);
+#ifdef SPAM_THRESHOLD
+int is_spam(int threshold);
+int is_spam_match(char *xsl, int threshold);
+#endif
- strncpy(TheUserFull, TheUser, sizeof(TheUserFull));
+ snprintf (TheUserFull, sizeof(TheUserFull), "%s", TheUser);
static char local_file[156];
static char local_file_new[156];
@@ -256,7 +261,7 @@
#ifdef QMAIL_EXT
/* !! Shouldn't this work its way backwards, and try all possibilities?
@@ -247,7 +247,7 @@
/* check for wildcard if there's no match */
if(tmpstr == NULL) {
@ -28,187 +18,74 @@
if(TheUser[i-1]=='-') {
tmpuser[0] = '\0';
strncat(tmpuser,TheUser,i);
@@ -444,6 +449,7 @@
int write_fd;
FILE *fs;
char tmp_file[256];
+ int pim[2];
@@ -547,10 +547,10 @@
if (user_over_maildirquota(address,format_maildirquota(quota))==1) {
/* This is a comment, ignore it */
if ( *address == '#' ) return(0);
@@ -631,6 +637,51 @@
}
}
/* check for over quota message in domain */
- sprintf(tmp_file, "%s/.over-quota.msg",TheDomainDir);
+ snprintf(tmp_file, sizeof(tmp_file), "%s/.over-quota.msg",TheDomainDir);
if ( (fs=fopen(tmp_file, "r")) == NULL ) {
/* if no domain over quota then check in vpopmail dir */
- sprintf(tmp_file, "%s/%s/.over-quota.msg",VPOPMAILDIR,DOMAINS_DIR);
+ snprintf(tmp_file, sizeof(tmp_file), "%s/%s/.over-quota.msg",VPOPMAILDIR,DOMAINS_DIR);
fs=fopen(tmp_file, "r");
}
+#ifdef SPAMC
+ /* fork the SpamAssassin client - patch by Alex Dupre */
+ if (!pipe(pim)) {
+ pid = vfork();
+ switch (pid) {
+ case -1:
+ close(pim[0]);
+ close(pim[1]);
+ break;
+ case 0:
+ close(pim[0]);
+ dup2(pim[1], 1);
+ close(pim[1]);
+ if (execl(SPAMC, SPAMC, "-u", maildir_to_email(address), 0) == -1) {
+ while ((file_count = read(0, msgbuf, MSG_BUF_SIZE)) > 0)
+ write(1, msgbuf, file_count);
+ _exit(0);
+ }
+ }
+ close(pim[1]);
+ dup2(pim[0], 0);
+ close(pim[0]);
+ }
+#ifdef SPAM_THRESHOLD
+ /* silently delete message if spam level > SPAM_THRESHOLD */
+ if (is_spam(SPAM_THRESHOLD) == 1) {
+ close(write_fd);
+ if (unlink(local_file) != 0) {
+ printf("unlink failed %s errno = %d\n", local_file, errno);
+ return(errno);
+ }
+ return(0);
+ }
+
+#ifdef MAKE_SEEKABLE
+ if (!Seekable(0))
+ MakeSeekable(stdin);
+#endif
+
+ if (lseek(0, 0L, SEEK_SET) < 0) {
+ printf("lseek errno=%d\n", errno);
+ return(errno);
+ }
+#endif
+#endif
@@ -577,10 +577,10 @@
if (domain_over_maildirquota(address)==1)
{
/* check for over quota message in domain */
- sprintf(tmp_file, "%s/.over-quota.msg",TheDomainDir);
+ snprintf(tmp_file, sizeof(tmp_file), "%s/.over-quota.msg",TheDomainDir);
if ( (fs=fopen(tmp_file, "r")) == NULL ) {
/* if no domain over quota then check in vpopmail dir */
- sprintf(tmp_file, "%s/%s/.over-quota.msg",VPOPMAILDIR,DOMAINS_DIR);
+ snprintf(tmp_file, sizeof(tmp_file), "%s/%s/.over-quota.msg",VPOPMAILDIR,DOMAINS_DIR);
fs=fopen(tmp_file, "r");
}
/* read it in chunks and write it to the new file */
while((file_count=read(0,msgbuf,MSG_BUF_SIZE))>0) {
@@ -823,6 +874,7 @@
printf("unable to fork\n");
exit(0);
@@ -769,6 +769,7 @@
printf("Unable to fork: %d.", errno);
vexit(EXIT_DEFER);
case 0:
+ setenv("SHELL", "/bin/sh", 1);
args[0] = "/bin/sh"; args[1] = "-c"; args[2] = prog; args[3] = 0;
sig_catch(SIGPIPE,SIG_DFL);
execv(*args,args);
@@ -882,6 +934,9 @@
if (strncmp(loop_buf, "Delivered-To: ", 14) == 0 &&
is_loop_match(loop_buf, address)==1 ) {
@@ -943,10 +944,10 @@
FILE *fs;
char tmp_file[256];
+ /* seek to the end of stdin */
+ fseek(stdin, 0L, SEEK_END);
+
/* return the loop found */
return(1);
- sprintf(tmp_file, "%s/.no-user.msg",TheDomainDir);
+ snprintf(tmp_file, sizeof(tmp_file), "%s/.no-user.msg",TheDomainDir);
if ( (fs=fopen(tmp_file, "r")) == NULL ) {
/* if no domain no user then check in vpopmail dir */
- sprintf(tmp_file, "%s/%s/.no-user.msg",VPOPMAILDIR,DOMAINS_DIR);
+ snprintf(tmp_file, sizeof(tmp_file), "%s/%s/.no-user.msg",VPOPMAILDIR,DOMAINS_DIR);
fs=fopen(tmp_file, "r");
}
if ( fs == NULL ) {
@@ -993,7 +994,7 @@
struct stat sb;
char quotawarnmsg[BUFF_SIZE];
@@ -920,6 +975,8 @@
* looping not found value
*/
if ( found == 0 ) {
+ /* seek to the end of stdin */
+ fseek(stdin, 0L, SEEK_END);
/* return not found looping message value */
return(0);
}
@@ -1300,3 +1357,96 @@
return(1);
}
- sprintf (quotawarnmsg, "%s%s", dir, "/quotawarn");
+ snprintf (quotawarnmsg, sizeof(quotawarnmsg), "%s%s", dir, "/quotawarn");
time(&tm);
+#ifdef SPAM_THRESHOLD
+/* Check for a spam message
+ * This is done by checking for a matching line
+ * in the email headers for X-Spam-Level: which
+ * we put in each spam email
+ *
+ * Return 1 if spam
+ * Return 0 if not spam
+ * Return -1 on error
+ */
+int is_spam(int threshold)
+{
+ int i;
+ int found;
+
+#ifdef MAKE_SEEKABLE
+ if (!Seekable(0))
+ MakeSeekable(stdin);
+#endif
+
+ if ( lseek(0, 0L, SEEK_SET) < 0 ) {
+ printf("lseek errno=%d\n", errno);
+ return(errno);
+ }
+
+ while (fgets(spam_buf, sizeof(spam_buf), stdin) != NULL){
+
+ /* if we find the line, return error (looping) */
+ if (strncmp(spam_buf, "X-Spam-Level: ", 14) == 0 &&
+ is_spam_match(spam_buf, threshold) ==1) {
+
+ /* seek to the end of stdin */
+ fseek(stdin, 0L, SEEK_END);
+
+ /* return the spam found */
+ return(1);
+
+ /* check for the start of the body, we only need
+ * to check the headers.
+ */
+ } else {
+
+ /* walk through the charaters in the body */
+ for (i = 0, found = 0; spam_buf[i] != 0 && found == 0; ++i) {
+ switch(spam_buf[i]) {
+
+ /* skip blank spaces and new lines */
+ case ' ':
+ case '\n':
+ case '\t':
+ case '\r':
+ break;
+
+ /* found a non blank, so we are still
+ * in the headers
+ */
+ default:
+
+ /* set the found non blank char flag */
+ found = 1;
+ break;
+ }
+ }
+
+ /* if the line only had blanks, then it is the
+ * delimiting line between the headers and the
+ * body. We don't need to check the body for
+ * the X-Spam-Level: line. Hence, we
+ * are done with our search and can return the
+ * spam not found value
+ */
+ if (found == 0) {
+ /* seek to the end of stdin */
+ fseek(stdin, 0L, SEEK_END);
+ /* return not found spam message value */
+ return(0);
+ }
+ }
+ }
+
+ /* if we get here then the there is either no body
+ * or the logic above failed and we scanned
+ * the whole email, headers and body.
+ */
+ return(0);
+}
+
+int is_spam_match(char *xsl, int threshold)
+{
+ if (strlen(xsl) - strlen("X-Spam-Level: ") > threshold) return(1);
+ else return(0);
+}
+#endif
/* Send only one warning every 24 hours */
@@ -1011,12 +1012,12 @@
close(fd);
/* Look in the domain for a .quotawarn.msg */
- sprintf(quotawarnmsg, "%s/.quotawarn.msg", TheDomainDir);
+ snprintf(quotawarnmsg, sizeof(quotawarnmsg), "%s/.quotawarn.msg", TheDomainDir);
if ( ((read_fd = open(quotawarnmsg, O_RDONLY)) < 0) ||
(stat(quotawarnmsg, &sb) != 0)) {
/* if that fails look in vpopmail dir */
- sprintf(quotawarnmsg, "%s/%s/.quotawarn.msg", VPOPMAILDIR, DOMAINS_DIR);
+ snprintf(quotawarnmsg, sizeof(quotawarnmsg), "%s/%s/.quotawarn.msg", VPOPMAILDIR, DOMAINS_DIR);
if ( ((read_fd = open(quotawarnmsg, O_RDONLY)) < 0) ||
(stat(quotawarnmsg, &sb) != 0)) {
return 0;