[flow-tools] flow-capture pidfile error

Mark Fullmer maf@splintered.net
Mon, 3 Jun 2002 23:02:56 -0400


Index: flow-capture.c
===================================================================
RCS file: /usr/home/djnz-cvsroot/flow-tools/src/flow-capture.c,v
retrieving revision 1.59
diff -c -r1.59 flow-capture.c
*** flow-capture.c	27 May 2002 03:07:44 -0000	1.59
--- flow-capture.c	4 Jun 2002 03:01:26 -0000
***************
*** 112,117 ****
--- 112,118 ----
  void sig_hup(int);
  void sig_chld(int);
  pid_t pid;
+ char *pidfile;
  struct ftnet ftnet;
  
  void usage(void);
***************
*** 205,211 ****
    /* year/month/day nesting */
    nest = 3;
  
!   while ((i = getopt(argc, argv, "A:b:c:C:d:De:E:hm:n:N:S:V:w:z:R:")) != -1)
    
      switch (i) {
  
--- 206,215 ----
    /* year/month/day nesting */
    nest = 3;
  
!   /* pidfile */
!   pidfile = CAPTURE_PIDFILE;
! 
!   while ((i = getopt(argc, argv, "A:b:c:C:d:De:E:hm:n:N:p:S:V:w:z:R:")) != -1)
    
      switch (i) {
  
***************
*** 273,278 ****
--- 277,286 ----
          fterr_errx(1, "-3 <= nesting level <= 3\n");
        break;
  
+     case 'p': /* pidfile */
+       pidfile = optarg;
+       break;
+ 
      case 'R': /* Post rotate exec */
        if (strlen(optarg) > MAXPATHLEN)
          fterr_errx(1, "Post rotate argument too long");
***************
*** 353,359 ****
      if ((pid = fork()) == -1) {
        fterr_err(1, "fork()");
      } else if (pid) {
!       write_pidfile(pid, CAPTURE_PIDFILE, ftnet.dst_port);
        exit (0); /* parent */
      }
  
--- 361,367 ----
      if ((pid = fork()) == -1) {
        fterr_err(1, "fork()");
      } else if (pid) {
!       write_pidfile(pid, pidfile, ftnet.dst_port);
        exit (0); /* parent */
      }
  
***************
*** 1108,1114 ****
  
  main_exit:
  
!   unlink_pidfile(pid, CAPTURE_PIDFILE, ftnet.dst_port);
  
    if (sig_quit_flag)
      fterr_info("SIGQUIT");
--- 1116,1122 ----
  
  main_exit:
  
!   unlink_pidfile(pid, pidfile, ftnet.dst_port);
  
    if (sig_quit_flag)
      fterr_info("SIGQUIT");
***************
*** 1201,1207 ****
  void fterr_exit_handler(int code)
  {
    if (pid)
!     unlink_pidfile(pid, CAPTURE_PIDFILE, ftnet.dst_port);
    exit (code);
  } /* fterr_exit_handler */
  
--- 1209,1215 ----
  void fterr_exit_handler(int code)
  {
    if (pid)
!     unlink_pidfile(pid, pidfile, ftnet.dst_port);
    exit (code);
  } /* fterr_exit_handler */
  
***************
*** 1210,1216 ****
    fprintf(stderr, "Usage: flow-capture [-h] [-A AS0_substitution] [-b big|little]\n");
    fprintf(stderr, "       [-C comment] [-c flow_clients] [-d debug_level] [-D daemonize]\n");
    fprintf(stderr, "       [-e expire_count] [-E expire_size[bKMG]] [-m privacy_mask] [-n rotations]\n");
!   fprintf(stderr, "       [-N nesting_level] [-o output_file] [-R rotate_program]\n");
    fprintf(stderr, "       [-S stat_interval] [-V pdu_version] [-z z_level]\n");
    fprintf(stderr, "        -w workdir localip/remoteip/port\n");
    fprintf(stderr, "Signals:\n");
--- 1218,1224 ----
    fprintf(stderr, "Usage: flow-capture [-h] [-A AS0_substitution] [-b big|little]\n");
    fprintf(stderr, "       [-C comment] [-c flow_clients] [-d debug_level] [-D daemonize]\n");
    fprintf(stderr, "       [-e expire_count] [-E expire_size[bKMG]] [-m privacy_mask] [-n rotations]\n");
!   fprintf(stderr, "       [-N nesting_level] [-o output_file] [-p pidfile ] [-R rotate_program]\n");
    fprintf(stderr, "       [-S stat_interval] [-V pdu_version] [-z z_level]\n");
    fprintf(stderr, "        -w workdir localip/remoteip/port\n");
    fprintf(stderr, "Signals:\n");

On Mon, Jun 03, 2002 at 09:10:55PM -0400, Ed Ravin wrote:
> I am running flow-capture as a non-root user - whenever it starts up it
> complains about being unable to write a pidfile to /var/run.  There
> seems to be no way to disable that or to redirect it to a different
> directory - other than redefining CAPTURE_PIDFILE and rebuilding.
> A minor nit, but it would be nice to have a pidfile command line option
> to either rename or disable the pidfile.
> 
> 
> _______________________________________________
> flow-tools@splintered.net
> http://www.splintered.net/sw/flow-tools