OpenPKG CVS Repository
  http://cvs.openpkg.org/
  ____________________________________________________________________________

  Server: cvs.openpkg.org                  Name:   Michael van Elst
  Root:   /e/openpkg/cvs                   Email:  [EMAIL PROTECTED]
  Module: openpkg-src openpkg-web          Date:   18-Jul-2003 12:34:36
  Branch: HEAD                             Handle: 2003071811343501

  Added files:
    openpkg-src/portsentry  portsentry.patch
  Modified files:
    openpkg-src/portsentry  portsentry.spec rc.portsentry
    openpkg-web             news.txt

  Log:
    patch daemon to maintain pidfile, add %status section

  Summary:
    Revision    Changes     Path
    1.1         +98 -0      openpkg-src/portsentry/portsentry.patch
    1.35        +3  -1      openpkg-src/portsentry/portsentry.spec
    1.11        +25 -6      openpkg-src/portsentry/rc.portsentry
    1.5637      +1  -0      openpkg-web/news.txt
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: openpkg-src/portsentry/portsentry.patch
  ============================================================================
  $ cvs diff -u -r0 -r1.1 portsentry.patch
  --- /dev/null 2003-07-18 12:34:36.000000000 +0200
  +++ portsentry.patch  2003-07-18 12:34:36.000000000 +0200
  @@ -0,0 +1,98 @@
  +--- portsentry.c.dist        2003-07-18 12:06:57.000000000 +0200
  ++++ portsentry.c     2003-07-18 12:14:26.000000000 +0200
  +@@ -50,7 +50,7 @@
  + int
  + main (int argc, char *argv[])
  + {
  +-  if (argc != 2)
  ++  if (argc != 2 && argc != 3)
  +     {
  +       Usage ();
  +       Exit (ERROR);
  +@@ -100,7 +100,7 @@
  +       Exit (ERROR);
  +     }
  + #ifndef NODAEMON
  +-      else if (DaemonSeed () == ERROR)
  ++      else if (DaemonSeed (argc > 2 ? argv[2] : NULL) == ERROR)
  +     {
  +       Log ("adminalert: ERROR: could not go into daemon mode. Shutting down.\n");
  +       printf ("ERROR: could not go into daemon mode. Shutting down.\n");
  +@@ -1594,10 +1594,10 @@
  +   printf ("Licensing restrictions apply. Please see documentation\n");
  +   printf ("Version: %s\n\n", VERSION);
  + #ifdef SUPPORT_STEALTH
  +-  printf ("usage: portsentry [-tcp -udp -stcp -atcp -sudp -audp]\n\n");
  ++  printf ("usage: portsentry [-tcp -udp -stcp -atcp -sudp -audp] [pidfile]\n\n");
  + #else
  +   printf ("Stealth scan detection not supported on this platform\n");
  +-  printf ("usage: portsentry [-tcp -udp]\n\n");
  ++  printf ("usage: portsentry [-tcp -udp] [pidfile]\n\n");
  + #endif
  +   printf ("*** PLEASE READ THE DOCS BEFORE USING *** \n\n");
  + }
  +--- portsentry_io.h.dist     2003-07-18 12:07:02.000000000 +0200
  ++++ portsentry_io.h  2003-07-18 12:14:38.000000000 +0200
  +@@ -31,7 +31,7 @@
  + void Log (char *,...);
  + void Exit (int);
  + void Start (void);
  +-int DaemonSeed (void);
  ++int DaemonSeed (char *pidfile);
  + int NeverBlock (char *, char *);
  + int CheckConfig (void);
  + int OpenTCPSocket (void);
  +--- portsentry_io.c.dist     2003-07-18 12:07:11.000000000 +0200
  ++++ portsentry_io.c  2003-07-18 12:32:39.000000000 +0200
  +@@ -30,6 +30,8 @@
  + #include "portsentry_io.h"
  + #include "portsentry_util.h"
  + 
  ++static char *rmpidfile;
  ++
  + /* Main logging function to surrogate syslog */
  + void 
  + Log (char *logentry, ...)
  +@@ -54,6 +56,14 @@
  + {
  +   Log ("securityalert: Psionic PortSentry is shutting down\n");
  +   Log ("adminalert: Psionic PortSentry is shutting down\n");
  ++
  ++  if (rmpidfile) {
  ++    Log ("adminalert: Psionic PortSentry removes '%s'\n", rmpidfile);
  ++    if (unlink(rmpidfile))
  ++      Log ("adminalert: Psionic PortSentry cannot remove pidfile (%s)\n",
  ++           strerror(errno));
  ++  }
  ++
  +   exit (status);
  + }
  + 
  +@@ -72,9 +82,10 @@
  + /* The daemonizing code copied from Advanced Programming */
  + /* in the UNIX Environment by W. Richard Stevens with minor changes */
  + int 
  +-DaemonSeed (void)
  ++DaemonSeed (char *pidfile)
  + {
  +   int childpid;
  ++  FILE *f;
  + 
  +   signal (SIGALRM, SIG_IGN);
  +   signal (SIGHUP, SIG_IGN);
  +@@ -89,6 +100,15 @@
  +   else if (childpid > 0)
  +     exit (0);
  + 
  ++  if (pidfile != NULL) {
  ++    f = fopen(pidfile,"w");
  ++    if (f != NULL) {
  ++      fprintf(f,"%d",getpid());
  ++      fclose(f);
  ++      rmpidfile = pidfile;
  ++    }
  ++  }
  ++
  +   setsid ();
  +   chdir ("/");
  +   umask (077);
  @@ .
  patch -p0 <<'@@ .'
  Index: openpkg-src/portsentry/portsentry.spec
  ============================================================================
  $ cvs diff -u -r1.34 -r1.35 portsentry.spec
  --- openpkg-src/portsentry/portsentry.spec    17 Jul 2003 15:33:04 -0000      1.34
  +++ openpkg-src/portsentry/portsentry.spec    18 Jul 2003 10:34:36 -0000      1.35
  @@ -33,7 +33,7 @@
   Group:        Security
   License:      Open Source
   Version:      1.1
  -Release:      20030717
  +Release:      20030718
   
   #   package options
   %option       with_fsl  yes
  @@ -42,6 +42,7 @@
   Source0:      http://www.psionic.com/downloads/portsentry-%{version}.tar.gz
   Source1:      rc.portsentry
   Source2:      fsl.portsentry
  +Patch0:       portsentry.patch
   
   #   build information
   Prefix:       %{l_prefix}
  @@ -62,6 +63,7 @@
   
   %prep
       %setup -q
  +    %patch -p0
       %{l_shtool} subst \
           -e 's;portsentry_util.c$;portsentry_util.c $(LIBS);' \
           Makefile
  @@ .
  patch -p0 <<'@@ .'
  Index: openpkg-src/portsentry/rc.portsentry
  ============================================================================
  $ cvs diff -u -r1.10 -r1.11 rc.portsentry
  --- openpkg-src/portsentry/rc.portsentry      17 Jul 2003 21:34:58 -0000      1.10
  +++ openpkg-src/portsentry/rc.portsentry      18 Jul 2003 10:34:36 -0000      1.11
  @@ -11,21 +11,40 @@
       portsentry_log_minsize="1M"
       portsentry_log_complevel="9"
   
  +%common
  +    portsentry_tcp_pidfile="@l_prefix@/var/portsentry/tcp.pid"
  +    portsentry_udp_pidfile="@l_prefix@/var/portsentry/udp.pid"
  +    portsentry_signal () {
  +        [ -f $portsentry_tcp_pidfile ] \
  +        && kill -$1 `cat $portsentry_tcp_pidfile` \
  +        && [ -f $portsentry_udp_pidfile ] \
  +        && kill -$1 `cat $portsentry_udp_pidfile`
  +    }
  +
  +%status -p 200 -u @l_susr@ -o
  +    portsentry_usable="unknown"
  +    portsentry_active="no"
  +    opService portsentry enable yes && \
  +        portsentry_signal 0 && portsentry_active="yes"
  +    echo "portsentry_enable=\"$portsentry_enable\""
  +    echo "portsentry_usable=\"$portsentry_usable\""
  +    echo "portsentry_active=\"$portsentry_active\""
  +
   %start -p 200 -u @l_susr@
       opService portsentry enable yes || exit 0
  -    @l_prefix@/sbin/portsentry -tcp
  -    @l_prefix@/sbin/portsentry -udp
  +    @l_prefix@/sbin/portsentry -tcp $portsentry_tcp_pidfile
  +    @l_prefix@/sbin/portsentry -udp $portsentry_udp_pidfile
   
   %stop -p 200 -u @l_susr@
       opService portsentry enable yes || exit 0
  -    rpmtool signal TERM portsentry
  +    portsentry_signal TERM
   
   %restart -u @l_susr@
       opService portsentry enable yes || exit 0
  -    rpmtool signal TERM portsentry
  +    portsentry_signal TERM
       sleep 2
  -    @l_prefix@/sbin/portsentry -tcp
  -    @l_prefix@/sbin/portsentry -udp
  +    @l_prefix@/sbin/portsentry -tcp $portsentry_tcp_pidfile
  +    @l_prefix@/sbin/portsentry -udp $portsentry_udp_pidfile
   
   %daily -u @l_susr@
       opService portsentry enable yes || exit 0
  @@ .
  patch -p0 <<'@@ .'
  Index: openpkg-web/news.txt
  ============================================================================
  $ cvs diff -u -r1.5636 -r1.5637 news.txt
  --- openpkg-web/news.txt      18 Jul 2003 09:41:01 -0000      1.5636
  +++ openpkg-web/news.txt      18 Jul 2003 10:34:35 -0000      1.5637
  @@ -1,3 +1,4 @@
  +18-Jul-2003: Upgraded package: P<portsentry-1.1-20030718>
   18-Jul-2003: Upgraded package: P<ircd-2.10.3p3-20030718>
   18-Jul-2003: Upgraded package: P<imapd-2.1.14-20030718>
   18-Jul-2003: Upgraded package: P<libxml-2.5.8-20030718>
  @@ .
______________________________________________________________________
The OpenPKG Project                                    www.openpkg.org
CVS Repository Commit List                     [EMAIL PROTECTED]

Reply via email to