head 1.2; access; symbols OPENPKG_E1_MP_HEAD:1.2 OPENPKG_E1_MP:1.2 OPENPKG_E1_MP_2_STABLE:1.2 OPENPKG_E1_FP:1.2 OPENPKG_2_STABLE_MP:1.2 OPENPKG_2_STABLE_20061018:1.2 OPENPKG_2_STABLE_20060622:1.2 OPENPKG_2_STABLE:1.2.0.10 OPENPKG_2_STABLE_BP:1.2 OPENPKG_2_5_RELEASE:1.2 OPENPKG_2_5_SOLID:1.2.0.8 OPENPKG_2_5_SOLID_BP:1.2 OPENPKG_2_4_RELEASE:1.2 OPENPKG_2_4_SOLID:1.2.0.6 OPENPKG_2_4_SOLID_BP:1.2 OPENPKG_CW_FP:1.2 OPENPKG_2_3_RELEASE:1.2 OPENPKG_2_3_SOLID:1.2.0.4 OPENPKG_2_3_SOLID_BP:1.2 OPENPKG_2_2_RELEASE:1.2 OPENPKG_2_2_SOLID:1.2.0.2 OPENPKG_2_2_SOLID_BP:1.2 OPENPKG_2_1_RELEASE:1.1.6.1 OPENPKG_2_1_SOLID:1.1.0.6 OPENPKG_2_1_SOLID_BP:1.1 OPENPKG_2_0_RELEASE:1.1 OPENPKG_2_0_SOLID:1.1.0.4 OPENPKG_2_0_SOLID_BP:1.1 OPENPKG_1_3_RELEASE:1.1.2.1 OPENPKG_1_3_SOLID:1.1.2.1.0.2 OPENPKG_1_3_SOLID_BP:1.1.2.1 OPENPKG_1_STABLE:1.1.0.2 OPENPKG_1_STABLE_MP:1.1; locks; strict; comment @# @; 1.2 date 2004.07.05.08.05.12; author rse; state Exp; branches; next 1.1; 1.1 date 2003.07.18.10.34.36; author mlelstv; state Exp; branches 1.1.2.1 1.1.6.1; next ; 1.1.2.1 date 2003.07.24.20.45.02; author rse; state Exp; branches; next ; 1.1.6.1 date 2004.07.05.08.28.18; author rse; state Exp; branches; next ; desc @@ 1.2 log @upgrading package: portsentry 1.1 -> 1.2 @ text @Index: Makefile --- Makefile.orig 2003-05-23 20:10:13 +0200 +++ Makefile 2004-07-05 09:59:10 +0200 @@@@ -115,90 +115,90 @@@@ SYSTYPE=bsd @@echo "Making $(SYSTYPE)" $(CC) $(CFLAGS) -DBSD44 -o ./portsentry ./portsentry.c \ - ./portsentry_io.c ./portsentry_util.c + ./portsentry_io.c ./portsentry_util.c $(LIBS) openbsd: SYSTYPE=openbsd @@echo "Making $(SYSTYPE)" $(CC) $(CFLAGS) -DBSD44 -o ./portsentry ./portsentry.c \ - ./portsentry_io.c ./portsentry_util.c + ./portsentry_io.c ./portsentry_util.c $(LIBS) freebsd: SYSTYPE=freebsd @@echo "Making $(SYSTYPE)" $(CC) $(CFLAGS) -DBSD44 -o ./portsentry ./portsentry.c \ - ./portsentry_io.c ./portsentry_util.c + ./portsentry_io.c ./portsentry_util.c $(LIBS) osx: SYSTYPE=osx @@echo "Making $(SYSTYPE)" $(CC) $(CFLAGS) -DBSD44 -o ./portsentry ./portsentry.c \ - ./portsentry_io.c ./portsentry_util.c + ./portsentry_io.c ./portsentry_util.c $(LIBS) netbsd: SYSTYPE=netbsd @@echo "Making $(SYSTYPE)" $(CC) $(CFLAGS) -DBSD44 -o ./portsentry ./portsentry.c \ - ./portsentry_io.c ./portsentry_util.c + ./portsentry_io.c ./portsentry_util.c $(LIBS) bsdi: SYSTYPE=bsdi @@echo "Making $(SYSTYPE)" $(CC) $(CFLAGS) -DBSD44 -o ./portsentry ./portsentry.c \ - ./portsentry_io.c ./portsentry_util.c + ./portsentry_io.c ./portsentry_util.c $(LIBS) generic: SYSTYPE=generic @@echo "Making $(SYSTYPE)" $(CC) $(CFLAGS) -o ./portsentry ./portsentry.c ./portsentry_io.c \ - ./portsentry_util.c + ./portsentry_util.c $(LIBS) hpux: SYSTYPE=hpux @@echo "Making $(SYSTYPE)" $(CC) -Ae -DHPUX -o ./portsentry ./portsentry.c ./portsentry_io.c \ - ./portsentry_util.c + ./portsentry_util.c $(LIBS) hpux-gcc: SYSTYPE=hpux-gcc @@echo "Making $(SYSTYPE)" $(CC) $(CFLAGS) -DHPUX -o ./portsentry ./portsentry.c ./portsentry_io.c \ - ./portsentry_util.c + ./portsentry_util.c $(LIBS) solaris: SYSTYPE=solaris @@echo "Making $(SYSTYPE)" $(CC) -lnsl -lsocket -lresolv -lc -o ./portsentry ./portsentry.c ./portsentry_io.c \ - ./portsentry_util.c + ./portsentry_util.c $(LIBS) aix: SYSTYPE=aix @@echo "Making $(SYSTYPE)" $(CC) $(CFLAGS) -o ./portsentry ./portsentry.c ./portsentry_io.c \ - ./portsentry_util.c + ./portsentry_util.c $(LIBS) osf: SYSTYPE=osf @@echo "Making $(SYSTYPE)" $(CC) $(CFLAGS) -taso -ldb -o ./portsentry ./portsentry.c ./portsentry_io.c \ - ./portsentry_util.c + ./portsentry_util.c $(LIBS) irix: SYSTYPE=irix @@echo "Making $(SYSTYPE)" $(CC) $(CFLAGS) -O -n32 -mips3 -o ./portsentry ./portsentry.c ./portsentry_io.c \ - ./portsentry_util.c + ./portsentry_util.c $(LIBS) # NeXTSTEP Users. NeXT used to work, but we changed the log function and Index: portsentry.c --- portsentry.c.orig 2003-05-23 20:10:13 +0200 +++ portsentry.c 2004-07-05 09:59:34 +0200 @@@@ -41,7 +41,7 @@@@ int main (int argc, char *argv[]) { - if (argc != 2) + if (argc != 2 && argc != 3) { Usage (); Exit (ERROR); @@@@ -91,7 +91,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"); @@@@ -1581,15 +1581,14 @@@@ Usage (void) { printf ("PortSentry - Port Scan Detector.\n"); - printf ("Copyright 1997-2003 Craig H. Rowland \n"); + printf ("Copyright 1997-2003 Craig H. Rowland \n"); 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"); } Index: portsentry_io.c --- portsentry_io.c.orig 2003-05-23 20:10:13 +0200 +++ portsentry_io.c 2004-07-05 09:59:10 +0200 @@@@ -21,6 +21,8 @@@@ #include "portsentry_io.h" #include "portsentry_util.h" +static char *rmpidfile; + /* Main logging function to surrogate syslog */ void Log (char *logentry, ...) @@@@ -45,6 +47,13 @@@@ { Log ("securityalert: PortSentry is shutting down\n"); Log ("adminalert: PortSentry is shutting down\n"); + + if (rmpidfile) { + Log ("adminalert: PortSentry removes '%s'\n", rmpidfile); + if (unlink(rmpidfile)) + Log ("adminalert: PortSentry cannot remove pidfile (%s)\n", strerror(errno)); + } + exit (status); } @@@@ -63,9 +72,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); @@@@ -80,6 +90,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); Index: portsentry_io.h --- portsentry_io.h.orig 2003-05-23 20:10:13 +0200 +++ portsentry_io.h 2004-07-05 09:59:10 +0200 @@@@ -22,7 +22,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); @ 1.1 log @patch daemon to maintain pidfile, add %status section @ text @d1 111 a111 3 --- 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 @@@@ d120 1 a120 1 @@@@ -100,7 +100,7 @@@@ d129 7 a135 1 @@@@ -1594,10 +1594,10 @@@@ d148 4 a151 14 --- 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 @@@@ d160 1 a160 1 @@@@ -54,6 +56,14 @@@@ d162 2 a163 2 Log ("securityalert: Psionic PortSentry is shutting down\n"); Log ("adminalert: Psionic PortSentry is shutting down\n"); d166 1 a166 1 + Log ("adminalert: Psionic PortSentry removes '%s'\n", rmpidfile); d168 1 a168 2 + Log ("adminalert: Psionic PortSentry cannot remove pidfile (%s)\n", + strerror(errno)); d174 1 a174 1 @@@@ -72,9 +82,10 @@@@ d186 1 a186 1 @@@@ -89,6 +100,15 @@@@ d202 12 @ 1.1.6.1 log @MFC: upgrade to latest version from CURRENT @ text @d1 3 a3 111 Index: Makefile --- Makefile.orig 2003-05-23 20:10:13 +0200 +++ Makefile 2004-07-05 09:59:10 +0200 @@@@ -115,90 +115,90 @@@@ SYSTYPE=bsd @@echo "Making $(SYSTYPE)" $(CC) $(CFLAGS) -DBSD44 -o ./portsentry ./portsentry.c \ - ./portsentry_io.c ./portsentry_util.c + ./portsentry_io.c ./portsentry_util.c $(LIBS) openbsd: SYSTYPE=openbsd @@echo "Making $(SYSTYPE)" $(CC) $(CFLAGS) -DBSD44 -o ./portsentry ./portsentry.c \ - ./portsentry_io.c ./portsentry_util.c + ./portsentry_io.c ./portsentry_util.c $(LIBS) freebsd: SYSTYPE=freebsd @@echo "Making $(SYSTYPE)" $(CC) $(CFLAGS) -DBSD44 -o ./portsentry ./portsentry.c \ - ./portsentry_io.c ./portsentry_util.c + ./portsentry_io.c ./portsentry_util.c $(LIBS) osx: SYSTYPE=osx @@echo "Making $(SYSTYPE)" $(CC) $(CFLAGS) -DBSD44 -o ./portsentry ./portsentry.c \ - ./portsentry_io.c ./portsentry_util.c + ./portsentry_io.c ./portsentry_util.c $(LIBS) netbsd: SYSTYPE=netbsd @@echo "Making $(SYSTYPE)" $(CC) $(CFLAGS) -DBSD44 -o ./portsentry ./portsentry.c \ - ./portsentry_io.c ./portsentry_util.c + ./portsentry_io.c ./portsentry_util.c $(LIBS) bsdi: SYSTYPE=bsdi @@echo "Making $(SYSTYPE)" $(CC) $(CFLAGS) -DBSD44 -o ./portsentry ./portsentry.c \ - ./portsentry_io.c ./portsentry_util.c + ./portsentry_io.c ./portsentry_util.c $(LIBS) generic: SYSTYPE=generic @@echo "Making $(SYSTYPE)" $(CC) $(CFLAGS) -o ./portsentry ./portsentry.c ./portsentry_io.c \ - ./portsentry_util.c + ./portsentry_util.c $(LIBS) hpux: SYSTYPE=hpux @@echo "Making $(SYSTYPE)" $(CC) -Ae -DHPUX -o ./portsentry ./portsentry.c ./portsentry_io.c \ - ./portsentry_util.c + ./portsentry_util.c $(LIBS) hpux-gcc: SYSTYPE=hpux-gcc @@echo "Making $(SYSTYPE)" $(CC) $(CFLAGS) -DHPUX -o ./portsentry ./portsentry.c ./portsentry_io.c \ - ./portsentry_util.c + ./portsentry_util.c $(LIBS) solaris: SYSTYPE=solaris @@echo "Making $(SYSTYPE)" $(CC) -lnsl -lsocket -lresolv -lc -o ./portsentry ./portsentry.c ./portsentry_io.c \ - ./portsentry_util.c + ./portsentry_util.c $(LIBS) aix: SYSTYPE=aix @@echo "Making $(SYSTYPE)" $(CC) $(CFLAGS) -o ./portsentry ./portsentry.c ./portsentry_io.c \ - ./portsentry_util.c + ./portsentry_util.c $(LIBS) osf: SYSTYPE=osf @@echo "Making $(SYSTYPE)" $(CC) $(CFLAGS) -taso -ldb -o ./portsentry ./portsentry.c ./portsentry_io.c \ - ./portsentry_util.c + ./portsentry_util.c $(LIBS) irix: SYSTYPE=irix @@echo "Making $(SYSTYPE)" $(CC) $(CFLAGS) -O -n32 -mips3 -o ./portsentry ./portsentry.c ./portsentry_io.c \ - ./portsentry_util.c + ./portsentry_util.c $(LIBS) # NeXTSTEP Users. NeXT used to work, but we changed the log function and Index: portsentry.c --- portsentry.c.orig 2003-05-23 20:10:13 +0200 +++ portsentry.c 2004-07-05 09:59:34 +0200 @@@@ -41,7 +41,7 @@@@ d12 1 a12 1 @@@@ -91,7 +91,7 @@@@ d21 1 a21 7 @@@@ -1581,15 +1581,14 @@@@ Usage (void) { printf ("PortSentry - Port Scan Detector.\n"); - printf ("Copyright 1997-2003 Craig H. Rowland \n"); + printf ("Copyright 1997-2003 Craig H. Rowland \n"); d34 14 a47 4 Index: portsentry_io.c --- portsentry_io.c.orig 2003-05-23 20:10:13 +0200 +++ portsentry_io.c 2004-07-05 09:59:10 +0200 @@@@ -21,6 +21,8 @@@@ d56 1 a56 1 @@@@ -45,6 +47,13 @@@@ d58 2 a59 2 Log ("securityalert: PortSentry is shutting down\n"); Log ("adminalert: PortSentry is shutting down\n"); d62 1 a62 1 + Log ("adminalert: PortSentry removes '%s'\n", rmpidfile); d64 2 a65 1 + Log ("adminalert: PortSentry cannot remove pidfile (%s)\n", strerror(errno)); d71 1 a71 1 @@@@ -63,9 +72,10 @@@@ d83 1 a83 1 @@@@ -80,6 +90,15 @@@@ a98 12 Index: portsentry_io.h --- portsentry_io.h.orig 2003-05-23 20:10:13 +0200 +++ portsentry_io.h 2004-07-05 09:59:10 +0200 @@@@ -22,7 +22,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); @ 1.1.2.1 log @mass Merge-From-CURRENT (MFC) in preparation for OpenPKG 1.3 [class BASE only] @ text @@