Changeset 75

Show
Ignore:
Timestamp:
06.10.2002 18:39:42 (6 years ago)
Author:
tibob
Message:

- pid configurable through command line [RC, looking at Loic Tortay's patch for pid configurable through configfile]
- various minor fixes [LT, RC]

Location:
trunk
Files:
12 modified

Legend:

Unmodified
Added
Removed
  • trunk/HISTORY

    r71 r75  
    22------------------ 
    33- typos in ipfm.conf.sample (Fixes Debian Bug #146409) 
     4- pid configurable through command line [RC, looking at Loic Tortay's patch for pid configurable through configfile] 
     5- various minor fixes [LT, RC] 
    46 
    57Version 0.11.5pre2 
  • trunk/Makefile.common.in

    r63 r75  
    11# 
    22# Common definitions for all the Makefile's 
    3 # Copyright (c) 1999 Robert CHERAMY <tibob@via.ecp.fr> 
     3# Copyright (c) 1999-2002 Robert CHERAMY <robert@cheramy.net> 
    44# Copyright (c) 2001 Loïc Tortay & IN2P3 Computing Center <tortay@cc.in2p3.fr> 
    55# 
     
    1515ETCDIR  = $(ROOT)@sysconfdir@ 
    1616LOGDIR  = $(ROOT)@localstatedir@/log 
    17 VARRUN  = $(ROOT)@localstatedir@/run 
     17VARRUNDIR = $(ROOT)@localstatedir@/run 
    1818 
    1919INSTALL = @INSTALL@ 
     
    2626CONFIGFILE=$(ETCDIR)/ipfm.conf 
    2727LOGFILE=$(LOGDIR)/ipfm/%d-%b.%H-%M 
    28 PIDFILE=$(VARRUN)/ipfm.pid 
     28PIDFILE=$(VARRUNDIR)/ipfm.pid 
    2929 
  • trunk/Makefile.in

    r63 r75  
    11# 
    22# Makefile for ipfm 
    3 # Copyright (c) 1999 Robert CHERAMY <tibob@via.ecp.fr> 
     3# Copyright (c) 1999-2002 Robert CHERAMY <robert@cheramy.net> 
    44# Copyright (c) 2001 Loïc Tortay & IN2P3 Computing Center <tortay@cc.in2p3.fr> 
    55# 
     
    2626        $(INSTALL) -m 444 doc/ipfm.8 $(MANDIR)/man8/ipfm.8 
    2727        $(INSTALL) -d -m 755 $(LOGDIR)/ipfm 
     28        $(INSTALL) -d -m 755 $(VARRUNDIR) 
    2829 
    2930clean: 
  • trunk/VERSION

    r67 r75  
    1 0.11.5pre2 
     10.11.5pre3 
  • trunk/doc/Makefile.in

    r28 r75  
    11# 
    22# Makefile for ipfm docs 
     3# Copyright (c) 1999-2002 Robert CHERAMY <robert@cheramy.net> 
    34# 
    45 
    56include ../Makefile.common 
    67 
    7 SED_SCRIPT=-e "s§__CONFIGURATION_FILE§$(CONFIGURATION_FILE)§g" \ 
    8            -e "s§__LOGFILE§$(LOG_FILE)§g" 
     8SED_SCRIPT=-e "s§__CONFIGURATION_FILE§$(CONFIGFILE)§g" \ 
     9           -e "s§__LOGFILE§$(LOGFILE)§g" \ 
     10           -e "s§__PIDFILE§$(PIDFILE)§g" 
    911 
    1012all: man 
  • trunk/doc/ipfm.man

    r63 r75  
    11.\" -*-nroff-*- 
    22.\" 
    3 .\"     Copyright (c) 1999-2001 Robert CHERAMY <robert@cheramy.net> 
     3.\"     Copyright (c) 1999-2002 Robert CHERAMY <robert@cheramy.net> 
    44.\"     Copyright (c) 2001 Loïc Tortay & IN2P3 Computing Center <tortay@cc.in2p3.fr> 
    55.\" 
     
    1818.\"     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
    1919.\" 
    20 .TH IPFM 8 "Last change: 11 november 2001" 
     20.TH IPFM 8 "Last change: 06 october 2002" 
    2121 
    2222.SH NAME 
     
    2929][\-\-config 
    3030.I config-file 
    31 ]  [-h][--help] [-n][--nodaemon] 
     31] [-h][--help] [-n][--nodaemon] [\-p 
     32.I pid-file 
     33][--pid 
     34.I pid-file 
     35] 
    3236 
    3337.SH DESCRIPTION 
     
    4953 
    5054.SH OPTIONS 
    51 .IP "-c config-file, --config <file>" 
     55.IP "-c config-file, --config config-file" 
    5256.I config-file 
    5357specifies an alternate configuration file to use. By default, 
     
    5862.IP "-h, --help" 
    5963displays an help message on standard output and exit 
     64.IP "-p pid-file, --pid pid-file" 
     65.I pid-file 
     66specifies an alternate pid file to use. By default, 
     67.IR __PIDFILE 
     68is used. 
    6069 
    6170.SH SIGNALS 
  • trunk/source/Makefile.in

    r63 r75  
    11# 
    2 # Makefile for ipfm 
     2# Makefile for ipfm sources 
     3# Copyright (c) 1999-2002 Robert CHERAMY <robert@cheramy.net> 
    34# 
    45 
    56include ../Makefile.common 
    67 
    7 DEFINES = -DPIDFILE=\"$(PIDFILE)\" \ 
     8DEFINES = -DDEFAULT_OPTIONS_PIDFILE=\"$(PIDFILE)\" \ 
    89          -DDEFAULT_OPTIONS_CONFIGFILE=\"$(CONFIGFILE)\" \ 
    910          -DDEFAULT_OPTIONS_LOGFILE=\"$(LOGFILE)\"  
  • trunk/source/config.l

    r66 r75  
    33  config.l - functions parsing the configuration file 
    44   
    5   (c) 1999-2000 Robert Cheramy <tibob@via.ecp.fr> 
     5  (c) 1999-2002 Robert Cheramy <robert@cheramy.net> 
    66  (c) 2000      Samuel Hocevar <sam@via.ecp.fr> 
    77  
     
    1212  which helped me to understand Lex and Yacc 
    1313 
    14   200010xx : sam & tibob : various config options 
     14  200010 : sam & tibob : various config options 
    1515 */ 
    1616 
     
    118118 
    119119[0-9A-Za-z]+          { 
    120                         yylval.stringval = strdup(yytext); 
     120                        yylval.stringval = xstrdup(yytext); 
    121121                        return STRING; 
    122122                      } 
  • trunk/source/config.y

    r66 r75  
    33  config.y - functions parsing the configuration file 
    44  
    5   (c) 1999-2000 Robert Cheramy <tibob@via.ecp.fr> 
     5  (c) 1999-2002 Robert Cheramy <robert@cheramy.net> 
    66  (c) 2000      Samuel Hocevar <sam@via.ecp.fr> 
    77  (c) 2001      Loïc Tortay & IN2P3 Computing Center <tortay@cc.in2p3.fr> 
     
    221221        } 
    222222      | Device EOL { 
     223          if (NULL != device) xfree(device); 
    223224          device = $1; 
    224225        } 
  • trunk/source/init.c

    r66 r75  
    44  (c) 1999      Andres Krapf <dae@via.ecp.fr> 
    55  (c) 2000      Samuel Hocevar <sam@via.ecp.fr> 
    6  
    7   200010xx : sam   : pid file & daemon mode handling 
    8   20001107 : tibob : SIGUSR1 handling 
    9   20001207 : tibob : modifications to have a correct SIGHUP behaviour. 
     6  (c) 2002      Robert Chéramy <robert@cheramy.net> 
     7 
     8  200010 : sam   : pid file & daemon mode handling 
     9  200011 : tibob : SIGUSR1 handling 
     10  200012 : tibob : modifications to have a correct SIGHUP behaviour. 
     11  200210 : tibob : command-line configurable pid file. 
     12   
    1013 */ 
    1114 
     
    7275#ifdef __OS_LINUX__ 
    7376  printf("\t-n, --nodaemon:\tdo not run as a daemon\n"); 
    74   printf("\t-c, --config <file>:\tspecify an alternate configuration file\n"); 
     77  printf("\t-c <file>, --config <file>:\tspecify an alternate configuration file\n"); 
    7578  printf("\t-h, --help:\tdisplay this help and exit\n"); 
     79  printf("\t-p <file>, --pid <file>:\tspecify an alternate pid file\n"); 
    7680#else 
    7781  printf("\t-n:\tdo not run as a daemon\n"); 
    7882  printf("\t-c <file>:\tspecify an alternate configuration file\n"); 
    7983  printf("\t-h:\tdisplay this help and exit\n"); 
     84  printf("\t-p <file>:\tspecify an alternate pid file\n"); 
    8085#endif /* __OS_LINUX__ */ 
    8186  printf("\nPlease report bugs to ipfm@via.ecp.fr\n"); 
     
    9499    { "help", 0, NULL, 0 }, 
    95100    { "nodaemon", 0, &run_as_daemon, 0 }, 
     101    { "pidfile", 1, NULL, 0 }, 
    96102    { NULL, 0, NULL, 0 } 
    97103  }; 
     
    99105         
    100106  Options.ConfigFile = NULL; 
    101  
    102 #ifdef __OS_LINUX__ 
    103   while (EOF != (ch = getopt_long(argc, argv, "hnc:", long_options, 
     107  Options.PidFile = NULL; 
     108 
     109#ifdef __OS_LINUX__ 
     110  while (EOF != (ch = getopt_long(argc, argv, "hncp:", long_options, 
    104111                                 &option_index))) { 
    105112#else 
    106   while (EOF != (ch = getopt(argc, argv, "hnc:"))) { 
     113  while (EOF != (ch = getopt(argc, argv, "hncp:"))) { 
    107114#endif /* __OS_LINUX__ */ 
    108115    switch(ch) {           
     
    110117    case 0: 
    111118      switch (option_index) { 
    112         case 0: 
    113           Options.ConfigFile = xstrdup(optarg); 
    114           break; 
    115         case 1: 
    116           print_help(); 
    117           exit(0); 
    118           break; 
    119     } 
     119      case 0: 
     120        Options.ConfigFile = xstrdup(optarg); 
     121        break; 
     122      case 1: 
     123        print_help(); 
     124        exit(0); 
     125        break; 
     126      case 2: 
     127        run_as_daemon = 0; 
     128        break; 
     129      case 3: 
     130        Options.PidFile = xstrdup(optarg); 
     131        break; 
     132      } 
     133      break; 
    120134#endif /* __OS_LINUX__ */ 
    121135    case 'c': 
     
    125139      run_as_daemon = 0; 
    126140      break; 
     141    case 'p': 
     142      Options.PidFile = xstrdup(optarg); 
     143      break; 
    127144    case 'h': 
    128145    case '?': 
     
    143160  if (NULL == Options.ConfigFile) { 
    144161    Options.ConfigFile = xstrdup(DEFAULT_OPTIONS_CONFIGFILE); 
     162  } 
     163  if (NULL == Options.PidFile) { 
     164    Options.PidFile = xstrdup(DEFAULT_OPTIONS_PIDFILE); 
    145165  } 
    146166} 
     
    234254 
    235255  if (run_as_daemon) { 
    236     remove_pid (PIDFILE); 
     256    remove_pid (Options.PidFile); 
    237257  } 
    238258 
  • trunk/source/init.h

    r63 r75  
    2727struct OptionsType { 
    2828  char *ConfigFile; 
     29  char *PidFile; 
    2930}; 
    3031 
  • trunk/source/ipfm.c

    r63 r75  
    55 ********************************************************************* 
    66 
    7  (c) 1999-2000 Robert Cheramy <tibob@via.ecp.fr> 
     7 (c) 1999-2002 Robert Cheramy <robert@cheramy.net> 
    88 (c) 2000      Samuel Hocevar <sam@via.ecp.fr> 
    99 (c) 1999      Andres Krapf <dae@via.ecp.fr> 
     
    1414 ********************************************************************* 
    1515 
    16  200010xx: sam & tibob : clear and dump options 
    17            sam : PID file & daemon mode handling 
     16 200010: sam & tibob : clear and dump options 
     17         sam : PID file & daemon mode handling 
     18 200210: tibob : configurable PID file 
    1819 
    1920 */ 
     
    5556#include "utils.h" 
    5657 
    57 // struct passwd *runas; 
    5858struct AllLogsType * pAllLogs = NULL; 
    5959extern int run_as_daemon; 
     60extern struct OptionsType Options; 
    6061 
    6162int main(int argc, char *argv[]) { 
     
    6970  if (run_as_daemon) { 
    7071    /* Check PID */ 
    71     if (check_pid(PIDFILE)) { 
     72    if (check_pid(Options.PidFile)) { 
    7273      printf ("Already running, exiting.\n"); 
    7374      exit (1); 
     
    8384 
    8485    /* Write PID file */ 
    85     if (!write_pid(PIDFILE)) { 
     86    if (!write_pid(Options.PidFile)) { 
    8687      exit (1); 
    8788    } 
    8889  } 
    8990   
    90   /* Disabled because I can't close the socket as nobody. 
    91      And I don't feel like using threads now :) 
    92   runas = getpwnam("nobody"); 
    93   setuid(runas->pw_uid); 
    94   */ 
    95  
    9691  for(;;) { 
    9792    p_packet = (struct ip *) getnextippkt();