From f06ae6fb2f2bb1bd2e8c6852e428abeb01503166 Mon Sep 17 00:00:00 2001 From: Matt Signorini Date: Fri, 28 Dec 2012 12:59:05 +1100 Subject: [PATCH] Renamed fcronlog in fcronconf.h to fcronlogfile, to avoid shadowing the function fcronlog. Modified convert-fcrontab to include fcronconf.o, to fix an undefined symbol issue with fcronlogfile. Also added code to parse a config file with read_conf, and an extra flag '-c' to specify a config file. Docs have not been updated in this commit. --- Makefile.in | 2 +- convert-fcrontab.c | 8 +++++++- convert-fcrontab.h | 3 +++ fcronconf.c | 4 ++-- fcronconf.h | 2 +- log.c | 12 ++++++------ 6 files changed, 20 insertions(+), 11 deletions(-) diff --git a/Makefile.in b/Makefile.in index 5bc938c..02f7163 100644 --- a/Makefile.in +++ b/Makefile.in @@ -77,7 +77,7 @@ endif OBJSD := fcron.o cl.o subs.o mem.o save.o temp_file.o log.o database.o job.o conf.o u_list.o exe_list.o lavg_list.o env_list.o fcronconf.o $(LIBOBJS) OBJSTAB := fcrontab.o cl.o subs.o mem.o save.o temp_file.o log.o fileconf.o allow.o read_string.o u_list.o env_list.o fcronconf.o OBJSDYN := fcrondyn.o subs.o mem.o log.o allow.o read_string.o fcronconf.o -OBJCONV := convert-fcrontab.o cl.o subs.o mem.o save.o log.o u_list.o env_list.o +OBJCONV := convert-fcrontab.o cl.o subs.o mem.o save.o log.o u_list.o env_list.o fcronconf.o OBJSIG := fcronsighup.o subs.o mem.o log.o allow.o fcronconf.o HEADERSALL := config.h $(SRCDIR)/global.h $(SRCDIR)/cl.h $(SRCDIR)/log.h $(SRCDIR)/subs.h $(SRCDIR)/mem.h $(SRCDIR)/save.h $(SRCDIR)/option.h $(SRCDIR)/dyncom.h diff --git a/convert-fcrontab.c b/convert-fcrontab.c index 8e9b148..c9414ea 100644 --- a/convert-fcrontab.c +++ b/convert-fcrontab.c @@ -244,7 +244,7 @@ main(int argc, char *argv[]) /* constants and variables defined by command line */ while(1) { - c = getopt(argc, argv, "hV"); + c = getopt(argc, argv, "chV"); if (c == EOF) break; switch (c) { @@ -254,6 +254,9 @@ main(int argc, char *argv[]) case 'h': usage(); break; + case 'c': + Set(fcronconf, optarg); break; + case ':': fprintf(stderr, "(setopt) Missing parameter"); usage(); @@ -269,6 +272,9 @@ main(int argc, char *argv[]) if (optind >= argc || argc != 2) usage(); + /* parse fcron.conf */ + read_conf(); + user_to_update = strdup2(argv[optind]); if (chdir(cdir) != 0) diff --git a/convert-fcrontab.h b/convert-fcrontab.h index 6881057..a06bf2a 100644 --- a/convert-fcrontab.h +++ b/convert-fcrontab.h @@ -30,6 +30,9 @@ #include "global.h" +/* needed for parsing a conf file */ +#include "fcronconf.h" + extern uid_t rootuid; extern gid_t rootgid; diff --git a/fcronconf.c b/fcronconf.c index 9250b01..1bf8c54 100644 --- a/fcronconf.c +++ b/fcronconf.c @@ -40,7 +40,7 @@ char *pidfile = NULL; char *fifofile = NULL; char *fcronallow = NULL; char *fcrondeny = NULL; -char *fcronlog = NULL; +char *fcronlogfile = NULL; char *shell = NULL; char *sendmail = NULL; char *editor = NULL; @@ -161,7 +161,7 @@ read_conf(void) else if ( strncmp(ptr1, "fifofile", namesize) == 0 ) { Set(fifofile , ptr2); } else if ( strncmp(ptr1, "fcronallow", namesize) == 0 ) { Set(fcronallow , ptr2); } else if ( strncmp(ptr1, "fcrondeny", namesize) == 0 ) { Set(fcrondeny , ptr2); } - else if ( strncmp(ptr1, "fcronlog", namesize) == 0 ) { Set(fcronlog, ptr2); } + else if ( strncmp(ptr1, "fcronlog", namesize) == 0 ) { Set(fcronlogfile, ptr2); } else if ( strncmp(ptr1, "shell", namesize) == 0 ) { Set(shell , ptr2); } else if ( strncmp(ptr1, "sendmail", namesize) == 0 ) { Set(sendmail , ptr2); } else if ( strncmp(ptr1, "editor", namesize) == 0 ) { Set(editor , ptr2); } diff --git a/fcronconf.h b/fcronconf.h index f1f19d7..fc06fe4 100644 --- a/fcronconf.h +++ b/fcronconf.h @@ -33,7 +33,7 @@ extern char *fcronconf; extern char *fcronallow; extern char *fcrondeny; extern char *fcrontabs; -extern char *fcronlog; +extern char *fcronlogfile; extern char *pidfile; extern char *fifofile; extern char *editor; diff --git a/log.c b/log.c index 944f7c0..69ee691 100644 --- a/log.c +++ b/log.c @@ -68,10 +68,10 @@ xopenlog(void) return; // are we using syslog? - if (dosyslog && (fcronlog == NULL)) { + if (dosyslog && (fcronlogfile == NULL)) { openlog(prog_name, LOG_PID, SYSLOG_FACILITY); - } else if (fcronlog != NULL) { - logfd = fopen(fcronlog, "a+"); + } else if (fcronlogfile != NULL) { + logfd = fopen(fcronlogfile, "a+"); } log_open = 1; @@ -85,9 +85,9 @@ xcloselog() return; // check whether we need to close syslog, or a file. - if (dosyslog && (fcronlog == NULL)) { + if (dosyslog && (fcronlogfile == NULL)) { closelog(); - } else if (fcronlog != NULL) { + } else if (fcronlogfile != NULL) { fclose(logfd); } @@ -205,7 +205,7 @@ fcronlog(int priority, char *msg) time_t t = time(NULL); struct tm *ft; char date[30]; - char type[30] + char *type; // print the current time as a string. ft = localtime(&t); -- 2.47.3