2 ******************************************************************************
6 * Author: Damien Stuart
8 * Purpose: Command-line and config file processing for fwknop server.
10 * Copyright 2010 Damien Stuart (dstuart@dstuart.org)
12 * License (GNU Public License):
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
29 ******************************************************************************
31 #include "fwknopd_common.h"
32 #include "config_init.h"
38 /* Check to see if an integer variable has a value that is within a
42 range_check(fko_srv_options_t *opts, char *var, char *val, int low, int high)
44 if (low > atoi(val) || high < atoi(val))
46 fprintf(stderr, "[*] var %s value '%s' not in the range %d-%d\n",
48 clean_exit(opts, NO_FW_CLEANUP, EXIT_FAILURE);
53 /* Take an index and a string value. malloc the space for the value
54 * and assign it to the array at the specified index.
57 set_config_entry(fko_srv_options_t *opts, const int var_ndx, const char *value)
61 /* Sanity check the index value.
63 if(var_ndx < 0 || var_ndx >= NUMBER_OF_CONFIG_ENTRIES)
65 fprintf(stderr, "Index value of %i is not valid\n", var_ndx);
66 clean_exit(opts, NO_FW_CLEANUP, EXIT_FAILURE);
69 /* If this particular entry was already set (i.e. not NULL), then
70 * assume it needs to be freed first.
72 if(opts->config[var_ndx] != NULL)
73 free(opts->config[var_ndx]);
75 /* If we are setting it to NULL, do it and be done.
79 opts->config[var_ndx] = NULL;
83 /* Otherwise, make the space we need and set it.
85 space_needed = strlen(value) + 1;
87 opts->config[var_ndx] = malloc(space_needed);
89 if(opts->config[var_ndx] == NULL)
91 fprintf(stderr, "*Fatal memory allocation error!\n");
92 clean_exit(opts, NO_FW_CLEANUP, EXIT_FAILURE);
95 strlcpy(opts->config[var_ndx], value, space_needed);
100 /* Given a config parameter name, return its index or -1 if not found.
103 config_entry_index(const fko_srv_options_t *opts, const char *var)
107 for(i=0; i<NUMBER_OF_CONFIG_ENTRIES; i++)
108 if(opts->config[i] != NULL && CONF_VAR_IS(var, config_map[i]))
114 /* Free the config memory
117 free_configs(fko_srv_options_t *opts)
121 free_acc_stanzas(opts);
123 for(i=0; i<NUMBER_OF_CONFIG_ENTRIES; i++)
124 if(opts->config[i] != NULL)
125 free(opts->config[i]);
129 validate_int_var_ranges(fko_srv_options_t *opts)
131 range_check(opts, "PCAP_LOOP_SLEEP", opts->config[CONF_PCAP_LOOP_SLEEP],
132 1, RCHK_MAX_PCAP_LOOP_SLEEP);
133 range_check(opts, "MAX_SPA_PACKET_AGE", opts->config[CONF_MAX_SPA_PACKET_AGE],
134 1, RCHK_MAX_SPA_PACKET_AGE);
135 range_check(opts, "MAX_SNIFF_BYTES", opts->config[CONF_MAX_SNIFF_BYTES],
136 1, RCHK_MAX_SNIFF_BYTES);
137 range_check(opts, "TCPSERV_PORT", opts->config[CONF_TCPSERV_PORT],
138 1, RCHK_MAX_TCPSERV_PORT);
141 range_check(opts, "IPFW_START_RULE_NUM", opts->config[CONF_IPFW_START_RULE_NUM],
142 0, RCHK_MAX_IPFW_START_RULE_NUM);
143 range_check(opts, "IPFW_MAX_RULES", opts->config[CONF_IPFW_MAX_RULES],
144 1, RCHK_MAX_IPFW_MAX_RULES);
145 range_check(opts, "IPFW_ACTIVE_SET_NUM", opts->config[CONF_IPFW_ACTIVE_SET_NUM],
146 0, RCHK_MAX_IPFW_SET_NUM);
147 range_check(opts, "IPFW_EXPIRE_SET_NUM", opts->config[CONF_IPFW_EXPIRE_SET_NUM],
148 0, RCHK_MAX_IPFW_SET_NUM);
149 range_check(opts, "IPFW_EXPIRE_PURGE_INTERVAL",
150 opts->config[CONF_IPFW_EXPIRE_PURGE_INTERVAL],
151 1, RCHK_MAX_IPFW_PURGE_INTERVAL);
153 /* Make sure the active and expire sets are not identical whenever
156 if((opts->config[CONF_IPFW_ACTIVE_SET_NUM] > 0
157 && opts->config[CONF_IPFW_EXPIRE_SET_NUM] > 0)
158 && (opts->config[CONF_IPFW_ACTIVE_SET_NUM]
159 == opts->config[CONF_IPFW_EXPIRE_SET_NUM]))
162 "[*] Cannot set identical ipfw active and expire sets.\n");
163 clean_exit(opts, NO_FW_CLEANUP, EXIT_FAILURE);
167 range_check(opts, "PF_EXPIRE_INTERVAL", opts->config[CONF_PF_EXPIRE_INTERVAL],
168 1, RCHK_MAX_PF_EXPIRE_INTERVAL);
170 #endif /* FIREWALL type */
175 /* Parse the config file...
178 parse_config_file(fko_srv_options_t *opts, const char *config_file)
181 unsigned int numLines = 0;
182 unsigned int i, good_ent;
185 char conf_line_buf[MAX_LINE_LEN] = {0};
186 char var[MAX_LINE_LEN] = {0};
187 char val[MAX_LINE_LEN] = {0};
188 char tmp1[MAX_LINE_LEN] = {0};
189 char tmp2[MAX_LINE_LEN] = {0};
193 /* First see if the config file exists. If it doesn't, complain
194 * and go on with program defaults.
196 if(stat(config_file, &st) != 0)
198 fprintf(stderr, "[*] Config file: '%s' was not found.\n",
200 clean_exit(opts, NO_FW_CLEANUP, EXIT_FAILURE);
203 if ((cfile_ptr = fopen(config_file, "r")) == NULL)
205 fprintf(stderr, "[*] Could not open config file: %s\n",
209 clean_exit(opts, NO_FW_CLEANUP, EXIT_FAILURE);
212 while ((fgets(conf_line_buf, MAX_LINE_LEN, cfile_ptr)) != NULL)
215 conf_line_buf[MAX_LINE_LEN-1] = '\0';
217 /* Get past comments and empty lines (note: we only look at the
220 if(IS_EMPTY_LINE(conf_line_buf[0]))
223 if(sscanf(conf_line_buf, "%s %[^;\n\r]", var, val) != 2)
226 "*Invalid config file entry in %s at line %i.\n - '%s'",
227 config_file, numLines, conf_line_buf
234 "CONF FILE: %s, LINE: %s\tVar: %s, Val: '%s'\n",
235 config_file, conf_line_buf, var, val
240 for(i=0; i<NUMBER_OF_CONFIG_ENTRIES; i++)
242 if(CONF_VAR_IS(config_map[i], var))
244 /* First check to see if we need to do a varable expansion
245 * on this value. Note: this only supports one expansion and
246 * only if the value starts with the variable.
250 if(sscanf((val+1), "%[A-Z_]%s", tmp1, tmp2))
252 if((cndx = config_entry_index(opts, tmp1)) >= 0)
254 strlcpy(val, opts->config[cndx], MAX_LINE_LEN);
255 strlcat(val, tmp2, MAX_LINE_LEN);
260 set_config_entry(opts, i, val);
268 "*Ignoring unknown configuration parameter: '%s' in %s\n",
278 /* Set defaults, and do sanity and bounds checks for the various options.
281 validate_options(fko_srv_options_t *opts)
283 char tmp_path[MAX_PATH_LEN];
285 /* If no conf dir is set in the config file, use the default.
287 if(opts->config[CONF_FWKNOP_CONF_DIR] == NULL)
288 set_config_entry(opts, CONF_FWKNOP_CONF_DIR, DEF_CONF_DIR);
290 /* If no access.conf path was specified on the command line or set in
291 * the config file, use the default.
293 if(opts->config[CONF_ACCESS_FILE] == NULL)
294 set_config_entry(opts, CONF_ACCESS_FILE, DEF_ACCESS_FILE);
296 /* If the pid and digest cache files where not set in the config file or
297 * via command-line, then grab the defaults. Start with RUN_DIR as the
298 * files may depend on that.
300 if(opts->config[CONF_FWKNOP_RUN_DIR] == NULL)
301 set_config_entry(opts, CONF_FWKNOP_RUN_DIR, DEF_RUN_DIR);
303 if(opts->config[CONF_FWKNOP_PID_FILE] == NULL)
305 strlcpy(tmp_path, opts->config[CONF_FWKNOP_RUN_DIR], MAX_PATH_LEN);
307 if(tmp_path[strlen(tmp_path)-1] != '/')
308 strlcat(tmp_path, "/", MAX_PATH_LEN);
310 strlcat(tmp_path, DEF_PID_FILENAME, MAX_PATH_LEN);
312 set_config_entry(opts, CONF_FWKNOP_PID_FILE, tmp_path);
316 if(opts->config[CONF_DIGEST_FILE] == NULL)
318 if(opts->config[CONF_DIGEST_DB_FILE] == NULL)
321 strlcpy(tmp_path, opts->config[CONF_FWKNOP_RUN_DIR], MAX_PATH_LEN);
323 if(tmp_path[strlen(tmp_path)-1] != '/')
324 strlcat(tmp_path, "/", MAX_PATH_LEN);
328 strlcat(tmp_path, DEF_DIGEST_CACHE_FILENAME, MAX_PATH_LEN);
329 set_config_entry(opts, CONF_DIGEST_FILE, tmp_path);
331 strlcat(tmp_path, DEF_DIGEST_CACHE_DB_FILENAME, MAX_PATH_LEN);
332 set_config_entry(opts, CONF_DIGEST_DB_FILE, tmp_path);
336 /* Set remaining require CONF_ vars if they are not already set. */
338 /* PCAP capture interface.
340 if(opts->config[CONF_PCAP_INTF] == NULL)
341 set_config_entry(opts, CONF_PCAP_INTF, DEF_INTERFACE);
343 /* PCAP Promiscuous mode.
345 if(opts->config[CONF_ENABLE_PCAP_PROMISC] == NULL)
346 set_config_entry(opts, CONF_ENABLE_PCAP_PROMISC,
347 DEF_ENABLE_PCAP_PROMISC);
349 /* The packet count argument to pcap_dispatch()
351 if(opts->config[CONF_PCAP_DISPATCH_COUNT] == NULL)
352 set_config_entry(opts, CONF_PCAP_DISPATCH_COUNT,
353 DEF_PCAP_DISPATCH_COUNT);
355 /* Microseconds to sleep between pcap loop iterations
357 if(opts->config[CONF_PCAP_LOOP_SLEEP] == NULL)
358 set_config_entry(opts, CONF_PCAP_LOOP_SLEEP,
359 DEF_PCAP_LOOP_SLEEP);
363 if(opts->config[CONF_PCAP_FILTER] == NULL)
364 set_config_entry(opts, CONF_PCAP_FILTER, DEF_PCAP_FILTER);
366 /* Enable SPA packet aging.
368 if(opts->config[CONF_ENABLE_SPA_PACKET_AGING] == NULL)
369 set_config_entry(opts, CONF_ENABLE_SPA_PACKET_AGING,
370 DEF_ENABLE_SPA_PACKET_AGING);
374 if(opts->config[CONF_MAX_SPA_PACKET_AGE] == NULL)
375 set_config_entry(opts, CONF_MAX_SPA_PACKET_AGE,
376 DEF_MAX_SPA_PACKET_AGE);
379 /* Enable digest persistence.
381 if(opts->config[CONF_ENABLE_DIGEST_PERSISTENCE] == NULL)
382 set_config_entry(opts, CONF_ENABLE_DIGEST_PERSISTENCE,
383 DEF_ENABLE_DIGEST_PERSISTENCE);
387 if(opts->config[CONF_MAX_SNIFF_BYTES] == NULL)
388 set_config_entry(opts, CONF_MAX_SNIFF_BYTES, DEF_MAX_SNIFF_BYTES);
390 #if FIREWALL_IPTABLES
391 /* Enable IPT forwarding.
393 if(opts->config[CONF_ENABLE_IPT_FORWARDING] == NULL)
394 set_config_entry(opts, CONF_ENABLE_IPT_FORWARDING,
395 DEF_ENABLE_IPT_FORWARDING);
397 /* Enable IPT local NAT.
399 if(opts->config[CONF_ENABLE_IPT_LOCAL_NAT] == NULL)
400 set_config_entry(opts, CONF_ENABLE_IPT_LOCAL_NAT,
401 DEF_ENABLE_IPT_LOCAL_NAT);
405 if(opts->config[CONF_ENABLE_IPT_SNAT] == NULL)
406 set_config_entry(opts, CONF_ENABLE_IPT_SNAT,
407 DEF_ENABLE_IPT_SNAT);
409 /* Enable IPT OUTPUT.
411 if(opts->config[CONF_ENABLE_IPT_OUTPUT] == NULL)
412 set_config_entry(opts, CONF_ENABLE_IPT_OUTPUT,
413 DEF_ENABLE_IPT_OUTPUT);
415 /* Flush IPT at init.
417 if(opts->config[CONF_FLUSH_IPT_AT_INIT] == NULL)
418 set_config_entry(opts, CONF_FLUSH_IPT_AT_INIT, DEF_FLUSH_IPT_AT_INIT);
420 /* Flush IPT at exit.
422 if(opts->config[CONF_FLUSH_IPT_AT_EXIT] == NULL)
423 set_config_entry(opts, CONF_FLUSH_IPT_AT_EXIT, DEF_FLUSH_IPT_AT_EXIT);
427 if(opts->config[CONF_IPT_INPUT_ACCESS] == NULL)
428 set_config_entry(opts, CONF_IPT_INPUT_ACCESS,
429 DEF_IPT_INPUT_ACCESS);
431 /* IPT output access.
433 if(opts->config[CONF_IPT_OUTPUT_ACCESS] == NULL)
434 set_config_entry(opts, CONF_IPT_OUTPUT_ACCESS,
435 DEF_IPT_OUTPUT_ACCESS);
437 /* IPT forward access.
439 if(opts->config[CONF_IPT_FORWARD_ACCESS] == NULL)
440 set_config_entry(opts, CONF_IPT_FORWARD_ACCESS,
441 DEF_IPT_FORWARD_ACCESS);
445 if(opts->config[CONF_IPT_DNAT_ACCESS] == NULL)
446 set_config_entry(opts, CONF_IPT_DNAT_ACCESS,
447 DEF_IPT_DNAT_ACCESS);
451 if(opts->config[CONF_IPT_SNAT_ACCESS] == NULL)
452 set_config_entry(opts, CONF_IPT_SNAT_ACCESS,
453 DEF_IPT_SNAT_ACCESS);
455 /* IPT masquerade access.
457 if(opts->config[CONF_IPT_MASQUERADE_ACCESS] == NULL)
458 set_config_entry(opts, CONF_IPT_MASQUERADE_ACCESS,
459 DEF_IPT_MASQUERADE_ACCESS);
463 /* Flush ipfw rules at init.
465 if(opts->config[CONF_FLUSH_IPFW_AT_INIT] == NULL)
466 set_config_entry(opts, CONF_FLUSH_IPFW_AT_INIT, DEF_FLUSH_IPFW_AT_INIT);
468 /* Flush ipfw rules at exit.
470 if(opts->config[CONF_FLUSH_IPFW_AT_EXIT] == NULL)
471 set_config_entry(opts, CONF_FLUSH_IPFW_AT_EXIT, DEF_FLUSH_IPFW_AT_EXIT);
473 /* Set IPFW start rule number.
475 if(opts->config[CONF_IPFW_START_RULE_NUM] == NULL)
476 set_config_entry(opts, CONF_IPFW_START_RULE_NUM,
477 DEF_IPFW_START_RULE_NUM);
479 /* Set IPFW max rules.
481 if(opts->config[CONF_IPFW_MAX_RULES] == NULL)
482 set_config_entry(opts, CONF_IPFW_MAX_RULES,
485 /* Set IPFW active set number.
487 if(opts->config[CONF_IPFW_ACTIVE_SET_NUM] == NULL)
488 set_config_entry(opts, CONF_IPFW_ACTIVE_SET_NUM,
489 DEF_IPFW_ACTIVE_SET_NUM);
491 /* Set IPFW expire set number.
493 if(opts->config[CONF_IPFW_EXPIRE_SET_NUM] == NULL)
494 set_config_entry(opts, CONF_IPFW_EXPIRE_SET_NUM,
495 DEF_IPFW_EXPIRE_SET_NUM);
497 /* Set IPFW Dynamic rule expiry interval.
499 if(opts->config[CONF_IPFW_EXPIRE_PURGE_INTERVAL] == NULL)
500 set_config_entry(opts, CONF_IPFW_EXPIRE_PURGE_INTERVAL,
501 DEF_IPFW_EXPIRE_PURGE_INTERVAL);
503 /* Set IPFW Dynamic rule expiry interval.
505 if(opts->config[CONF_IPFW_ADD_CHECK_STATE] == NULL)
506 set_config_entry(opts, CONF_IPFW_ADD_CHECK_STATE,
507 DEF_IPFW_ADD_CHECK_STATE);
510 /* Set PF anchor name
512 if(opts->config[CONF_PF_ANCHOR_NAME] == NULL)
513 set_config_entry(opts, CONF_PF_ANCHOR_NAME,
516 /* Set PF rule expiry interval.
518 if(opts->config[CONF_PF_EXPIRE_INTERVAL] == NULL)
519 set_config_entry(opts, CONF_PF_EXPIRE_INTERVAL,
520 DEF_PF_EXPIRE_INTERVAL);
523 /* --DSS Place-holder */
525 #endif /* FIREWALL type */
529 if(opts->config[CONF_GPG_HOME_DIR] == NULL)
530 set_config_entry(opts, CONF_GPG_HOME_DIR, DEF_GPG_HOME_DIR);
532 /* Enable SPA over HTTP.
534 if(opts->config[CONF_ENABLE_SPA_OVER_HTTP] == NULL)
535 set_config_entry(opts, CONF_ENABLE_SPA_OVER_HTTP,
536 DEF_ENABLE_SPA_OVER_HTTP);
538 /* Enable TCP server.
540 if(opts->config[CONF_ENABLE_TCP_SERVER] == NULL)
541 set_config_entry(opts, CONF_ENABLE_TCP_SERVER, DEF_ENABLE_TCP_SERVER);
545 if(opts->config[CONF_TCPSERV_PORT] == NULL)
546 set_config_entry(opts, CONF_TCPSERV_PORT, DEF_TCPSERV_PORT);
550 if(opts->config[CONF_SYSLOG_IDENTITY] == NULL)
551 set_config_entry(opts, CONF_SYSLOG_IDENTITY, DEF_SYSLOG_IDENTITY);
555 if(opts->config[CONF_SYSLOG_FACILITY] == NULL)
556 set_config_entry(opts, CONF_SYSLOG_FACILITY, DEF_SYSLOG_FACILITY);
559 /* Validate integer variable ranges
561 validate_int_var_ranges(opts);
563 /* Some options just trigger some output of information, or trigger an
564 * external function, but do not actually start fwknopd. If any of those
565 * are set, we can return here an skip the validation routines as all
566 * other options will be ignored anyway.
568 * These are also mutually exclusive (for now).
570 if((opts->dump_config + opts->kill + opts->restart + opts->status) == 1)
573 if((opts->dump_config + opts->kill + opts->restart + opts->status) > 1)
576 "The -D, -K, -R, and -S options are mutually exclusive. Pick only one.\n"
578 clean_exit(opts, NO_FW_CLEANUP, EXIT_FAILURE);
581 if(opts->config[CONF_FIREWALL_EXE] == NULL)
584 "No firewall command executable is set. Please check FIREWALL_EXE in fwknopd.conf.\n"
586 clean_exit(opts, NO_FW_CLEANUP, EXIT_FAILURE);
593 set_preconfig_entries(fko_srv_options_t *opts)
595 /* First, set any default or otherwise static settings here. Some may
596 * end up being overwritten via config file or command-line.
599 /* Setup the firewall executable based on build-time info.
600 * --DSS Note: We will want to either force external script mode, or
601 * error out if we do not have a firewall executable defined.
604 set_config_entry(opts, CONF_FIREWALL_EXE, FIREWALL_EXE);
609 /* Initialize program configuration via config file and/or command-line
613 config_init(fko_srv_options_t *opts, int argc, char **argv)
616 unsigned char got_conf_file = 0, got_override_config = 0;
618 char override_file[MAX_LINE_LEN];
621 /* Zero out options and opts_track.
623 memset(opts, 0x00, sizeof(fko_srv_options_t));
625 /* Set some preconfiguration options (i.e. build-time defaults)
627 set_preconfig_entries(opts);
629 /* In case this is a re-config.
633 /* First, scan the command-line args for -h/--help or an alternate
634 * configuration file. If we find an alternate config file, use it,
635 * otherwise use the default. We also grab any override config files
638 while ((cmd_arg = getopt_long(argc, argv,
639 GETOPTS_OPTION_STRING, cmd_opts, &index)) != -1) {
641 /* If help is wanted, give it and exit.
646 clean_exit(opts, NO_FW_CLEANUP, EXIT_SUCCESS);
649 /* Look for configuration file arg.
652 set_config_entry(opts, CONF_CONFIG_FILE, optarg);
655 /* If we already have the config_override option, we are done.
657 if(got_override_config > 0)
660 /* Look for override configuration file arg.
663 set_config_entry(opts, CONF_OVERRIDE_CONFIG, optarg);
664 got_override_config++;
666 /* If we already have the conf_file option, we are done.
668 if(got_conf_file > 0)
673 /* If no alternate configuration file was specified, we use the
676 if(opts->config[CONF_CONFIG_FILE] == NULL)
677 set_config_entry(opts, CONF_CONFIG_FILE, DEF_CONFIG_FILE);
679 /* Parse configuration file to populate any params not already specified
680 * via command-line options.
682 parse_config_file(opts, opts->config[CONF_CONFIG_FILE]);
684 /* If there are override configuration entries, process them
687 if(opts->config[CONF_OVERRIDE_CONFIG] != NULL)
689 /* Make a copy of the override_config string so we can munge it.
691 strlcpy(override_file, opts->config[CONF_OVERRIDE_CONFIG], MAX_LINE_LEN);
694 cmrk = strchr(ndx, ',');
698 /* Only one to process...
700 parse_config_file(opts, ndx);
703 /* Walk the string pulling the next config override
704 * at the comma delimiters.
706 while(cmrk != NULL) {
708 parse_config_file(opts, ndx);
710 cmrk = strchr(ndx, ',');
713 /* Process the last entry
715 parse_config_file(opts, ndx);
719 /* Reset the options index so we can run through them again.
723 /* Last, but not least, we process command-line options (some of which
724 * may override configuration file options.
726 while ((cmd_arg = getopt_long(argc, argv,
727 GETOPTS_OPTION_STRING, cmd_opts, &index)) != -1) {
731 set_config_entry(opts, CONF_ACCESS_FILE, optarg);
734 /* This was handled earlier */
737 opts->packet_ctr_limit = atoi(optarg);
741 set_config_entry(opts, CONF_DIGEST_FILE, optarg);
743 set_config_entry(opts, CONF_DIGEST_DB_FILE, optarg);
747 opts->dump_config = 1;
750 opts->foreground = 1;
757 opts->fw_list_all = 1;
763 if (is_valid_dir(optarg))
765 set_config_entry(opts, CONF_GPG_HOME_DIR, optarg);
770 "[*] Directory '%s' could not stat()/does not exist?\n",
772 clean_exit(opts, NO_FW_CLEANUP, EXIT_FAILURE);
776 set_config_entry(opts, CONF_PCAP_INTF, optarg);
782 set_config_entry(opts, CONF_LOCALE, optarg);
785 /* This was handled earlier */
788 set_config_entry(opts, CONF_FWKNOP_PID_FILE, optarg);
791 set_config_entry(opts, CONF_PCAP_FILTER, optarg);
793 case ROTATE_DIGEST_CACHE:
794 opts->rotate_digest_cache = 1;
806 fprintf(stdout, "fwknopd server %s\n", MY_VERSION);
807 clean_exit(opts, NO_FW_CLEANUP, EXIT_SUCCESS);
811 clean_exit(opts, NO_FW_CLEANUP, EXIT_FAILURE);
815 /* Now that we have all of our options set, and we are actually going to
816 * start fwknopd, we can validate them.
818 validate_options(opts);
823 /* Dump the configuration
826 dump_config(const fko_srv_options_t *opts)
830 fprintf(stdout, "Current fwknopd config settings:\n");
832 for(i=0; i<NUMBER_OF_CONFIG_ENTRIES; i++)
833 fprintf(stdout, "%3i. %-28s = '%s'\n",
836 (opts->config[i] == NULL) ? "<not set>" : opts->config[i]
839 fprintf(stdout, "\n");
843 /* Print usage message...
848 fprintf(stdout, "\n%s server version %s\n%s\n\n", MY_NAME, MY_VERSION, MY_DESC);
850 "Usage: fwknopd [options]\n\n"
851 " -h, --help - Print this usage message and exit.\n"
852 " -a, --access-file - Specify an alternate access.conf file.\n"
853 " -c, --config-file - Specify an alternate configuration file.\n"
854 " -C, --packet-limit - Limit the number of candidate SPA packets to\n"
855 " process and exit when this limit is reached.\n"
856 " -d, --digest-file - Specify an alternate digest.cache file.\n"
857 " -D, --dump-config - Dump the current fwknop configuration values.\n"
858 " -f, --foreground - Run fwknopd in the foreground (do not become\n"
859 " a background daemon).\n"
860 " -i, --interface - Specify interface to listen for incoming SPA\n"
862 " -K, --kill - Kill the currently running fwknopd.\n"
863 " --gpg-home-dir - Specify the GPG home directory.\n"
864 " -l, --locale - Provide a locale setting other than the system\n"
866 " -O, --override-config - Specify a file with configuration entries that will\n"
867 " overide those in fwknopd.conf\n"
868 " -p, --pid-file - Specify an alternate fwknopd.pid file.\n"
869 " -P, --pcap-filter - Specify a Berkeley packet filter statement to\n"
870 " override the PCAP_FILTER variable in fwknopd.conf.\n"
871 " -R, --restart - Force the currently running fwknopd to restart.\n"
872 " --rotate-digest-cache\n"
873 " - Rotate the digest cache file by renaming it to\n"
874 " '<name>-old', and starting a new one.\n"
875 " -S, --status - Display the status of any running fwknopd process.\n"
876 " -v, --verbose - Set verbose mode.\n"
877 " -V, --version - Print version number.\n"
878 " --fw-list - List all firewall rules that fwknop has created\n"
880 " --fw-list-all - List all firewall rules in the complete policy,\n"
881 " including those that have nothing to do with\n"
883 " --fw-flush - Flush all firewall rules created by fwknop.\n"