]> granicus.if.org Git - fcron/commitdiff
Renamed fcronlog in fcronconf.h to fcronlogfile, to avoid shadowing the function...
authorMatt Signorini <matthew.signorini@gmail.com>
Fri, 28 Dec 2012 01:59:05 +0000 (12:59 +1100)
committerThibault Godouet <fcron@free.fr>
Mon, 31 Dec 2012 16:48:41 +0000 (16:48 +0000)
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
convert-fcrontab.c
convert-fcrontab.h
fcronconf.c
fcronconf.h
log.c

index 5bc938c97efe316a70717d122ecafe00016007b7..02f71630ada82812686366a1b40114299d516771 100644 (file)
@@ -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
 
index 8e9b148088d90fbb7ed6dde014fbc0675b4234c4..c9414eaee5e7d6412d3d47871ba80311f4ab927d 100644 (file)
@@ -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)
index 6881057c2c46d4d11a664e91fda70226bc566b65..a06bf2a41896527da162fa0d6d6b02a811999d62 100644 (file)
@@ -30,6 +30,9 @@
 
 #include "global.h"
 
+/* needed for parsing a conf file */
+#include "fcronconf.h"
+
 extern uid_t rootuid;
 extern gid_t rootgid;
 
index 9250b0183f7a930d326cc6cd2a77ef93c9d8ca5b..1bf8c54b5f555fbfc8374cec809598d3a9e73b4c 100644 (file)
@@ -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); }
index f1f19d7137d50642202bf39cc9d48e835694592b..fc06fe49c26218c79ac07add7e907563237ad83b 100644 (file)
@@ -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 944f7c05252050cf0523ca8fe21c025cda62538d..69ee6919a0dab8d1e4aaa34025748be36f399e44 100644 (file)
--- 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);