Bug 114188 - [maintainer-update] mail/p5-Mail-SpamAssassin deletes /var/lib even if used
Summary: [maintainer-update] mail/p5-Mail-SpamAssassin deletes /var/lib even if used
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Pav Lucistnik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-07-01 14:00 UTC by Michael Scheidell
Modified: 2007-07-22 23:50 UTC (History)
0 users

See Also:


Attachments
file.diff (1.27 KB, patch)
2007-07-01 14:00 UTC, Michael Scheidell
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Scheidell 2007-07-01 14:00:15 UTC
PR 112502 erases /var/lib directory during deinstall of SpamAssassin, even if
used by other programs

(Thanks Henrik Olsen)

This patch fixes this.

Second patch adds sa-compile if selected. (spamd fails if user originally
selected sa-compile and did not RUN sa-compile, due to missing libraries)

Note: I do NOT need to bump portrevision since no additional functionality
added, and if user already deleted his /var/lib, this won't bring it back

#1.  no additional functionality added
#2. if sa-compile not run, spamd didn't start, so user had to do it.
#3, users who nightly do a portupgrade -R don't need this to run.

How-To-Repeat: portupgrade p5-Mail-SpamAssassin || make deinstall

patch tried, seems to work:

  Deinstalling p5-Mail-SpamAssassin-3.2.1
rmdir: /var/lib: Directory not empty
pkg_delete: unexec command for 'rmdir /var/lib' failed
pkg_delete: couldn't entirely delete package (perhaps the packing list is
incorrectly specified?)
To delete spamd user permanently, use 'rmuser spamd'
mirror# ls /var/lib/spamassassin/
ls: /var/lib/spamassassin/: No such file or directory
mirror# ls /var/lib
keep.txt
Comment 1 Michael Scheidell 2007-07-06 05:09:38 UTC
ping...

you can also close =
http://www.freebsd.org/cgi/query-pr.cgi?pr=3Dports/114014 as invalid.
Comment 2 Pav Lucistnik freebsd_committer freebsd_triage 2007-07-10 22:55:51 UTC
State Changed
From-To: open->feedback

Question - shouldn't the sa-compile be run from package install too? Now you 
have it only executed when installed from port, but not when installed from 
package. 


Comment 3 Pav Lucistnik freebsd_committer freebsd_triage 2007-07-10 22:55:51 UTC
Responsible Changed
From-To: freebsd-ports-bugs->pav

Track
Comment 4 Michael Scheidell 2007-07-10 23:09:59 UTC
I tried to get it to run in pkg-install and could not.
Id be willing to test patches.

in all reality, sa-compile has to be run in cron every time sa-update is 
run anyway.



_________________________________________________________________________
This email has been scanned and certified safe by SpammerTrap(tm). 
For Information please see http://www.spammertrap.com
_________________________________________________________________________
Comment 5 Pav Lucistnik freebsd_committer freebsd_triage 2007-07-10 23:20:00 UTC
> I tried to get it to run in pkg-install and could not.

Why not?

You need to
1) modify pkg-install to have two different actions on PRE-INSTALL and
   POST-INSTALL
2) add call of POST-INSTALL to Makefile / post-install: target
3) use replacement on pkg-install to conditionalize the execution on
   selected SACOMPILE option. You can use the same trick that gets used
   in pkg-plist, just include SUB_FILES=pkg-install and
   SUB_LIST+= SACOMPILE="" and SACOMPILE="# " respectively.

You should have PREFIX in pkg-install available as ${PKG_PREFIX}

I don't see why it shouldn't run.

-- 
Pav Lucistnik <pav@oook.cz>
              <pav@FreeBSD.org>

Every man is as God made him, ay, and often worse.
  -- Miguel de Cervantes
Comment 6 Michael Scheidell 2007-07-20 19:14:26 UTC
/var/lib already taken care of in PR 114186, thanks Henrik Olsen
This update replaces patch sent with PR114118, and fixes the problem 
reported by pav in that sa-compile wasn't being run if binary package 
installed.

This takes the compile out of Makefile, adds it back to pkg-install 
where it needs to be, but also puts in two interactive questions,
run sa-update (with a 120 second timeout, and sets default of N if 
portupgrade --batch or make -DBATCH, or PACKAGE_BUILDING)

and sa-compile, same reasons.

Additionally, minor cleanup of pkg-plist, and one security issue: 
There is a DOS attack possible with p5-Net-DNS < .60.

also, a bugfix, despite documentation, it appears that DKIM still needs 
p5-Mail-DomainKeys, so that is put back in.

portrevision bumped due to security and domainkeys issue.


diff -bBru /var/tmp/p5-Mail-SpamAssassin/ ./
diff -bBru /var/tmp/p5-Mail-SpamAssassin/Makefile ./Makefile
--- /var/tmp/p5-Mail-SpamAssassin/Makefile      Sat Jun 16 18:17:03 2007
+++ ./Makefile  Fri Jul 20 13:56:21 2007
@@ -7,6 +7,7 @@
 
 PORTNAME=      Mail-SpamAssassin
 PORTVERSION=   3.2.1
+PORTREVISION=  1
 CATEGORIES=    mail perl5
 MASTER_SITES=  ${MASTER_SITE_APACHE:S/$/:apache/} 
${MASTER_SITE_PERL_CPAN:S/$/:cpan/}
 MASTER_SITE_SUBDIR=    spamassassin/source/:apache Mail/:cpan
@@ -16,7 +17,7 @@
 MAINTAINER=    scheidell@secnap.net
 COMMENT=       A highly efficient mail filter for identifying spam
 
-BUILD_DEPENDS= p5-Net-DNS>=0.58:${PORTSDIR}/dns/p5-Net-DNS \
+BUILD_DEPENDS= p5-Net-DNS>=0.60:${PORTSDIR}/dns/p5-Net-DNS \
                p5-IO-Zlib>=1.04:${PORTSDIR}/archivers/p5-IO-Zlib \
                p5-HTML-Parser>=3.43:${PORTSDIR}/www/p5-HTML-Parser \
                
p5-IO-Compress-Zlib>=2.04:${PORTSDIR}/archivers/p5-IO-Compress-Zlib \
@@ -61,7 +62,6 @@
 
 .if defined(WITH_SPF_QUERY)
 RUN_DEPENDS+=  p5-NetAddr-IP>=4.00.7:${PORTSDIR}/net-mgmt/p5-NetAddr-IP
-# see http://www.freebsd.org/cgi/query-pr.cgi?pr=113638
 RUN_DEPENDS+=  ${SITE_PERL}/Mail/SPF.pm:${PORTSDIR}/mail/p5-Mail-SPF
 .endif
 
@@ -97,6 +97,7 @@
 .if defined(WITH_DKIM)
 RUN_DEPENDS+=  p5-Mail-DKIM>=.20:${PORTSDIR}/mail/p5-Mail-DKIM
 RUN_DEPENDS+=  
${SITE_PERL}/IO/Socket/SSL.pm:${PORTSDIR}/security/p5-IO-Socket-SSL
+RUN_DEPENDS+=  p5-Mail-DomainKeys>=0.80:${PORTSDIR}/mail/p5-Mail-DomainKeys
 .endif
 
 .if defined(WITH_SACOMPILE)
@@ -211,6 +212,7 @@
 .endif
 .if defined(WITH_DKIM)
        ${REINPLACE_CMD} -e '/DKIM/s/^#loadplugin/loadplugin/' 
${WRKSRC}/rules/v312.pre
+       ${REINPLACE_CMD} -e '/DomainKeys/s/^#loadplugin/loadplugin/' 
${WRKSRC}/rules/v310.pre
 .endif
 .if !defined(WITH_SPF_QUERY)
        ${REINPLACE_CMD} -e '/SPF/s/^loadplugin/#loadplugin/' 
${WRKSRC}/rules/init.pre
@@ -239,7 +241,9 @@
        @${INSTALL_DATA} ${WRKSRC}/spamc/libspamc.h ${PREFIX}/include
 
 post-install:
+.if defined (WITH_SPAMC)
        @${STRIP_CMD} ${PREFIX}/bin/spamc
+.endif
        @[ -f ${PREFIX}/etc/mail/spamassassin/init.pre ] || \
                ${CP} ${PREFIX}/etc/mail/spamassassin/init.pre.sample \
                        ${PREFIX}/etc/mail/spamassassin/init.pre
@@ -252,6 +256,7 @@
        @[ -f ${PREFIX}/etc/mail/spamassassin/v320.pre ] || \
                ${CP} ${PREFIX}/etc/mail/spamassassin/v320.pre.sample \
                        ${PREFIX}/etc/mail/spamassassin/v320.pre
+       @PKG_PREFIX=${PREFIX} BATCH=${BATCH} ${SH} ${PKGDIR}/pkg-install 
${PKGNAME} POST-INSTALL
 
 .if !defined(NOPORTDOCS)
        @${MKDIR} ${DOCSDIR} ${DOCSDIR}/sql ${DOCSDIR}/ldap
diff -bBru /var/tmp/p5-Mail-SpamAssassin/pkg-install ./pkg-install
--- /var/tmp/p5-Mail-SpamAssassin/pkg-install   Sun May  8 05:40:39 2005
+++ ./pkg-install       Fri Jul 20 14:01:44 2007
@@ -1,4 +1,45 @@
 #!/bin/sh
+PKG_PREFIX=${PKG_PREFIX:=/usr/local}
+
+ask() {
+        local question default answer
+
+        question=$1
+        default=$2
+        if [ -z "${PACKAGE_BUILDING}" -a -z "${BATCH}" ]; then
+                read -t120 -p "${question} [${default}]? " answer
+        fi
+        echo ${answer:-${default}}
+}
+
+yesno() {
+        local question default answer
+
+        question=$1
+        default=$2
+        while :; do
+                answer=$(ask "${question}" "${default}")
+                case "${answer}" in
+                [Yy]*)  return 0;;
+                [Nn]*)  return 1;;
+                esac
+                echo "Please answer yes or no."
+        done
+}
+
+if [ "$2" = "POST-INSTALL" ];then
+
+   if yesno "Do you wish to run sa-update to fetch new rules" "N";then
+       ${PKG_PREFIX}/bin/sa-update
+   fi
+   grep '^load.*Rule2XSBody' 
${PKG_PREFIX}/etc/mail/spamassassin/v320.pre > /dev/null
+   if [ $? -eq 0 ];then
+     if yesno "Do you with to compile rules with re2c (will take a long 
time)" "N";then
+       ${PKG_PREFIX}/bin/sa-compile
+     fi
+   fi
+   exit 0
+fi  # post-install
 
 if [ "$2" != "PRE-INSTALL" ]; then
     exit 0
diff -bBru /var/tmp/p5-Mail-SpamAssassin/pkg-plist ./pkg-plist
--- /var/tmp/p5-Mail-SpamAssassin/pkg-plist     Fri Jul 20 13:35:39 2007
+++ ./pkg-plist Fri Jul 20 13:38:40 2007
@@ -169,8 +169,8 @@
 %%DATADIR%%/languages
 %%DATADIR%%/sa-update-pubkey.txt
 %%DATADIR%%/user_prefs.template
-@unexec rm -rf %D/libdata/spamassassin || true
-@unexec rm -rf /var/lib/spamassassin || true
+@unexec rm -rf /var/lib/spamassassin/2* || true
+@unexec rmdir /var/lib/spamassassin 2>/dev/null  || true
 @unexec rmdir /var/lib 2>/dev/null || true
 @dirrm %%DATADIR%%
 @dirrm %%SITE_PERL%%/%%PERL_ARCH%%/auto/Mail/SpamAssassin

_________________________________________________________________________
This email has been scanned and certified safe by SpammerTrap(tm). 
For Information please see http://www.spammertrap.com
_________________________________________________________________________
Comment 7 Pav Lucistnik freebsd_committer freebsd_triage 2007-07-21 09:50:36 UTC
> diff -bBru /var/tmp/p5-Mail-SpamAssassin/ ./
> diff -bBru /var/tmp/p5-Mail-SpamAssassin/Makefile ./Makefile

This patch is damaged - tabs expanded to spaces and lines wrapped.
Can you send it again, as an attachment, or upload it to a webspace?

-- 
Pav Lucistnik <pav@oook.cz>
              <pav@FreeBSD.org>

How will you recognize experienced hacker from beginner?
Beginner thinks that kilobyte have 1000 bytes.
Experienced hacker thinks one kilometer have 1024 meters.
Comment 8 Michael Scheidell 2007-07-21 17:32:26 UTC
> -----Original Message-----
> From: Pav Lucistnik [mailto:pav@FreeBSD.org]=20
> Sent: Saturday, July 21, 2007 4:51 AM
> To: Michael Scheidell
> Cc: bug-followup@FreeBSD.org
> Subject: Re: ports/114188: [maintainer-update]=20
> mail/p5-Mail-SpamAssassindeletes /var/lib even if used

> How will you recognize experienced hacker from beginner?=20
> Beginner thinks that kilobyte have 1000 bytes. Experienced=20
> hacker thinks one kilometer have 1024 meters.

Maybe we only think one kilometer have 1023 meters ;-)
My first book on c programming had a chapter 0.

Patch below, includes the tabs (I hope :-)  no long lines, I hope no
linewrap:


 diff -bBru /var/tmp/p5-Mail-SpamAssassin/ ./
diff -bBru /var/tmp/p5-Mail-SpamAssassin/Makefile ./Makefile
--- /var/tmp/p5-Mail-SpamAssassin/Makefile      Sat Jun 16 18:17:03 2007
+++ ./Makefile  Fri Jul 20 13:56:21 2007
@@ -7,6 +7,7 @@

 PORTNAME=3D      Mail-SpamAssassin
 PORTVERSION=3D   3.2.1
+PORTREVISION=3D  1
 CATEGORIES=3D    mail perl5
 MASTER_SITES=3D  ${MASTER_SITE_APACHE:S/$/:apache/}
${MASTER_SITE_PERL_CPAN:S/$/:cpan/}
 MASTER_SITE_SUBDIR=3D    spamassassin/source/:apache Mail/:cpan
@@ -16,7 +17,7 @@
 MAINTAINER=3D    scheidell@secnap.net
 COMMENT=3D       A highly efficient mail filter for identifying spam

-BUILD_DEPENDS=3D p5-Net-DNS>=3D0.58:${PORTSDIR}/dns/p5-Net-DNS \
+BUILD_DEPENDS=3D p5-Net-DNS>=3D0.60:${PORTSDIR}/dns/p5-Net-DNS \
                p5-IO-Zlib>=3D1.04:${PORTSDIR}/archivers/p5-IO-Zlib \
                p5-HTML-Parser>=3D3.43:${PORTSDIR}/www/p5-HTML-Parser \
=20
p5-IO-Compress-Zlib>=3D2.04:${PORTSDIR}/archivers/p5-IO-Compress-Zlib \
@@ -61,7 +62,6 @@

 .if defined(WITH_SPF_QUERY)
 RUN_DEPENDS+=3D  =
p5-NetAddr-IP>=3D4.00.7:${PORTSDIR}/net-mgmt/p5-NetAddr-IP
-# see http://www.freebsd.org/cgi/query-pr.cgi?pr=3D113638
 RUN_DEPENDS+=3D  ${SITE_PERL}/Mail/SPF.pm:${PORTSDIR}/mail/p5-Mail-SPF
 .endif

@@ -97,6 +97,7 @@
 .if defined(WITH_DKIM)
 RUN_DEPENDS+=3D  p5-Mail-DKIM>=3D.20:${PORTSDIR}/mail/p5-Mail-DKIM
 RUN_DEPENDS+=3D
${SITE_PERL}/IO/Socket/SSL.pm:${PORTSDIR}/security/p5-IO-Socket-SSL
+RUN_DEPENDS+=3D
p5-Mail-DomainKeys>=3D0.80:${PORTSDIR}/mail/p5-Mail-DomainKeys
 .endif

 .if defined(WITH_SACOMPILE)
@@ -211,6 +212,7 @@
 .endif
 .if defined(WITH_DKIM)
        ${REINPLACE_CMD} -e '/DKIM/s/^#loadplugin/loadplugin/'
${WRKSRC}/rules/v312.pre
+       ${REINPLACE_CMD} -e '/DomainKeys/s/^#loadplugin/loadplugin/'
${WRKSRC}/rules/v310.pre
 .endif
 .if !defined(WITH_SPF_QUERY)
        ${REINPLACE_CMD} -e '/SPF/s/^loadplugin/#loadplugin/'
${WRKSRC}/rules/init.pre
@@ -239,7 +241,9 @@
        @${INSTALL_DATA} ${WRKSRC}/spamc/libspamc.h ${PREFIX}/include

 post-install:
+.if defined (WITH_SPAMC)
        @${STRIP_CMD} ${PREFIX}/bin/spamc
+.endif
        @[ -f ${PREFIX}/etc/mail/spamassassin/init.pre ] || \
                ${CP} ${PREFIX}/etc/mail/spamassassin/init.pre.sample \
                        ${PREFIX}/etc/mail/spamassassin/init.pre
@@ -252,6 +256,7 @@
        @[ -f ${PREFIX}/etc/mail/spamassassin/v320.pre ] || \
                ${CP} ${PREFIX}/etc/mail/spamassassin/v320.pre.sample \
                        ${PREFIX}/etc/mail/spamassassin/v320.pre
+       @PKG_PREFIX=3D${PREFIX} BATCH=3D${BATCH} ${SH} =
${PKGDIR}/pkg-install
${PKGNAME} POST-INSTALL

 .if !defined(NOPORTDOCS)
        @${MKDIR} ${DOCSDIR} ${DOCSDIR}/sql ${DOCSDIR}/ldap
diff -bBru /var/tmp/p5-Mail-SpamAssassin/pkg-install ./pkg-install
--- /var/tmp/p5-Mail-SpamAssassin/pkg-install   Sun May  8 05:40:39 2005
+++ ./pkg-install       Fri Jul 20 14:01:44 2007
@@ -1,4 +1,45 @@
 #!/bin/sh
+PKG_PREFIX=3D${PKG_PREFIX:=3D/usr/local}
+
+ask() {
+        local question default answer
+
+        question=3D$1
+        default=3D$2
+        if [ -z "${PACKAGE_BUILDING}" -a -z "${BATCH}" ]; then
+                read -t120 -p "${question} [${default}]? " answer
+        fi
+        echo ${answer:-${default}}
+}
+
+yesno() {
+        local question default answer
+
+        question=3D$1
+        default=3D$2
+        while :; do
+                answer=3D$(ask "${question}" "${default}")
+                case "${answer}" in
+                [Yy]*)  return 0;;
+                [Nn]*)  return 1;;
+                esac
+                echo "Please answer yes or no."
+        done
+}
+
+if [ "$2" =3D "POST-INSTALL" ];then
+
+   if yesno "Do you wish to run sa-update to fetch new rules" "N";then
+       ${PKG_PREFIX}/bin/sa-update
+   fi
+   grep '^load.*Rule2XSBody'
${PKG_PREFIX}/etc/mail/spamassassin/v320.pre > /dev/null
+   if [ $? -eq 0 ];then
+     if yesno "Do you with to compile rules with re2c (will take a long
time)" "N";then
+       ${PKG_PREFIX}/bin/sa-compile
+     fi
+   fi
+   exit 0
+fi  # post-install

 if [ "$2" !=3D "PRE-INSTALL" ]; then
     exit 0
diff -bBru /var/tmp/p5-Mail-SpamAssassin/pkg-plist ./pkg-plist
--- /var/tmp/p5-Mail-SpamAssassin/pkg-plist     Fri Jul 20 13:35:39 2007
+++ ./pkg-plist Fri Jul 20 13:38:40 2007
@@ -169,8 +169,8 @@
 %%DATADIR%%/languages
 %%DATADIR%%/sa-update-pubkey.txt
 %%DATADIR%%/user_prefs.template
-@unexec rm -rf %D/libdata/spamassassin || true
-@unexec rm -rf /var/lib/spamassassin || true
+@unexec rm -rf /var/lib/spamassassin/2* || true
+@unexec rmdir /var/lib/spamassassin 2>/dev/null  || true
 @unexec rmdir /var/lib 2>/dev/null || true
 @dirrm %%DATADIR%%
 @dirrm %%SITE_PERL%%/%%PERL_ARCH%%/auto/Mail/SpamAssassin
_________________________________________________________________________
This email has been scanned and certified safe by SpammerTrap(tm). 
For Information please see http://www.spammertrap.com
_________________________________________________________________________
Comment 9 Pav Lucistnik freebsd_committer freebsd_triage 2007-07-21 19:41:08 UTC
> Patch below, includes the tabs (I hope :-)  no long lines, I hope no
> linewrap:

Still mangled. Please try sending it as an attachment.

-- 
Pav Lucistnik <pav@oook.cz>
              <pav@FreeBSD.org>

A)bort, R)etry, H)it with big hammer
Comment 10 Pav Lucistnik freebsd_committer freebsd_triage 2007-07-22 23:38:33 UTC
State Changed
From-To: feedback->closed

Committed, thanks!
Comment 11 dfilter service freebsd_committer freebsd_triage 2007-07-22 23:41:05 UTC
pav         2007-07-22 22:40:58 UTC

  FreeBSD ports repository

  Modified files:
    mail/p5-Mail-SpamAssassin Makefile pkg-install pkg-plist 
  Log:
  - take sa-compile out of Makefile and put into pkg-install, so it gets executed
    from pkg_add
  - add two interactive questions (with 120 seconds timeout)
  - raise minimal version of p5-Net-DNS to .60
  - despire documentation, dkim still needs p5-Mail-DomainKeys
  
  PR:             ports/114188
  Submitted by:   Michael Scheidell <scheidell@secnap.net> (maintainer)
  
  Revision  Changes    Path
  1.108     +7 -2      ports/mail/p5-Mail-SpamAssassin/Makefile
  1.3       +41 -0     ports/mail/p5-Mail-SpamAssassin/pkg-install
  1.41      +2 -2      ports/mail/p5-Mail-SpamAssassin/pkg-plist
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"