Bug 57451 - Upgrade security/clamav-devel
Summary: Upgrade security/clamav-devel
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: Dirk Meyer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-10-01 13:30 UTC by rob
Modified: 2003-10-03 14:32 UTC (History)
1 user (show)

See Also:


Attachments
clamav-devel.patch (7.45 KB, patch)
2003-10-01 13:30 UTC, rob
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description rob 2003-10-01 13:30:34 UTC
Upgrade security/clamav-devel
 -newer snapshot ;-)
 -added RC-ng scripts
 -The milter script could use some testing
Comment 1 rob 2003-10-01 13:49:32 UTC
Rob Evers wrote:
>>Number:         57451
>>Category:       ports
>>Synopsis:       Upgrade security/clamav-devel
>>Confidential:   no
>>Severity:       non-critical
>>Priority:       low
>>Responsible:    freebsd-ports-bugs
>>State:          open
>>Quarter:        
>>Keywords:       
>>Date-Required:
>>Class:          maintainer-update
>>Submitter-Id:   current-users
>>Arrival-Date:   Wed Oct 01 05:30:34 PDT 2003
>>Closed-Date:
>>Last-Modified:
>>Originator:     Rob Evers
>>Release:        FreeBSD 4.9-PRERELEASE i386
>>Organization:
>>Environment:
> 
> System: FreeBSD haha.debank.tv 4.9-PRERELEASE FreeBSD 4.9-PRERELEASE #0: Thu Sep 18 16:37:14 CEST 2003 rob@haha.debank.tv:/usr/obj/usr/src/sys/HAHA i386
> 
> 
> 	
> 
>>Description:
> 
> Upgrade security/clamav-devel
>  -newer snapshot ;-)
>  -added RC-ng scripts
>  -The milter script could use some testing
> 
>>How-To-Repeat:
>>Fix:
> 
> 
Forgot to mention the file pkg-deinstall has to be created.

Rob Evers
Comment 2 Oliver Eikemeier 2003-10-01 14:16:00 UTC
Hi Rob,

thanks a lot for the quick response. And keep up the good work.
Just a few remarks:

> +#
> +# $FreeBSD: ports/security/clamav/files/clamd.sh,v 1.1 2003/09/28 13:29:28 dinoex Exp $
> +#
=> should be $FreeBSD$

> +name=clamav_clamd

Any reason for the name change, especially since your script isn't
named clamav_clamd.sh?

> +clamav_clamd_enable=${clamav_clamd_enable:-"NO"}
> +clamav_clamd_flags=${clamav_clamd_flags:-""}
> +clamd_socket=${clamd_socket:-"%%CLAMD_SOCKET%%"}

=> clamav_clamd_socket then, but I would prefer clamd...

> +# $FreeBSD: ports/security/clamav/files/clamd.sh,v 1.1 2003/09/28 13:29:28 dinoex Exp $
see above

> +# PROVIDE: clamav-milter
you don't. you provide clamav_milter.

> +# REQUIRE: LOGIN
I don't know clamav structure, but I assume you require clamd?

> +command=%%PREFIX%%/sbin/clamd && %%PREFIX%%/sbin/clamav-milter
you are calling %%PREFIX%%/sbin/clamav-milter here, surely not
what you want. How about command=%%PREFIX%%/sbin/clamav-milter

> +pidfile=/var/run/clamav/clamd.pid
That's already the pidfile of clamd

> +	rm "$clamd_socket"
And now you kill clamds socket.

> +  rm -f $pidfile
see above

> diff -ruN clamav-devel.orig/pkg-deinstall clamav-devel/pkg-deinstall
> --- clamav-devel.orig/pkg-deinstall	Thu Jan  1 01:00:00 1970
> +++ clamav-devel/pkg-deinstall	Wed Oct  1 14:04:48 2003
> @@ -0,0 +1,4 @@
> +echo "----------------------------------------------------------"
> +echo "  If you really want to remove this package, please remove"
> +echo " the clamav-user and clean out log files "
> +echo "----------------------------------------------------------"
Great, but you should check for POST-DEINSTALL here. And you *could*
tell the users to do `pw userdel clamav', I can see no harm in that.
But is is fine as it is.

Regards, and thanks for the great work with the clamav-devel port
    Oliver
Comment 3 Dirk Meyer freebsd_committer freebsd_triage 2003-10-01 15:15:26 UTC
Responsible Changed
From-To: freebsd-ports-bugs->dinoex

I will take care of it.
Comment 4 dirk.meyer 2003-10-01 18:31:58 UTC
RC-ng scripts seems problematic:

# ps -ax | grep /usr/local/sbin/clamd
91001  ??  Ss     0:00,01 /usr/local/sbin/clamd
# sh /usr/local/etc/rc.d/clamav-clamd.sh status
clamav_clamd is not running.

after boot /var/run is empty.
the startscrip has to create this directory.

-The milter script could use some testing

sadly rcNG can't start two services ...
so we have to enable both in /etc/rc.conf

clamav_clamd_enable="YES"
clamav_milter_enable="YES"


I like to suggest this changes:

kind regards Dirk

- Dirk Meyer, Im Grund 4, 34317 Habichtswald, Germany
- [dirk.meyer@dinoex.sub.org],[dirk.meyer@guug.de],[dinoex@FreeBSD.org]

diff -ur --exclude=CVS --exclude=Makefile.local ./Makefile /usr/ports/current/clamav-devel/Makefile
--- ./Makefile	Wed Oct  1 16:08:32 2003
+++ /usr/ports/current/clamav-devel/Makefile	Wed Oct  1 19:20:27 2003
@@ -42,13 +42,17 @@
 CLAMAVUSER?=	clamav
 CLAMAVGROUP?=	clamav
 CLAMD_SOCKET?=	/var/run/clamav/clamd
+CLAMAV_MILTER_SOCKET?=	/var/run/clmilter.sock
 
 PLIST_SUB+=	CLAMAVUSER="${CLAMAVUSER}"
 PLIST_SUB+=	CLAMAVGROUP="${CLAMAVGROUP}"
 
 SED_SCRIPT=	-e 's|%%PREFIX%%|${PREFIX}|g' \
 		-e 's|%%DATADIR%%|${DATADIR}|g' \
-		-e 's|%%CLAMD_SOCKET%%|${CLAMD_SOCKET}|g'
+		-e 's|%%CLAMAVUSER%%|${CLAMAVUSER}|g' \
+		-e 's|%%CLAMAVGROUP%%|${CLAMAVGROUP}|g' \
+		-e 's|%%CLAMD_SOCKET%%|${CLAMD_SOCKET}|g' \
+		-e 's|%%CLAMAV_MILTER_SOCKET%%|${CLAMAV_MILTER_SOCKET}|g'
 
 SED_CONF=	-E -e 's|^\#?(Example)$$|\#\1|' \
 		-e 's|^\#?(LogFile) .*$$|\1 /var/log/clamav/clamd.log|' \
diff -ur --exclude=CVS --exclude=Makefile.local ./files/clamav-clamd.sh /usr/ports/current/clamav-devel/files/clamav-clamd.sh
--- ./files/clamav-clamd.sh	Wed Oct  1 16:08:42 2003
+++ /usr/ports/current/clamav-devel/files/clamav-clamd.sh	Wed Oct  1 19:17:33 2003
@@ -30,9 +30,13 @@
 
 start_precmd()
 {
+	if [ ! -d /var/run/clamav ]; then
+		mkdir -p /var/run/clamav
+		chown %%CLAMAVUSER%%:%%CLAMAVGROUP%% /var/run/clamav
+	fi
 	if [ -S "$clamd_socket" ]; then
-	warn "Stale socket $clamd_socket removed."
-	rm "$clamd_socket"
+		warn "Stale socket $clamd_socket removed."
+		rm "$clamd_socket"
 	fi
 }
 
diff -ur --exclude=CVS --exclude=Makefile.local ./files/clamav-milter.sh /usr/ports/current/clamav-devel/files/clamav-milter.sh
--- ./files/clamav-milter.sh	Wed Oct  1 16:08:47 2003
+++ /usr/ports/current/clamav-devel/files/clamav-milter.sh	Wed Oct  1 19:24:20 2003
@@ -21,8 +21,7 @@
 name=clamav_milter
 rcvar=`set_rcvar`
 
-command=%%PREFIX%%/sbin/clamd && %%PREFIX%%/sbin/clamav-milter
-pidfile=/var/run/clamav/clamd.pid
+command=%%PREFIX%%/sbin/clamav-milter
 required_dirs=%%DATADIR%%
 required_files=%%PREFIX%%/etc/clamav.conf
 
@@ -30,24 +29,17 @@
 
 start_precmd()
 {
-	if [ -S "$clamd_socket" ]; then
-	warn "Stale socket $clamd_socket removed."
-	rm "$clamd_socket"
+	if [ -S "$clamav_milter_socket" ]; then
+		warn "Stale socket $clamav_milter_socket removed."
+		rm "$clamav_milter_socket"
 	fi
 }
 
-stop_postcmd=stop_postcmd
-
-stop_postcmd()
-{
-  rm -f $pidfile
-}
-
 # set defaults
 
-clamav_milter=${clamav_milter_enable:-"NO"}
-clamav_milter=${clamav_milter_flags:-""}
-clamd_socket=${clamd_socket:-"%%CLAMD_SOCKET%%"}
+clamav_milter_enable=${clamav_milter_enable:-"NO"}
+clamav_milter_socket=${clamav_milter_socket:-"%%CLAMAV_MILTER_SOCKET%%"}
+clamav_milter_flags=${clamav_milter_flags:-"--postmaster-only --local --outgoing --max-children=50 ${clamav_milter_socket}"}
 
 load_rc_config $name
 run_rc_command "$1"
Comment 5 Oliver Eikemeier 2003-10-02 02:50:00 UTC
Dirk Meyer wrote:

> RC-ng scripts seems problematic:
> 
> # ps -ax | grep /usr/local/sbin/clamd
> 91001  ??  Ss     0:00,01 /usr/local/sbin/clamd
> # sh /usr/local/etc/rc.d/clamav-clamd.sh status
> clamav_clamd is not running.

See my comments above:

>> +	rm "$clamd_socket"
> And now you kill clamds socket.

>> +  rm -f $pidfile
> see above

its clamav-milter.sh killing the clamd socket and pid.

> after boot /var/run is empty.
> the startscrip has to create this directory.

Nope, it requires this directory to exist, it is clearly
an error if it doesn't. Add it to required_dirs if this
is a problem.

>  start_precmd()
>  {
> +	if [ ! -d /var/run/clamav ]; then
> +		mkdir -p /var/run/clamav
> +		chown %%CLAMAVUSER%%:%%CLAMAVGROUP%% /var/run/clamav
> +	fi

This directory should be created during installation and removed
during deinstallation. It shouldn't 'vanish' while the port is
installed. Otherwise you have to investigate why.
Comment 6 dirk.meyer 2003-10-02 04:49:33 UTC
> Oliver Eikemeier wrote:
>  See my comments above:
[...]
>  > see above

already taken care off ...

>  > after boot /var/run is empty.
>  > the startscrip has to create this directory.
>  [...]
>  This directory should be created during installation and removed
>  during deinstallation. It shouldn't 'vanish' while the port is
>  installed. Otherwise you have to investigate why.

/etc/rc deletes all files in /var/run, but keep dirs.
pkg-plist did not create it when extracting a package.

more cavetas:
[...]
===> Adding user "clamav" if necessary.
===> Setting permissions...
===> Adding user "clamav" if necessary.
===> Setting permissions...
===> Adding user "clamav" if necessary.
[...]
===>   Deinstalling clamav-devel-20031001
----------------------------------------------------------
  If you really want to remove this package, please remove
 the clamav-user and clean out log files 
----------------------------------------------------------
----------------------------------------------------------
  If you really want to remove this package, please remove
 the clamav-user and clean out log files 
----------------------------------------------------------

See revised patch ...

kind regards Dirk

- Dirk Meyer, Im Grund 4, 34317 Habichtswald, Germany
- [dirk.meyer@dinoex.sub.org],[dirk.meyer@guug.de],[dinoex@FreeBSD.org]

diff -ur --exclude=CVS --exclude=Makefile.local ./Makefile /usr/ports/current/clamav-devel/Makefile
--- ./Makefile	Wed Oct  1 16:08:32 2003
+++ /usr/ports/current/clamav-devel/Makefile	Thu Oct  2 05:44:43 2003
@@ -42,13 +42,17 @@
 CLAMAVUSER?=	clamav
 CLAMAVGROUP?=	clamav
 CLAMD_SOCKET?=	/var/run/clamav/clamd
+CLAMAV_MILTER_SOCKET?=	/var/run/clmilter.sock
 
 PLIST_SUB+=	CLAMAVUSER="${CLAMAVUSER}"
 PLIST_SUB+=	CLAMAVGROUP="${CLAMAVGROUP}"
 
 SED_SCRIPT=	-e 's|%%PREFIX%%|${PREFIX}|g' \
 		-e 's|%%DATADIR%%|${DATADIR}|g' \
-		-e 's|%%CLAMD_SOCKET%%|${CLAMD_SOCKET}|g'
+		-e 's|%%CLAMAVUSER%%|${CLAMAVUSER}|g' \
+		-e 's|%%CLAMAVGROUP%%|${CLAMAVGROUP}|g' \
+		-e 's|%%CLAMD_SOCKET%%|${CLAMD_SOCKET}|g' \
+		-e 's|%%CLAMAV_MILTER_SOCKET%%|${CLAMAV_MILTER_SOCKET}|g'
 
 SED_CONF=	-E -e 's|^\#?(Example)$$|\#\1|' \
 		-e 's|^\#?(LogFile) .*$$|\1 /var/log/clamav/clamd.log|' \
@@ -101,7 +105,7 @@
 
 pre-install:
 	 ${SETENV} PKG_PREFIX=${PREFIX} \
-		${SH} ${PKGINSTALL} ${PREFIX}
+		${SH} ${PKGINSTALL} ${PREFIX} PRE-INSTALL
 
 post-install:
 	@[ -f ${PREFIX}/etc/clamav.conf ] || \
diff -ur --exclude=CVS --exclude=Makefile.local ./files/clamav-clamd.sh /usr/ports/current/clamav-devel/files/clamav-clamd.sh
--- ./files/clamav-clamd.sh	Wed Oct  1 16:08:42 2003
+++ /usr/ports/current/clamav-devel/files/clamav-clamd.sh	Thu Oct  2 05:05:19 2003
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $FreeBSD: ports/security/clamav/files/clamd.sh,v 1.1 2003/09/28 13:29:28 dinoex Exp $
+# $FreeBSD$
 #
 
 # PROVIDE: clamd
@@ -31,8 +31,8 @@
 start_precmd()
 {
 	if [ -S "$clamd_socket" ]; then
-	warn "Stale socket $clamd_socket removed."
-	rm "$clamd_socket"
+		warn "Stale socket $clamd_socket removed."
+		rm "$clamd_socket"
 	fi
 }
 
diff -ur --exclude=CVS --exclude=Makefile.local ./files/clamav-milter.sh /usr/ports/current/clamav-devel/files/clamav-milter.sh
--- ./files/clamav-milter.sh	Wed Oct  1 16:08:47 2003
+++ /usr/ports/current/clamav-devel/files/clamav-milter.sh	Thu Oct  2 05:06:03 2003
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $FreeBSD: ports/security/clamav/files/clamd.sh,v 1.1 2003/09/28 13:29:28 dinoex Exp $
+# $FreeBSD$
 #
 
 # PROVIDE: clamav-milter
@@ -21,8 +21,7 @@
 name=clamav_milter
 rcvar=`set_rcvar`
 
-command=%%PREFIX%%/sbin/clamd && %%PREFIX%%/sbin/clamav-milter
-pidfile=/var/run/clamav/clamd.pid
+command=%%PREFIX%%/sbin/clamav-milter
 required_dirs=%%DATADIR%%
 required_files=%%PREFIX%%/etc/clamav.conf
 
@@ -30,24 +29,17 @@
 
 start_precmd()
 {
-	if [ -S "$clamd_socket" ]; then
-	warn "Stale socket $clamd_socket removed."
-	rm "$clamd_socket"
+	if [ -S "$clamav_milter_socket" ]; then
+		warn "Stale socket $clamav_milter_socket removed."
+		rm "$clamav_milter_socket"
 	fi
 }
 
-stop_postcmd=stop_postcmd
-
-stop_postcmd()
-{
-  rm -f $pidfile
-}
-
 # set defaults
 
-clamav_milter=${clamav_milter_enable:-"NO"}
-clamav_milter=${clamav_milter_flags:-""}
-clamd_socket=${clamd_socket:-"%%CLAMD_SOCKET%%"}
+clamav_milter_enable=${clamav_milter_enable:-"NO"}
+clamav_milter_socket=${clamav_milter_socket:-"%%CLAMAV_MILTER_SOCKET%%"}
+clamav_milter_flags=${clamav_milter_flags:-"--postmaster-only --local --outgoing --max-children=50 ${clamav_milter_socket}"}
 
 load_rc_config $name
 run_rc_command "$1"
diff -ur --exclude=CVS --exclude=Makefile.local ./pkg-deinstall /usr/ports/current/clamav-devel/pkg-deinstall
--- ./pkg-deinstall	Wed Oct  1 16:08:47 2003
+++ /usr/ports/current/clamav-devel/pkg-deinstall	Thu Oct  2 05:48:36 2003
@@ -1,3 +1,6 @@
+if [ ! "$2" = "POST-DEINSTALL" ]; then
+	exit 0
+fi
 echo "----------------------------------------------------------"
 echo "  If you really want to remove this package, please remove"
 echo " the clamav-user and clean out log files "
diff -ur --exclude=CVS --exclude=Makefile.local ./pkg-install /usr/ports/current/clamav-devel/pkg-install
--- ./pkg-install	Tue Sep 30 05:04:25 2003
+++ /usr/ports/current/clamav-devel/pkg-install	Thu Oct  2 05:44:33 2003
@@ -1,5 +1,9 @@
 #!/bin/sh
 
+if [ ! "$2" = "PRE-INSTALL" ]; then
+	exit 0
+fi
+
 if [ -z "${CLAMAVUSER}" ]; then
 	CLAMAVUSER=clamav
 fi
diff -ur --exclude=CVS --exclude=Makefile.local ./pkg-plist /usr/ports/current/clamav-devel/pkg-plist
--- ./pkg-plist	Wed Oct  1 16:08:47 2003
+++ /usr/ports/current/clamav-devel/pkg-plist	Thu Oct  2 05:37:43 2003
@@ -1,4 +1,3 @@
-@exec mkdir -p share/clamav
 bin/clamscan
 bin/clamdscan
 bin/freshclam
@@ -17,7 +16,7 @@
 @owner %%CLAMAVUSER%%
 @group %%CLAMAVGROUP%%
 %%DATADIR%%/mirrors.txt
-@exec chown %%CLAMAVUSER%%:%%CLAMAVGROUP%% %B
+@exec chown -R %%CLAMAVUSER%%:%%CLAMAVGROUP%% %B
 @dirrm %%DATADIR%%
-@unexec rmdir /var/run/clamav 2>/dev/null || true
-@unexec rmdir /var/log/clamav 2>/dev/null || true
+@unexec rmdir /var/run/clamav
+@unexec rmdir /var/log/clamav
Only in /usr/ports/current/clamav-devel: todo
Comment 7 Oliver Eikemeier 2003-10-02 16:01:46 UTC
>>  > after boot /var/run is empty.
>>  > the startscrip has to create this directory.
>>  [...]
>>  This directory should be created during installation and removed
>>  during deinstallation. It shouldn't 'vanish' while the port is
>>  installed. Otherwise you have to investigate why.
> 
> /etc/rc deletes all files in /var/run, but keep dirs.
> pkg-plist did not create it when extracting a package.

it should happen in pkg-install:

> CLAMRUN=/var/run/clamav
> [...]
> mkdir -p "${CLAMRUN}"
> chown "${CLAMAVUSER}:${CLAMAVGROUP}" "${CLAMRUN}"

Didn't that work?

>  @owner %%CLAMAVUSER%%
>  @group %%CLAMAVGROUP%%
>  %%DATADIR%%/mirrors.txt
> -@exec chown %%CLAMAVUSER%%:%%CLAMAVGROUP%% %B
> +@exec chown -R %%CLAMAVUSER%%:%%CLAMAVGROUP%% %B

the @owner and @group are supposed to take care of that.
Are any permissions wrong?

>  @dirrm %%DATADIR%%
> -@unexec rmdir /var/run/clamav 2>/dev/null || true
> -@unexec rmdir /var/log/clamav 2>/dev/null || true
> +@unexec rmdir /var/run/clamav
> +@unexec rmdir /var/log/clamav

either you do a @dirrm and accept that if fails on
/var/log/clamav, or you should keep the 2>...

ask portlint ;-)

> Only in /usr/ports/current/clamav-devel: todo
Hey, post it. We want to know :->

I must admit: I'm starting to get confused by all these
patches flying around. Is it now:

  CLAMD_SOCKET
  CLAMAV_MILTER_SOCKET
  rc.d/clamd.sh
  clamd_enable
  clamd_socket
  rc.d/clamav-milter.sh
  clamav_milter_socket
  clamav_milter_enable

or

  CLAMAV_CLAMD_SOCKET
  CLAMAV_MILTER_SOCKET
  rc.d/calmav-clamd.sh
  calmav_clamd_enable
  calmav_clamd_socket
  rc.d/clamav-milter.sh
  clamav_milter_socket
  clamav_milter_enable

or a mixture?

Btw, would be nice to run clamav-milter with
$clamav_milter_user="clamav" and /var/run/clamav/clmilter.sock,
but I don't use sendmail, so I can't test it.

You do a great job Dirk, thank you for your efforts
    Oliver
Comment 8 dirk.meyer 2003-10-02 19:19:02 UTC
This is the full patch against the last commite revision:
Any objections?

kind regards Dirk

- Dirk Meyer, Im Grund 4, 34317 Habichtswald, Germany
- [dirk.meyer@dinoex.sub.org],[dirk.meyer@guug.de],[dinoex@FreeBSD.org]

Index: Makefile
===================================================================
RCS file: /home/pcvs/ports/security/clamav-devel/Makefile,v
retrieving revision 1.21
diff -u -r1.21 Makefile
--- Makefile	30 Sep 2003 18:21:48 -0000	1.21
+++ Makefile	2 Oct 2003 18:17:40 -0000
@@ -6,7 +6,7 @@
 #
 
 PORTNAME=	clamav
-PORTVERSION=	20030930
+PORTVERSION=	20031001
 CATEGORIES=	security
 MASTER_SITES=	http://clamav.sourceforge.net/snapshot/
 PKGNAMESUFFIX=	-devel
@@ -41,12 +41,18 @@
 
 CLAMAVUSER?=	clamav
 CLAMAVGROUP?=	clamav
+CLAMD_SOCKET?=	/var/run/clamav/clamd
+CLAMAV_MILTER_SOCKET?=	/var/run/clmilter.sock
 
 PLIST_SUB+=	CLAMAVUSER="${CLAMAVUSER}"
 PLIST_SUB+=	CLAMAVGROUP="${CLAMAVGROUP}"
 
 SED_SCRIPT=	-e 's|%%PREFIX%%|${PREFIX}|g' \
-		-e 's|%%DATADIR%%|${DATADIR}|g'
+		-e 's|%%DATADIR%%|${DATADIR}|g' \
+		-e 's|%%CLAMAVUSER%%|${CLAMAVUSER}|g' \
+		-e 's|%%CLAMAVGROUP%%|${CLAMAVGROUP}|g' \
+		-e 's|%%CLAMD_SOCKET%%|${CLAMD_SOCKET}|g' \
+		-e 's|%%CLAMAV_MILTER_SOCKET%%|${CLAMAV_MILTER_SOCKET}|g'
 
 SED_CONF=	-E -e 's|^\#?(Example)$$|\#\1|' \
 		-e 's|^\#?(LogFile) .*$$|\1 /var/log/clamav/clamd.log|' \
@@ -57,6 +63,15 @@
 
 .include <bsd.port.pre.mk>
 
+USE_RC_SUBR=	yes
+RC_DIR=		${PREFIX}/etc/rc.d
+RC_SUFX=	.sh
+SED_SCRIPT+=	-e 's|%%RC_SUBR%%|${RC_SUBR}|g' \
+		-e 's|%%RC_DIR%%|${RC_DIR}|g' \
+		-e 's|%%RC_SUFX%%|${RC_SUFX}|g'
+PLIST_SUB+=	RC_DIR=${RC_DIR} \
+		RC_SUFX=${RC_SUFX}
+
 .if ${OSVERSION} < 501001
 # compiles only with optimizer
 CFLAGS+=	-O
@@ -70,12 +85,6 @@
 PLIST_SUB+=	CLAMAV-MILTER:="@comment "
 .endif
 
-post-extract:
-	@${SED} ${SED_SCRIPT} ${FILESDIR}/clamav-milter.sh \
-		> ${WRKSRC}/clamav-milter.sh
-	@${SED} ${SED_SCRIPT} ${FILESDIR}/clamav-clamd.sh \
-		> ${WRKSRC}/clamav-clamd.sh
-
 post-patch:
 	@${REINPLACE_CMD} -e 's|-pthread|${PTHREAD_LIBS}|g' ${WRKSRC}/configure
 	@${REINPLACE_CMD} -e 's|/usr/lib/sendmail|/usr/sbin/sendmail|g' \
@@ -88,21 +97,26 @@
 
 post-build:
 	@${SED} ${SED_CONF} ${BUILD_WRKSRC}/etc/clamav.conf \
-		>${BUILD_WRKSRC}/etc/clamav.conf.default
+		> ${BUILD_WRKSRC}/etc/clamav.conf.default
+	@${SED} ${SED_SCRIPT} ${FILESDIR}/clamav-clamd.sh \
+		> ${WRKDIR}/clamav-clamd.sh
+	@${SED} ${SED_SCRIPT} ${FILESDIR}/clamav-milter.sh \
+		> ${WRKDIR}/clamav-milter.sh
 
 pre-install:
 	 ${SETENV} PKG_PREFIX=${PREFIX} \
-		${SH} ${PKGINSTALL} ${PREFIX}
+		${SH} ${PKGINSTALL} ${PREFIX} PRE-INSTALL
 
 post-install:
 	@[ -f ${PREFIX}/etc/clamav.conf ] || \
-		${CP} ${PREFIX}/etc/clamav.conf.default ${PREFIX}/etc/clamav.conf
+		${CP} ${PREFIX}/etc/clamav.conf.default \
+			${PREFIX}/etc/clamav.conf
 	@${CHOWN} -R ${CLAMAVUSER}:${CLAMAVGROUP} ${DATADIR}
-	${INSTALL_SCRIPT} ${WRKSRC}/clamav-clamd.sh \
-		${LOCALBASE}/etc/rc.d/clamav-clamd.sh.sample
+	@${INSTALL_SCRIPT} ${WRKDIR}/clamav-clamd.sh \
+		${RC_DIR}/clamav-clamd${RC_SUFX}
 .if defined(WITH_MILTER)
-	${INSTALL_SCRIPT} ${WRKSRC}/clamav-milter.sh \
-		${LOCALBASE}/etc/rc.d/clamav-milter.sh.sample
+	@${INSTALL_SCRIPT} ${WRKDIR}/clamav-milter.sh \
+		${RC_DIR}/clamav-milter${RC_SUFX}
 .endif
 
 .include <bsd.port.post.mk>
Index: distinfo
===================================================================
RCS file: /home/pcvs/ports/security/clamav-devel/distinfo,v
retrieving revision 1.12
diff -u -r1.12 distinfo
--- distinfo	30 Sep 2003 18:21:48 -0000	1.12
+++ distinfo	2 Oct 2003 18:17:40 -0000
@@ -1 +1 @@
-MD5 (clamav-devel-20030930.tar.gz) = 7c15623dc0750f64431ee692a0046d6e
+MD5 (clamav-devel-20031001.tar.gz) = cb4e13698fbe2d68b7c5e5f624e66737
Index: pkg-deinstall
===================================================================
RCS file: pkg-deinstall
diff -N pkg-deinstall
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ pkg-deinstall	2 Oct 2003 18:17:40 -0000
@@ -0,0 +1,7 @@
+if [ ! "$2" = "POST-DEINSTALL" ]; then
+	exit 0
+fi
+echo "----------------------------------------------------------"
+echo "  If you really want to remove this package, please remove"
+echo " the clamav-user and clean out log files "
+echo "----------------------------------------------------------"
Index: pkg-install
===================================================================
RCS file: /home/pcvs/ports/security/clamav-devel/pkg-install,v
retrieving revision 1.6
diff -u -r1.6 pkg-install
--- pkg-install	30 Sep 2003 03:39:11 -0000	1.6
+++ pkg-install	2 Oct 2003 18:17:40 -0000
@@ -1,5 +1,9 @@
 #!/bin/sh
 
+if [ ! "$2" = "PRE-INSTALL" ]; then
+	exit 0
+fi
+
 if [ -z "${CLAMAVUSER}" ]; then
 	CLAMAVUSER=clamav
 fi
Index: pkg-plist
===================================================================
RCS file: /home/pcvs/ports/security/clamav-devel/pkg-plist,v
retrieving revision 1.11
diff -u -r1.11 pkg-plist
--- pkg-plist	30 Sep 2003 03:39:11 -0000	1.11
+++ pkg-plist	2 Oct 2003 18:17:40 -0000
@@ -1,10 +1,9 @@
-@exec mkdir -p share/clamav
 bin/clamscan
 bin/clamdscan
 bin/freshclam
 bin/sigtool
-etc/rc.d/clamav-clamd.sh.sample
-%%CLAMAV-MILTER:%%etc/rc.d/clamav-milter.sh.sample
+etc/rc.d/clamav-clamd%%RC_SUFX%%
+%%CLAMAV-MILTER:%%etc/rc.d/clamav-milter%%RC_SUFX%%
 %%CLAMAV-MILTER:%%sbin/clamav-milter
 sbin/clamd
 include/clamav.h
@@ -21,10 +20,3 @@
 @dirrm %%DATADIR%%
 @unexec rmdir /var/run/clamav 2>/dev/null || true
 @unexec rmdir /var/log/clamav 2>/dev/null || true
-@unexec echo ""
-@unexec echo "========================================================="
-@unexec echo " If you want to deinstall this package permanently then"
-@unexec echo "               \"rmuser -y %%CLAMAVUSER%%\" "
-@unexec echo " This will remove clamav's spool-directory and user "
-@unexec echo "========================================================="
-@unexec echo ""
Index: files/clamav-clamd.sh
===================================================================
RCS file: /home/pcvs/ports/security/clamav-devel/files/clamav-clamd.sh,v
retrieving revision 1.1
diff -u -r1.1 clamav-clamd.sh
--- files/clamav-clamd.sh	26 Sep 2003 12:19:55 -0000	1.1
+++ files/clamav-clamd.sh	2 Oct 2003 18:17:40 -0000
@@ -1,18 +1,53 @@
 #!/bin/sh
-PREFIX=%%PREFIX%%
+#
+# $FreeBSD$
+#
 
-case "$1" in
-start)
-	# remove old socket
-	rm -f /tmp/clamd
-	[ -x ${PREFIX}/sbin/clamd ] && ${PREFIX}/sbin/clamd > /dev/null && echo -n ' clamd'
-	;;
-stop)
-	killall 'clamd' && echo -n ' clamd'
-	;;
-*)
-	echo "Usage: ${0##*/} { start | stop }" >&2
-	;;
-esac
+# PROVIDE: clamd
+# REQUIRE: LOGIN
+# BEFORE: mail
+# KEYWORD: FreeBSD shutdown
 
-exit 0
+#
+# Add the following lines to /etc/rc.conf to enable clamd:
+#
+#clamav_clamd_enable="YES"
+#
+# See clamd(8) for flags
+#
+
+. %%RC_SUBR%%
+
+name=clamav_clamd
+rcvar=`set_rcvar`
+
+command=%%PREFIX%%/sbin/clamd
+pidfile=/var/run/clamav/clamd.pid
+required_dirs=%%DATADIR%%
+required_files=%%PREFIX%%/etc/clamav.conf
+
+start_precmd=start_precmd
+
+start_precmd()
+{
+	if [ -S "$clamd_socket" ]; then
+		warn "Stale socket $clamd_socket removed."
+		rm "$clamd_socket"
+	fi
+}
+
+stop_postcmd=stop_postcmd
+
+stop_postcmd()
+{
+  rm -f $pidfile
+}
+
+# set defaults
+
+clamav_clamd_enable=${clamav_clamd_enable:-"NO"}
+clamav_clamd_flags=${clamav_clamd_flags:-""}
+clamd_socket=${clamd_socket:-"%%CLAMD_SOCKET%%"}
+
+load_rc_config $name
+run_rc_command "$1"
Index: files/clamav-milter.sh
===================================================================
RCS file: /home/pcvs/ports/security/clamav-devel/files/clamav-milter.sh,v
retrieving revision 1.1
diff -u -r1.1 clamav-milter.sh
--- files/clamav-milter.sh	26 Sep 2003 12:19:55 -0000	1.1
+++ files/clamav-milter.sh	2 Oct 2003 18:17:40 -0000
@@ -1,28 +1,48 @@
 #!/bin/sh
 #
-#	runs clamd and clamav-milter
+# $FreeBSD$
 #
 
-case "$1" in
-'start')
-	rm -f /tmp/clamd /var/run/clmilter.sock
-	%%PREFIX%%/sbin/clamd && echo -n " clamd"
-	%%PREFIX%%/sbin/clamav-milter \
-		--local \
-		--outgoing \
-		--max-children=50 \
-		/var/run/clmilter.sock &
-	echo -n " clamav-milter"
-	;;
-'stop')
-	killall 'clamav-milter'
-	echo -n " clamav-milter"
-	killall 'clamd'
-	echo -n " clamad"
-	;;
-*)
-	echo "Usage: ${0##*/} { start | stop }"
-	;;
-esac
+# PROVIDE: clamav-milter
+# REQUIRE: LOGIN
+# BEFORE: mail
+# KEYWORD: FreeBSD shutdown
 
-exit 0
+#
+# Add the following lines to /etc/rc.conf to enable clamd:
+#
+#clamav_milter="YES"
+#
+# See clamav-milter(1) for flags
+#
+
+. %%RC_SUBR%%
+
+name=clamav_milter
+rcvar=`set_rcvar`
+
+command=%%PREFIX%%/sbin/clamav-milter
+required_dirs=%%DATADIR%%
+required_files=%%PREFIX%%/etc/clamav.conf
+
+start_precmd=start_precmd
+
+start_precmd()
+{
+	if [ -S "$clamav_milter_socket" ]; then
+		warn "Stale socket $clamav_milter_socket removed."
+		rm "$clamav_milter_socket"
+	fi
+}
+
+# set defaults
+
+clamav_milter_enable=${clamav_milter_enable:-"NO"}
+clamav_milter_socket=${clamav_milter_socket:-"%%CLAMAV_MILTER_SOCKET%%"}
+clamav_milter_flags=${clamav_milter_flags:-"--postmaster-only --local --outgoing --max-children=50"}
+
+load_rc_config $name
+
+# add socket to any given argument
+clamav_milter_flags="${clamav_milter_flags} ${clamav_milter_socket}"
+run_rc_command "$1"
Comment 9 rob 2003-10-03 10:10:14 UTC
Dirk Meyer wrote:
> This is the full patch against the last commite revision:
> Any objections?
> 
> kind regards Dirk
> 
> - Dirk Meyer, Im Grund 4, 34317 Habichtswald, Germany
> - [dirk.meyer@dinoex.sub.org],[dirk.meyer@guug.de],[dinoex@FreeBSD.org]
> 

Hi Dirk,

Sorry to have taken so long, I looked at the patch and, the only thing 
I think we have to change is the naming of the clamd socket. In the 
attached patch I changed CLAMD_SOCKET to CLAMAV_CLAMD_SOCKET, so 
naming is (I think) more consistent.
Thank you Dirk and Olivier for the fixes.

Rob Evers
Comment 10 Dirk Meyer freebsd_committer freebsd_triage 2003-10-03 14:32:24 UTC
State Changed
From-To: open->closed

committed, thanks.