Skip to content

Commit

Permalink
Update reload to exit if parseconfig fails
Browse files Browse the repository at this point in the history
I spotted that reload didn't exit when parseconfig failed and would continue to run with no knocks configured.

Updated the code to still close the logfile and exit if parseconfig fails.
  • Loading branch information
airwoflgh committed Nov 27, 2015
1 parent e566d49 commit 64230a1
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/knockd.c
Expand Up @@ -386,15 +386,21 @@ void reload(int signum)
}
list_free(doors);

parseconfig(o_cfg);

vprint("Closing and re-opening log file: %s\n", o_logfile);
logprint("Closing and re-opening log file: %s\n", o_logfile);
vprint("Closing log file: %s\n", o_logfile);
logprint("Closing log file: %s\n", o_logfile);

/* close and re-open the log file */
if(logfd) {
fclose(logfd);
}

if(parseconfig(o_cfg)) {
exit(1);
}

vprint("Re-opening log file: %s\n", o_logfile);
logprint("Re-opening log file: %s\n", o_logfile);

logfd = fopen(o_logfile, "a");
if(logfd == NULL) {
perror("warning: cannot open logfile");
Expand Down

2 comments on commit 64230a1

@airwoflgh
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the flow, does reload also need to make a call to generate_pcap_filter() after a successful config re-read to honour any updated ports in the changes?

@airwoflgh
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it does :) Have just spotted this bug report.

jvinet#2

Please sign in to comment.