OpenPKG CVS Repository
http://cvs.openpkg.org/
____________________________________________________________________________
Server: cvs.openpkg.org Name: Ralf S. Engelschall
Root: /e/openpkg/cvs Email: [EMAIL PROTECTED]
Module: openpkg-src Date: 05-Aug-2003 18:12:01
Branch: HEAD Handle: 2003080517120000
Added files:
openpkg-src/sav sweep.c sweep.mk
Modified files:
openpkg-src/sav rc.sav sav.spec sweep.sh
Removed files:
openpkg-src/sav wrap_open.c
Log:
finish packaging
Summary:
Revision Changes Path
1.2 +28 -1 openpkg-src/sav/rc.sav
1.16 +32 -39 openpkg-src/sav/sav.spec
1.1 +187 -0 openpkg-src/sav/sweep.c
1.1 +28 -0 openpkg-src/sav/sweep.mk
1.3 +6 -3 openpkg-src/sav/sweep.sh
1.2 +0 -22 openpkg-src/sav/wrap_open.c
____________________________________________________________________________
patch -p0 <<'@@ .'
Index: openpkg-src/sav/rc.sav
============================================================================
$ cvs diff -u -r1.1 -r1.2 rc.sav
--- openpkg-src/sav/rc.sav 5 Aug 2003 10:55:36 -0000 1.1
+++ openpkg-src/sav/rc.sav 5 Aug 2003 16:12:00 -0000 1.2
@@ -5,8 +5,35 @@
%config
sav_enable="$openpkg_rc_def"
+ sav_ides="http://www.sophos.com/downloads/ide/"
%daily -u @l_susr@
rcService sav enable yes || exit 0
- # FIXME: cs: periodic virus pattern fetching
+
+ # determine information
+ sav_datadir="@l_prefix@/var/sav/data"
+ [EMAIL PROTECTED]@/bin/sweep -v |\
+ sed -n -e 's;^Product
version[^0-9]*\([0-9]\)\.\([0-9.]*\).*$;\1\2;p'`
+ sav_zipfile="${sav_version}_ides.zip"
+ sav_tmpdir="${sav_version}_ides"
+
+ # download and unpack latest IDEs
+ umask 077
+ cd ${sav_datadir} || exit 1
+ @l_prefix@/bin/curl -s -o ${sav_zipfile} ${sav_ides}/${sav_zipfile} || exit 1
+ mkdir ${sav_tmpdir}
+ (cd ${sav_tmpdir} && @l_prefix@/bin/unzip -jo ../${sav_zipfile}) || exit 1
+
+ # update IDE repository
+ for ide in *.ide; do
+ if [ ! -f ${sav_tmpdir}/$ide ]; then
+ rm -f $ide
+ fi
+ done
+ cp ${sav_tmpdir}/*.ide .
+ chmod 644 *.ide
+
+ # cleanup
+ rm -f ${sav_zipfile} >/dev/null 2>&1 || true
+ rm -rf ${sav_tmpdir} >/dev/null 2>&1 || true
@@ .
patch -p0 <<'@@ .'
Index: openpkg-src/sav/sav.spec
============================================================================
$ cvs diff -u -r1.15 -r1.16 sav.spec
--- openpkg-src/sav/sav.spec 5 Aug 2003 10:55:36 -0000 1.15
+++ openpkg-src/sav/sav.spec 5 Aug 2003 16:12:00 -0000 1.16
@@ -23,10 +23,6 @@
## SUCH DAMAGE.
##
-# package versions
-%define V_sav 2.14
-%define V_ide 372
-
# package information
Name: sav
Summary: Sophos Anti-Virus
@@ -36,28 +32,27 @@
Distribution: OpenPKG [EVAL]
Group: System
License: Commercial/Free-Trail
-Version: %{V_sav}
+Version: 2.14
Release: 20030805
# list of sources
-Source0: http://www.sophos.com/downloads/ide/%{V_ide}_ides.zip
-Source1: http://downloads.sophos.com/dp/full/freebsd.elf.tar.Z
-Source2: http://downloads.sophos.com/dp/full/linux.intel.libc6.tar.Z
-Source3: http://downloads.sophos.com/dp/full/solaris.sparc.tar.Z
-Source4: rc.sav
-Source5: sav.conf
-Source6: sweep.sh
-Source7: wrap_open.c
+Source0: http://downloads.sophos.com/dp/full/freebsd.elf.tar.Z
+Source1: http://downloads.sophos.com/dp/full/linux.intel.libc6.tar.Z
+Source2: http://downloads.sophos.com/dp/full/solaris.sparc.tar.Z
+Source3: rc.sav
+Source4: sav.conf
+Source5: sweep.sh
+Source6: sweep.c
+Source7: sweep.mk
%NoSource 0
%NoSource 1
%NoSource 2
-%NoSource 3
# build information
Prefix: %{l_prefix}
BuildRoot: %{l_buildroot}
-BuildPreReq: OpenPKG, openpkg >= 20030717, gcc, infozip
-PreReq: OpenPKG, openpkg >= 20030717
+BuildPreReq: OpenPKG, openpkg >= 20030717, gcc
+PreReq: OpenPKG, openpkg >= 20030717, curl, infozip
AutoReq: no
AutoReqProv: no
@@ -78,16 +73,17 @@
esac
%{l_gzip} -d -c $engine | %{l_tar} xf -
- # decompress identity files (IDEs)
- ( mkdir ides; cd ides;
- %{l_prefix}/bin/unzip -x %{SOURCE %{V_ide}_ides.zip}
- ) || exit $?
-
- # prepare open() wrapper (/etc/sav.conf -> %{l_prefix}/etc/sav/sav.conf)
- %{l_shtool} install -c -m 644 %{l_value -s -a} %{SOURCE wrap_open.c} ./
-
%build
- %{l_cc} -ldl -shared -s -o wrap_open.so wrap_open.c
+ # build open(2) wrapper DSO
+ # (for mapping hard-coded /etc/sav.conf to %{l_prefix}/etc/sav/sav.conf)
+ %{l_shtool} install -c -m 644 %{l_value -s -a} \
+ %{SOURCE sweep.c} %{SOURCE sweep.mk} ./
+ case "%{l_target}" in
+ *-freebsd* ) target="freebsd" ;;
+ *-linux* ) target="linux" ;;
+ *-solaris* ) target="solaris" ;;
+ esac
+ %{l_make} %{l_mflags} -f sweep.mk $target
%install
rm -rf $RPM_BUILD_ROOT
@@ -102,9 +98,9 @@
$RPM_BUILD_ROOT%{l_prefix}/man/man1 \
$RPM_BUILD_ROOT%{l_prefix}/var/sav/data
- # install open() wrapper library
+ # install open(2) wrapper library
%{l_shtool} install -c -m 755 \
- wrap_open.so \
+ sweep.so \
$RPM_BUILD_ROOT%{l_prefix}/libexec/sav/
# install binary wrapper script
@@ -114,7 +110,8 @@
# install run-command script
%{l_shtool} install -c -m 755 %{l_value -s -a} \
- %{SOURCE rc.sav} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
+ %{SOURCE rc.sav} \
+ $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
# install default configuration
%{l_shtool} install -c -m 644 %{l_value -s -a} \
@@ -123,18 +120,17 @@
# install SAVI library and add compatibility links
%{l_shtool} install -c -m 755 \
- sav-install/libsavi.so.3.* \
+ sav-install/libsavi.so* \
$RPM_BUILD_ROOT%{l_prefix}/lib/sav/
( cd $RPM_BUILD_ROOT%{l_prefix}/lib/sav
- %{l_shtool} mkln -s -f libsavi.so.3* libsavi.so.3
- %{l_shtool} mkln -s -f libsavi.so.3* libsavi.so.2
- %{l_shtool} mkln -s -f libsavi.so.3* libsavi.so
+ %{l_shtool} mkln -s -f libsavi.so.3.* libsavi.so.3
+ %{l_shtool} mkln -s -f libsavi.so.3.* libsavi.so
) || exit $?
# install original binary
%{l_shtool} install -c -m 755 \
sav-install/sweep \
- $RPM_BUILD_ROOT%{l_prefix}/libexec/sav/sweep.bin
+ $RPM_BUILD_ROOT%{l_prefix}/libexec/sav/sweep
# install man page
%{l_shtool} install -c -m 644 \
@@ -148,13 +144,10 @@
%{l_shtool} install -c -m 644 \
sav-install/vdl*.vdb \
$RPM_BUILD_ROOT%{l_prefix}/var/sav/data/
- for ide in ides/*.ide; do
- %{l_shtool} install -c -m 644 \
- $ide $RPM_BUILD_ROOT%{l_prefix}/var/sav/data/
- done
- # generate file list
- %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std} \
+ # determine installation files
+ %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
+ %{l_files_std} \
'%config %{l_prefix}/etc/sav/*'
%files -f files
@@ .
patch -p0 <<'@@ .'
Index: openpkg-src/sav/sweep.c
============================================================================
$ cvs diff -u -r0 -r1.1 sweep.c
--- /dev/null 2003-08-05 18:12:00.000000000 +0200
+++ sweep.c 2003-08-05 18:12:00.000000000 +0200
@@ -0,0 +1,187 @@
+/*
+** sweep.c -- Sophos Anti-Virus binary RTLD wrapper
+*/
+
+#define CONFIG_OLD "/etc/sav.conf"
+#define CONFIG_NEW "@l_prefix@/etc/sav/sav.conf"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <unistd.h>
+#include <limits.h>
+
+#if defined(PATH_MAX)
+#define PATH_ADJUST_MAXLEN PATH_MAX
+#elif defined(MAXPATHLEN)
+#define PATH_ADJUST_MAXLEN MAXPATHLEN
+#else
+#define PATH_ADJUST_MAXLEN 1024
+#endif
+
+static void path_adjust(char *buf, size_t buflen, const char *path)
+{
+ size_t pathlen;
+
+ /* special case first */
+ if (path == NULL) {
+ buf[0] = '\0';
+ return;
+ }
+
+ /* take over path into buffer */
+ pathlen = strlen(path);
+ if (pathlen > buflen)
+ pathlen = buflen;
+ strncpy(buf, path, pathlen);
+ buf[pathlen] = '\0';
+
+ /* apply path adjustments */
+ if (strcmp(buf, CONFIG_OLD) == 0)
+ strcpy(buf, CONFIG_NEW);
+
+ return;
+}
+
+#if OPENPKG_FREEBSD
+
+#include <dlfcn.h>
+#include <fcntl.h>
+
+int open(const char *path, int flags, ...)
+{
+ static int (*func)(const char *, int, ...) = NULL;
+ char path_adjusted[PATH_ADJUST_MAXLEN];
+ int rv;
+ int mode;
+ va_list ap;
+
+ /* initially resolve original open(2) function */
+ if (func == NULL)
+ func = dlsym(RTLD_NEXT, "open");
+
+ /* adjust path */
+ path_adjust(path_adjusted, sizeof(path_adjusted), path);
+
+ /* execute original function */
+ if (flags & O_CREAT) {
+ va_start(ap, flags);
+ mode = (int)va_arg(ap, int);
+ rv = func(path_adjusted, flags, mode);
+ va_end(ap);
+ }
+ else
+ rv = func(path_adjusted, flags);
+
+ /* pass-through return value */
+ return rv;
+}
+
+/* ----------------------------------------------------------------- */
+
+#elif OPENPKG_LINUX
+
+#include <features.h>
+#define __USE_GNU
+#include <dlfcn.h>
+#undef __USE_GNU
+#include <fcntl.h>
+
+static int
+myopen(
+ const char *func_name,
+ int (**func_ptr)(const char *, int, ...),
+ char *buf,
+ size_t buflen,
+ const char *path,
+ int flags,
+ va_list ap)
+{
+ int rv;
+ int mode;
+
+ /* initially resolve original open(2) like function */
+ if (*func_ptr == NULL) {
+ if ((*func_ptr = dlsym(RTLD_NEXT, func_name)) == NULL) {
+ fprintf(stderr, "sweep.so: unable to resolve function \"%s\"\n",
func_name);
+ abort();
+ }
+ }
+
+ /* adjust path */
+ path_adjust(buf, buflen, path);
+
+ /* execute original function */
+ if (flags & O_CREAT) {
+ mode = (int)va_arg(ap, int);
+ rv = (*func_ptr)(buf, flags, mode);
+ }
+ else
+ rv = (*func_ptr)(buf, flags);
+
+ /* pass-through return value */
+ return rv;
+}
+
+#define genstub(name) \
+int name(const char *path, int flags, ...) \
+{ \
+ static int (*func)(const char *, int, ...) = NULL; \
+ char path_adjusted[PATH_ADJUST_MAXLEN]; \
+ va_list ap; \
+ int rv; \
+\
+ va_start(ap, flags); \
+ rv = myopen(#name, &func, path_adjusted, sizeof(path_adjusted), path, flags,
ap); \
+ va_end(ap); \
+ return rv; \
+}
+
+genstub(open)
+genstub(open64)
+genstub(__open)
+genstub(__open64)
+genstub(__libc_open)
+genstub(__libc_open64)
+
+#elif OPENPKG_SOLARIS
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <dlfcn.h>
+
+int open(const char *path, int flags, ...)
+{
+ static int (*func)(const char *, int, ...) = NULL;
+ char path_adjusted[PATH_ADJUST_MAXLEN];
+ int rv;
+ int mode;
+ va_list ap;
+
+ fprintf(stderr, "FUCK\n");
+
+ /* initially resolve original open(2) function */
+ if (func == NULL)
+ func = dlsym(RTLD_NEXT, "open");
+
+ /* adjust path */
+ path_adjust(path_adjusted, sizeof(path_adjusted), path);
+
+ /* execute original function */
+ if (flags & O_CREAT) {
+ va_start(ap, flags);
+ mode = (int)va_arg(ap, int);
+ rv = func(path_adjusted, flags, mode);
+ va_end(ap);
+ }
+ else
+ rv = func(path_adjusted, flags);
+
+ /* pass-through return value */
+ return rv;
+}
+
+#endif
+
@@ .
patch -p0 <<'@@ .'
Index: openpkg-src/sav/sweep.mk
============================================================================
$ cvs diff -u -r0 -r1.1 sweep.mk
--- /dev/null 2003-08-05 18:12:00.000000000 +0200
+++ sweep.mk 2003-08-05 18:12:00.000000000 +0200
@@ -0,0 +1,28 @@
+
+PLATFORM =
+CC = gcc
+CPPFLAGS = -DOPENPKG_$(PLATFORM)=1
+CFLAGS = -Wall -fpic
+LD = gcc
+LDFLAGS = -shared
+LIBS =
+MFLAGS = -f sweep.mk
+
+all: freebsd
+
+freebsd:
+ $(MAKE) $(MFLAGS) sweep.so PLATFORM=FREEBSD
+linux:
+ $(MAKE) $(MFLAGS) sweep.so PLATFORM=LINUX LIBS="-ldl"
+solaris:
+ $(MAKE) $(MFLAGS) sweep.so PLATFORM=SOLARIS
+
+sweep.o: sweep.c
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c -o sweep.o sweep.c
+
+sweep.so: sweep.o
+ $(LD) $(LDFLAGS) -o sweep.so sweep.o $(LIBS)
+
+clean:
+ rm -f sweep.so sweep.o
+
@@ .
patch -p0 <<'@@ .'
Index: openpkg-src/sav/sweep.sh
============================================================================
$ cvs diff -u -r1.2 -r1.3 sweep.sh
--- openpkg-src/sav/sweep.sh 5 Aug 2003 10:55:36 -0000 1.2
+++ openpkg-src/sav/sweep.sh 5 Aug 2003 16:12:00 -0000 1.3
@@ -1,17 +1,20 @@
#!/bin/sh
##
-## sweep - Sophos Anti-Virus binary wrapper
+## sweep -- Sophos Anti-Virus binary wrapper
##
# force DSO to be pre-loaded
-LD_PRELOAD="@l_prefix@/libexec/sav/wrap_open.so"
+LD_PRELOAD="@l_prefix@/libexec/sav/sweep.so"
export LD_PRELOAD
+# make sure shared libaries are found
LD_LIBRARY_PATH="@l_prefix@/lib/sav:/usr/lib:/lib:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH
+
+# make sure private data is found
SAV_IDE="@l_prefix@/var/sav/data"
export SAV_IDE
# execute original executable
-exec @l_prefix@/libexec/sav/sweep.bin "$@"
+exec @l_prefix@/libexec/sav/sweep ${1+"$@"}
@@ .
rm -f openpkg-src/sav/wrap_open.c <<'@@ .'
Index: openpkg-src/sav/wrap_open.c
============================================================================
[NO CHANGE SUMMARY BECAUSE FILE AS A WHOLE IS JUST REMOVED]
@@ .
______________________________________________________________________
The OpenPKG Project www.openpkg.org
CVS Repository Commit List [EMAIL PROTECTED]