# HG changeset patch # User Carl Byington # Date 1527183345 25200 # Node ID 9298f8b00db21882e4bae57b56f900c40cc762e1 # Parent c6d5b1658f615aa2b59e883fa3176c17c762c148 patches from Takao Abe add switches for config and pid files diff -r c6d5b1658f61 -r 9298f8b00db2 AUTHORS --- a/AUTHORS Mon Feb 06 12:08:35 2017 -0800 +++ b/AUTHORS Thu May 24 10:35:45 2018 -0700 @@ -1,3 +1,4 @@ 510 Software Group Sergey Shapovalov Marco d'Itri +Takao Abe diff -r c6d5b1658f61 -r 9298f8b00db2 ChangeLog --- a/ChangeLog Mon Feb 06 12:08:35 2017 -0800 +++ b/ChangeLog Thu May 24 10:35:45 2018 -0700 @@ -1,3 +1,7 @@ +1.10 2018-05-24 + patches from Takao Abe to add command line switches for the + config and pid files. + 1.9 2017-02-06 changes for rhel7 systemd and /var/run on tmpfs diff -r c6d5b1658f61 -r 9298f8b00db2 Makefile.am --- a/Makefile.am Mon Feb 06 12:08:35 2017 -0800 +++ b/Makefile.am Thu May 24 10:35:45 2018 -0700 @@ -2,12 +2,12 @@ SUBDIRS = src man html info hackdir = $(sysconfdir)/sm-archive -hack_SCRIPTS = sm-archive sm-archive.service sm-archive-tmpfs.conf -hack_DATA = sm-archive.conf +hack_SCRIPTS = sm-archive sm-archive.service +hack_DATA = sm-archive.conf sm-archive-tmpfs.conf htmldir = ${datadir}/doc/@PACKAGE@-@VERSION@ html_DATA = AUTHORS COPYING ChangeLog NEWS README CLEANFILES = sm-archive.service sm-archive xml/sm-archive xml/Makefile -EXTRA_DIST = sm-archive-tmpfs.conf sm-archive.service.rc sm-archive.rc $(hack_DATA) sm-archive.spec $(wildcard m4/*) $(wildcard xml/h*) $(wildcard xml/M*) $(wildcard xml/sm*) +EXTRA_DIST = sm-archive.service.rc sm-archive.rc $(hack_DATA) sm-archive.spec $(wildcard m4/*) $(wildcard xml/h*) $(wildcard xml/M*) $(wildcard xml/sm*) sm-archive: sm-archive.rc cat $(srcdir)/sm-archive.rc | \ diff -r c6d5b1658f61 -r 9298f8b00db2 NEWS --- a/NEWS Mon Feb 06 12:08:35 2017 -0800 +++ b/NEWS Thu May 24 10:35:45 2018 -0700 @@ -1,3 +1,4 @@ +1.10 2018-05-24 patches from Takao Abe add switches for config and pid files 1.9 2017-02-06 changes for rhel7 systemd and /var/run on tmpfs 1.8 2010-12-24 patches from Marco d'Itri for postfix 1.7 2008-06-12 Fedora 9 compile and const correctness. diff -r c6d5b1658f61 -r 9298f8b00db2 configure.in --- a/configure.in Mon Feb 06 12:08:35 2017 -0800 +++ b/configure.in Thu May 24 10:35:45 2018 -0700 @@ -1,5 +1,5 @@ AC_PREREQ(2.59) -AC_INIT(sm-archive,1.9,carl@five-ten-sg.com) +AC_INIT(sm-archive,1.10,carl@five-ten-sg.com) AC_CONFIG_SRCDIR([config.h.in]) AC_CONFIG_HEADER([config.h]) diff -r c6d5b1658f61 -r 9298f8b00db2 sm-archive.spec.in --- a/sm-archive.spec.in Mon Feb 06 12:08:35 2017 -0800 +++ b/sm-archive.spec.in Thu May 24 10:35:45 2018 -0700 @@ -129,6 +129,10 @@ %changelog +* Thu May 24 2018 Carl Byington - 1.10-1 +- patches from Takao Abe to add command line switches for the + config and pid files. + * Mon Feb 06 2017 Carl Byington - 1.9-1 - enable rhel7 systemd and /var/run is on tmpfs diff -r c6d5b1658f61 -r 9298f8b00db2 src/sm-archive.cpp --- a/src/sm-archive.cpp Mon Feb 06 12:08:35 2017 -0800 +++ b/src/sm-archive.cpp Thu May 24 10:35:45 2018 -0700 @@ -56,7 +56,11 @@ void sig_chld(int signo); } +// command line options +const char *optionConfigFile = "sm-archive.conf" ; +const char *optionPidFile = "/var/run/sm-archive.pid" ; int debug_syslog = 0; +// bool syslog_opened = false; bool use_syslog = true; // false to printf bool loader_run = true; // used to stop the config loader thread @@ -293,7 +297,7 @@ snprintf(buf, sizeof(buf), "loading configuration generation %d", newc->generation); my_syslog(buf); } - if (load_conf(*newc, "sm-archive.conf")) { + if (load_conf(*newc, optionConfigFile)) { newc->load_time = time(NULL); return newc; } @@ -349,13 +353,15 @@ void usage(const char *prog); void usage(const char *prog) { - fprintf(stderr, "Usage: %s [-d [level]] [-c] -p sm-sock-addr [-t timeout]\n", prog); + fprintf(stderr, "Usage: %s [-d [level]] [-c] -p sm-sock-addr [-t timeout] [-C config-file] [-P pid-file]\n", prog); fprintf(stderr, "where sm-sock-addr is for the connection to sendmail\n"); fprintf(stderr, " and should be one of\n"); fprintf(stderr, " inet:port@ip-address\n"); fprintf(stderr, " local:local-domain-socket-file-name\n"); fprintf(stderr, "-c will load and dump the config to stdout\n"); fprintf(stderr, "-d will set the syslog message level, currently 0 to 3\n"); + fprintf(stderr, "-C specifies the config file, defaults to sm-archive.conf\n"); + fprintf(stderr, "-P specifies the pid file, defaults to /var/run/sm-archive.pid\n"); } @@ -393,7 +399,7 @@ bool check = false; bool setconn = false; int c; - const char *args = "p:t:d:ch"; + const char *args = "p:t:d:chC:P:"; extern char *optarg; // Process command line options @@ -433,6 +439,22 @@ else debug_syslog = atoi(optarg); break; + case 'C': + if (optarg == NULL || *optarg == '\0') { + fprintf( stderr, "Must specify the config file path: %s\n", optarg ); + exit(EX_USAGE); + } + optionConfigFile = optarg ; + break ; + + case 'P': + if (optarg == NULL || *optarg == '\0') { + fprintf( stderr, "Must specify the pid file path: %s\n", optarg ); + exit(EX_USAGE); + } + optionPidFile = optarg ; + break ; + case 'h': default: usage(argv[0]); @@ -473,7 +495,7 @@ } // write the pid - const char *pidpath = "/var/run/sm-archive.pid"; + const char *pidpath = optionPidFile; unlink(pidpath); FILE *f = fopen(pidpath, "w"); if (f) { diff -r c6d5b1658f61 -r 9298f8b00db2 xml/sm-archive.in --- a/xml/sm-archive.in Mon Feb 06 12:08:35 2017 -0800 +++ b/xml/sm-archive.in Thu May 24 10:35:45 2018 -0700 @@ -19,7 +19,7 @@ - 2008-03-21 + 2018-05-24 @@ -73,6 +73,18 @@ Set the timeout in seconds used for communication with sendmail. + + -C config-file + + Specify the config file, defaults to sm-archive.conf in the current directory. + + + + -P pid-file + + Specify the pid file, defaults to /var/run/sm-archive.pid + + @@ -178,7 +190,7 @@ - 2008-03-21 + 2018-05-24