FreeBSD Port: p3scan-2.3.2_2
Andrew Karev
a-karev at mail.ru
Thu Apr 5 13:24:25 UTC 2007
Dear maintainer!
Is it possible to apply changes from the attached file?
Change list:
1. Allows to compile at RELENG_4 (added conditional dependency to
devel/libgnugetopt). Yes, I know, that support for this branch is
ceased, but corrections are trivial, so why not?
2. Allows to specify group and user as make variables: does not need to
chown every time package version updated
3. Rewritten p3scan.sh: 'start_cmd' replaced with 'command' and
'p3scan_flags' variables
4. Enhanced %%P3SCANID%% parameter in p3scan.c: added
config->virusdatabase path to filename
5. Notify directory changed to /var/spool/p3scan/notify as default in
p3scan.conf
Regards,
Andrew
-------------- next part --------------
diff -ur p3scan/Makefile p3scan-2.3.2_2/Makefile
--- p3scan/Makefile Mon Nov 20 01:32:57 2006
+++ p3scan-2.3.2_2/Makefile Thu Apr 5 16:01:21 2007
@@ -36,10 +36,14 @@
USE_RC_SUBR= p3scan.sh
SUB_FILES= p3scan.sh pkg-message
+USER?=mailnull
+GROUP?=mail
+
.include <bsd.port.pre.mk>
.if ${OSVERSION} < 500000
-IGNORE= is not supported on 4.x
+LIB_DEPENDS+= gnugetopt.1:${PORTSDIR}/devel/libgnugetopt
+LDFLAGS+= -lgnugetopt
.endif
.if !defined(WITHOUT_UVSCAN)
diff -ur p3scan/files/p3scan.sh.in p3scan-2.3.2_2/files/p3scan.sh.in
--- p3scan/files/p3scan.sh.in Wed Nov 1 04:36:24 2006
+++ p3scan-2.3.2_2/files/p3scan.sh.in Thu Apr 5 16:10:31 2007
@@ -17,21 +17,15 @@
name=p3scan
rcvar=`set_rcvar`
-required_files=%%PREFIX%%/etc/p3scan/p3scan.conf
-
# set defaults
+command=%%PREFIX%%/sbin/${name}
p3scan_enable=${p3scan_enable:-"NO"}
-p3scan_config=${p3scan_config:-"%%PREFIX%%/local/etc/p3scan/p3scan.conf"}
-
-load_rc_config $name
-run_rc_command "$1"
+p3scan_config=${p3scan_config:-"%%PREFIX%%/etc/p3scan/p3scan.conf"}
-start_cmd="p3scan_start"
+required_files=${p3scan_config}
-p3scan_start()
-{
- %%PREFIX%%/sbin/p3scan -f ${p3scan_config}
-}
+p3scan_flags="-f ${p3scan_config} ${p3scan_flags}"
+load_rc_config $name
run_rc_command "$1"
diff -ur p3scan/files/patch-p3scan.c p3scan-2.3.2_2/files/patch-p3scan.c
--- p3scan/files/patch-p3scan.c Wed Nov 1 04:36:24 2006
+++ p3scan-2.3.2_2/files/patch-p3scan.c Thu Apr 5 15:54:03 2007
@@ -1,6 +1,6 @@
---- p3scan.c.orig Tue Dec 13 02:00:00 2005
-+++ p3scan.c Wed Nov 1 11:44:03 2006
-@@ -41,36 +41,37 @@
+--- p3scan.c.orig Mon Dec 12 18:00:00 2005
++++ p3scan.c Thu Apr 5 15:09:02 2007
+@@ -41,36 +41,39 @@
TODO: Wanted: white-list support
TODO: Wanted: no iptables support
*/
@@ -18,7 +18,9 @@
+#include <sys/param.h>
+#include <sys/signal.h>
#include <sys/stat.h>
++#if __FreeBSD_version >= 500000
+#include <sys/statvfs.h>
++#endif
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
@@ -52,7 +54,7 @@
#include "p3scan.h"
#include "getline_ssl.h"
-@@ -182,8 +183,8 @@
+@@ -182,8 +185,8 @@
do_log(LOG_NOTICE, "ERR: Exiting now...\n");
fprintf(stderr, "%s\n", puffer);
if (strlen(NONULL(config->emergency))){
@@ -63,7 +65,65 @@
if (system(puffer)) fprintf(stderr,"ERR: Calling do_log!");
}
/* Tell main p3scan to abort */
-@@ -1640,8 +1641,9 @@
+@@ -366,7 +369,7 @@
+ XXXXXX[4] = letters[v % 62];
+ v /= 62;
+ XXXXXX[5] = letters[v % 62];
+- fd=open(template, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR | O_SYNC, 0600);
++ fd=open(template, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR | O_FSYNC, 0600);
+ if (fd >= 0){
+ errno = save_errno;
+ return fd;
+@@ -699,7 +702,11 @@
+ #define COPYMSG "/var/spool/p3scan/copymsg "
+ FILE * scanner;
+ static char line[4096*16];
++#if __FreeBSD_version >= 500000
+ struct statvfs fs;
++#else
++ struct statfs fs;
++#endif
+ int htmlfd=0;
+
+ ret=checktimeout(p);
+@@ -716,11 +723,16 @@
+ return SCANNER_RET_ERR;
+ }
+ }
++
+ /* See if we have enough room to process the message based upon
+ what the user determines is enough room in p3scan.conf
+ This was already done... but it is also dynamic so check again.
+ */
++#if __FreeBSD_version >= 500000
+ if ( statvfs( config->virusdir, &fs ) == SCANNER_RET_ERR){
++#else
++ if ( statfs( config->virusdir, &fs ) == SCANNER_RET_ERR){
++#endif
+ p->errmsg=1;
+ context_uninit(p);
+ config->emergency="Unable to get available space!";
+@@ -1280,6 +1292,7 @@
+ char *mail=NULL, *mailx=NULL;
+ char svrout[1];
+ char comm[4096];
++ char scanid[4096];
+ unsigned long len;
+ int readerr=0, bufferr=0, subjfd=-1, extrafd=-1;
+ int ret;
+@@ -1363,6 +1376,11 @@
+ snprintf(comm,4096,"%s %s/p3scan.*",CHMODCMD,config->virusdirbase);
+ do_log(LOG_DEBUG,"Forcing all files 0600 %s",comm);
+ if(system(comm)) do_log(LOG_CRIT,"ERR: chmod");
++
++ if (paramlist_get(p->params, "%P3SCANID%")){
++ snprintf(scanid,4096,"%s%s",config->virusdirbase, paramlist_get(p->params, "%P3SCANID%"));
++ paramlist_set(p->params, "%P3SCANID%", scanid);
++ }
+ }
+ sprintf(mail, "%s/%i.mailout", config->notifydir,getpid());
+ if (p->extra) sprintf(mailx, "%s/%i.extrout", config->notifydir,getpid());
+@@ -1640,8 +1658,9 @@
}
} else {
if (htonl(INADDR_ANY) == config->targetaddr.sin_addr.s_addr) {
@@ -75,7 +135,7 @@
return 1;
}
/* try to avoid loop */
-@@ -2882,7 +2884,7 @@
+@@ -2882,12 +2901,16 @@
char * responsemsg;
int virusdirlen=0;
char chownit[100];
@@ -84,7 +144,16 @@
int len=0;
int ret=0;
FILE * chowncmd;
-@@ -2920,7 +2922,8 @@
+ unsigned long kbfree;
++#if __FreeBSD_version >= 500000
+ struct statvfs fs;
++#else
++ struct statfs fs;
++#endif
+
+ w_memory_init(); // We need to initialize our memory allocation routines
+
+@@ -2920,7 +2943,8 @@
fclose(fp);
}else do_log(LOG_CRIT, "ERR: Can't write PID to %s", PID_FILE);
len=strlen(CHOWNCMD)+1+strlen(config->runasuser)+1+strlen(config->runasuser)+1+strlen(config->pidfile)+1;
@@ -94,3 +163,15 @@
if ((chowncmd=popen(chownit, "r"))==NULL){
do_log(LOG_ALERT, "ERR: Can't '%s' !!!", chowncmd);
return SCANNER_RET_ERR;
+@@ -3036,7 +3060,11 @@
+ }else{
+ /* child */
+ config->child=1;
++#if __FreeBSD_version >= 500000
+ if ( statvfs( config->virusdir, &fs ) == SCANNER_RET_ERR){
++#else
++ if ( statfs( config->virusdir, &fs ) == SCANNER_RET_ERR){
++#endif
+ config->emergency="Unable to get available space!";
+ do_log(LOG_EMERG, "ERR: Unable to get available space!");
+ return SCANNER_RET_CRIT; // Should never reach here, but keep it clean. :)
diff -ur p3scan/pkg-install p3scan-2.3.2_2/pkg-install
--- p3scan/pkg-install Wed Nov 1 00:50:01 2006
+++ p3scan-2.3.2_2/pkg-install Thu Apr 5 16:01:56 2007
@@ -107,11 +107,11 @@
exit 1
fi
- user=mailnull
- group=mail
+ user=${USER}
+ group=${GROUP}
spooldir=/var/spool/p3scan
childrendir=/var/spool/p3scan/children
- notifydir=/var/spool/p3scannotify
+ notifydir=/var/spool/p3scan/notify
piddir=/var/run/p3scan/
etcdir=${PREFIX:-$PKG_PREFIX}/etc
More information about the freebsd-ports
mailing list