2 ******************************************************************************
6 * Author: Damien Stuart
8 * Purpose: Access.conf 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 ******************************************************************************
34 #include <sys/socket.h>
37 #include "fwknopd_common.h"
38 #include <arpa/inet.h>
44 /* Add an access string entry
47 add_acc_string(char **var, const char *val)
52 if((*var = strdup(val)) == NULL)
55 "Fatal memory allocation error adding access list entry: %s", var
61 /* Add an access int entry
64 add_acc_int(int *var, const char *val)
66 return(*var = atoi(val));
69 /* Add an access bool entry (unsigned char of 1 or 0)
72 add_acc_bool(unsigned char *var, const char *val)
74 return(*var = (strncasecmp(val, "Y", 1) == 0) ? 1 : 0);
77 /* Add expiration time - convert date to epoch seconds
80 add_acc_expire_time(fko_srv_options_t *opts, time_t *access_expire_time, const char *val)
84 memset(&tm, 0, sizeof(struct tm));
86 if (sscanf(val, "%2d/%2d/%4d", &tm.tm_mon, &tm.tm_mday, &tm.tm_year) != 3)
90 "Fatal: invalid date value '%s' (need MM/DD/YYYY) for access stanza expiration time",
93 clean_exit(opts, NO_FW_CLEANUP, EXIT_FAILURE);
97 tm.tm_mon -= 1; /* 0-11 */
99 /* number of years since 1900
101 if(tm.tm_year > 1900)
107 *access_expire_time = mktime(&tm);
112 /* Add expiration time via epoch seconds defined in access.conf
115 add_acc_expire_time_epoch(fko_srv_options_t *opts, time_t *access_expire_time, const char *val)
118 unsigned long expire_time = 0;
122 expire_time = (time_t) strtoul(val, &endptr, 10);
124 if (errno == ERANGE || (errno != 0 && expire_time == 0))
127 "Fatal: invalid epoch seconds value '%s' for access stanza expiration time",
130 clean_exit(opts, NO_FW_CLEANUP, EXIT_FAILURE);
133 *access_expire_time = (time_t) expire_time;
138 #if FIREWALL_IPTABLES
140 add_acc_force_nat(fko_srv_options_t *opts, acc_stanza_t *curr_acc, const char *val)
142 char ip_str[MAX_IPV4_STR_LEN] = {0};
144 if (sscanf(val, "%15s %5u", ip_str, &curr_acc->force_nat_port) != 2)
148 "Fatal: invalid FORCE_NAT arg '%s', need <IP> <PORT>",
151 clean_exit(opts, NO_FW_CLEANUP, EXIT_FAILURE);
154 if (curr_acc->force_nat_port > MAX_PORT)
157 "Fatal: invalid FORCE_NAT port '%d'", curr_acc->force_nat_port);
158 clean_exit(opts, NO_FW_CLEANUP, EXIT_FAILURE);
161 curr_acc->force_nat = 1;
162 add_acc_string(&(curr_acc->force_nat_ip), ip_str);
168 /* Take an IP or Subnet/Mask and convert it to mask for later
169 * comparisons of incoming source IPs against this mask.
172 add_source_mask(acc_stanza_t *acc, const char *ip)
175 char ip_str[MAX_IPV4_STR_LEN] = {0};
180 acc_int_list_t *last_sle, *new_sle, *tmp_sle;
182 if((new_sle = calloc(1, sizeof(acc_int_list_t))) == NULL)
185 "Fatal memory allocation error adding stanza source_list entry"
190 /* If this is not the first entry, we walk our pointer to the
193 if(acc->source_list == NULL)
195 acc->source_list = new_sle;
199 tmp_sle = acc->source_list;
203 } while((tmp_sle = tmp_sle->next));
205 last_sle->next = new_sle;
208 /* Convert the IP data into the appropriate mask
210 if(strcasecmp(ip, "ANY") == 0)
212 new_sle->maddr = 0x0;
217 /* See if we have a subnet component. If so pull out the IP and
218 * mask values, then create the final mask value.
220 if((ndx = strchr(ip, '/')) != NULL)
223 strlcpy(ip_str, ip, (ndx-ip)+1);
228 strlcpy(ip_str, ip, strlen(ip)+1);
231 if(inet_aton(ip_str, &in) == 0)
234 "Error parsing IP to int for: %s", ip_str
243 /* Store our mask converted from CIDR to a 32-bit value.
245 new_sle->mask = (0xFFFFFFFF << (32 - mask));
247 /* Store our masked address for comparisons with future incoming
250 new_sle->maddr = ntohl(in.s_addr) & new_sle->mask;
254 /* Expand the access SOURCE string to a list of masks.
257 expand_acc_source(acc_stanza_t *acc)
264 for(ndx = start; *ndx; ndx++)
268 /* Skip over any leading whitespace.
270 while(isspace(*start))
273 strlcpy(buf, start, (ndx-start)+1);
274 add_source_mask(acc, buf);
279 /* Skip over any leading whitespace (once again for the last in the list).
281 while(isspace(*start))
284 strlcpy(buf, start, (ndx-start)+1);
285 add_source_mask(acc, buf);
289 parse_proto_and_port(char *pstr, int *proto, int *port)
294 /* Parse the string into its components.
296 if((ndx = strchr(pstr, '/')) == NULL)
299 "Parse error on access port entry: %s", pstr);
304 strlcpy(proto_str, pstr, (ndx - pstr)+1);
308 if(strcasecmp(proto_str, "tcp") == 0)
310 else if(strcasecmp(proto_str, "udp") == 0)
315 "Invalid protocol in access port entry: %s", pstr);
323 /* Take a proto/port string and convert it to appropriate integer values
324 * for comparisons of incoming SPA requests.
327 add_port_list_ent(acc_port_list_t **plist, char *port_str)
331 acc_port_list_t *last_plist, *new_plist, *tmp_plist;
333 /* Parse the string into its components and continue only if there
334 * are no problems with the incoming string.
336 if(parse_proto_and_port(port_str, &proto_int, &port) != 0)
339 if((new_plist = calloc(1, sizeof(acc_port_list_t))) == NULL)
342 "Fatal memory allocation error adding stanza source_list entry"
347 /* If this is not the first entry, we walk our pointer to the
359 last_plist = tmp_plist;
360 } while((tmp_plist = tmp_plist->next));
362 last_plist->next = new_plist;
365 new_plist->proto = proto_int;
366 new_plist->port = port;
369 /* Add a string list entry to the given acc_string_list.
372 add_string_list_ent(acc_string_list_t **stlist, const char *str_str)
374 acc_string_list_t *last_stlist, *new_stlist, *tmp_stlist;
376 if((new_stlist = calloc(1, sizeof(acc_string_list_t))) == NULL)
379 "Fatal memory allocation error creating string list entry"
384 /* If this is not the first entry, we walk our pointer to the
389 *stlist = new_stlist;
393 tmp_stlist = *stlist;
396 last_stlist = tmp_stlist;
397 } while((tmp_stlist = tmp_stlist->next));
399 last_stlist->next = new_stlist;
402 if(new_stlist->str != NULL)
403 free(new_stlist->str);
405 new_stlist->str = strdup(str_str);
407 if(new_stlist->str == NULL)
410 "Fatal memory allocation error adding string list entry item"
417 /* Expand a proto/port access string to a list of access proto-port struct.
420 expand_acc_port_list(acc_port_list_t **plist, char *plist_str)
427 for(ndx = start; *ndx; ndx++)
431 /* Skip over any leading whitespace.
433 while(isspace(*start))
436 strlcpy(buf, start, (ndx-start)+1);
437 add_port_list_ent(plist, buf);
442 /* Skip over any leading whitespace (once again for the last in the list).
444 while(isspace(*start))
447 strlcpy(buf, start, (ndx-start)+1);
449 add_port_list_ent(plist, buf);
452 /* Expand a comma-separated string into a simple acc_string_list.
455 expand_acc_string_list(acc_string_list_t **stlist, char *stlist_str)
462 for(ndx = start; *ndx; ndx++)
466 /* Skip over any leading whitespace.
468 while(isspace(*start))
471 strlcpy(buf, start, (ndx-start)+1);
472 add_string_list_ent(stlist, buf);
477 /* Skip over any leading whitespace (once again for the last in the list).
479 while(isspace(*start))
482 strlcpy(buf, start, (ndx-start)+1);
484 add_string_list_ent(stlist, buf);
487 /* Free the acc source_list
490 free_acc_source_list(acc_int_list_t *sle)
492 acc_int_list_t *last_sle;
497 sle = last_sle->next;
506 free_acc_port_list(acc_port_list_t *ple)
508 acc_port_list_t *last_ple;
513 ple = last_ple->next;
519 /* Free a string_list
522 free_acc_string_list(acc_string_list_t *stl)
524 acc_string_list_t *last_stl;
529 stl = last_stl->next;
536 /* Free any allocated content of an access stanza.
538 * NOTE: If a new access.conf parameter is created, and it is a string
539 * value, it also needs to be added to the list of items to check
543 free_acc_stanza_data(acc_stanza_t *acc)
546 if(acc->source != NULL)
549 free_acc_source_list(acc->source_list);
552 if(acc->open_ports != NULL)
554 free(acc->open_ports);
555 free_acc_port_list(acc->oport_list);
558 if(acc->restrict_ports != NULL)
560 free(acc->restrict_ports);
561 free_acc_port_list(acc->rport_list);
564 if(acc->force_nat_ip != NULL)
565 free(acc->force_nat_ip);
570 if(acc->cmd_exec_user != NULL)
571 free(acc->cmd_exec_user);
573 if(acc->require_username != NULL)
574 free(acc->require_username);
576 if(acc->gpg_home_dir != NULL)
577 free(acc->gpg_home_dir);
579 if(acc->gpg_decrypt_id != NULL)
580 free(acc->gpg_decrypt_id);
582 if(acc->gpg_decrypt_pw != NULL)
583 free(acc->gpg_decrypt_pw);
585 if(acc->gpg_remote_id != NULL)
587 free(acc->gpg_remote_id);
588 free_acc_string_list(acc->gpg_remote_id_list);
592 /* Expand any access entries that may be multi-value.
595 expand_acc_ent_lists(fko_srv_options_t *opts)
597 acc_stanza_t *acc = opts->acc_stanzas;
599 /* We need to do this for each stanza.
603 /* Expand the source string to 32-bit integer masks foreach entry.
605 expand_acc_source(acc);
607 /* Now expand the open_ports string.
609 if(acc->open_ports != NULL && strlen(acc->open_ports))
610 expand_acc_port_list(&(acc->oport_list), acc->open_ports);
612 if(acc->restrict_ports != NULL && strlen(acc->restrict_ports))
613 expand_acc_port_list(&(acc->rport_list), acc->restrict_ports);
615 /* Expand the GPG_REMOTE_ID string.
617 if(acc->gpg_remote_id != NULL && strlen(acc->gpg_remote_id))
618 expand_acc_string_list(&(acc->gpg_remote_id_list), acc->gpg_remote_id);
625 free_acc_stanzas(fko_srv_options_t *opts)
627 acc_stanza_t *acc, *last_acc;
629 /* Free any resources first (in case of reconfig). Assume non-NULL
630 * entry needs to be freed.
632 acc = opts->acc_stanzas;
637 acc = last_acc->next;
639 free_acc_stanza_data(last_acc);
646 /* Wrapper for free_acc_stanzas(), we may put additional initialization
650 acc_stanza_init(fko_srv_options_t *opts)
652 /* Free any resources first (in case of reconfig). Assume non-NULL
653 * entry needs to be freed.
655 free_acc_stanzas(opts);
660 /* Add a new stanza bay allocating the required memory at the required
661 * location, yada-yada-yada.
664 acc_stanza_add(fko_srv_options_t *opts)
666 acc_stanza_t *acc = opts->acc_stanzas;
667 acc_stanza_t *new_acc = calloc(1, sizeof(acc_stanza_t));
668 acc_stanza_t *last_acc;
673 "Fatal memory allocation error adding access stanza"
675 clean_exit(opts, NO_FW_CLEANUP, EXIT_FAILURE);
678 /* If this is not the first acc entry, we walk our acc pointer to the
679 * end of the existing list.
683 opts->acc_stanzas = new_acc;
689 } while((acc = acc->next));
691 last_acc->next = new_acc;
697 /* Scan the access options for entries that have not bees set, but need
701 set_acc_defaults(fko_srv_options_t *opts)
703 acc_stanza_t *acc = opts->acc_stanzas;
710 /* set default fw_access_timeout if necessary
712 if(acc->fw_access_timeout < 1)
713 acc->fw_access_timeout = DEF_FW_ACCESS_TIMEOUT;
715 /* set default gpg keyring path if necessary
717 if(acc->gpg_decrypt_pw != NULL && acc->gpg_home_dir == NULL)
718 add_acc_string(&(acc->gpg_home_dir), opts->config[CONF_GPG_HOME_DIR]);
724 /* Perform some sanity checks on an acc stanza data.
727 acc_data_is_valid(const acc_stanza_t *acc)
729 if((acc->key == NULL || !strlen(acc->key))
730 && (acc->gpg_decrypt_pw == NULL || !strlen(acc->gpg_decrypt_pw)))
733 "[*] No keys found for access stanza source: '%s'\n", acc->source
741 /* Read and parse the access file, popluating the access data as we go.
744 parse_access_file(fko_srv_options_t *opts)
749 unsigned int num_lines = 0;
751 char access_line_buf[MAX_LINE_LEN] = {0};
752 char var[MAX_LINE_LEN] = {0};
753 char val[MAX_LINE_LEN] = {0};
758 acc_stanza_t *curr_acc = NULL;
760 /* First see if the access file exists. If it doesn't, complain
763 if(stat(opts->config[CONF_ACCESS_FILE], &st) != 0)
765 fprintf(stderr, "[*] Access file: '%s' was not found.\n",
766 opts->config[CONF_ACCESS_FILE]);
768 clean_exit(opts, NO_FW_CLEANUP, EXIT_FAILURE);
771 if ((file_ptr = fopen(opts->config[CONF_ACCESS_FILE], "r")) == NULL)
773 fprintf(stderr, "[*] Could not open access file: %s\n",
774 opts->config[CONF_ACCESS_FILE]);
777 clean_exit(opts, NO_FW_CLEANUP, EXIT_FAILURE);
780 /* Initialize the access list.
782 acc_stanza_init(opts);
784 /* Now walk through access file pulling the access entries into the
787 while ((fgets(access_line_buf, MAX_LINE_LEN, file_ptr)) != NULL)
790 access_line_buf[MAX_LINE_LEN-1] = '\0';
792 /* Get past comments and empty lines (note: we only look at the
795 if(IS_EMPTY_LINE(access_line_buf[0]))
798 if(sscanf(access_line_buf, "%s %[^;\n\r]", var, val) != 2)
801 "*Invalid access file entry in %s at line %i.\n - '%s'",
802 opts->config[CONF_ACCESS_FILE], num_lines, access_line_buf
807 /* Remove any colon that may be on the end of the var
809 if((ndx = strrchr(var, ':')) != NULL)
814 if(opts->verbose > 3)
816 "ACCESS FILE: %s, LINE: %s\tVar: %s, Val: '%s'\n",
817 opts->config[CONF_ACCESS_FILE], access_line_buf, var, val
820 /* Process the entry.
822 * NOTE: If a new access.conf parameter is created. It also needs
823 * to be accounted for in the following if/if else construct.
826 if(CONF_VAR_IS(var, "SOURCE"))
828 /* If this is not the first stanza, sanity check the previous
829 * stanza for the minimum required data.
831 if(curr_acc != NULL) {
832 if(!acc_data_is_valid(curr_acc))
835 "[*] Data error in access file: '%s'\n",
836 opts->config[CONF_ACCESS_FILE]);
837 clean_exit(opts, NO_FW_CLEANUP, EXIT_FAILURE);
843 curr_acc = acc_stanza_add(opts);
845 add_acc_string(&(curr_acc->source), val);
849 else if (curr_acc == NULL)
851 /* The stanza must start with the "SOURCE" variable
855 else if(CONF_VAR_IS(var, "OPEN_PORTS"))
857 add_acc_string(&(curr_acc->open_ports), val);
859 else if(CONF_VAR_IS(var, "RESTRICT_PORTS"))
861 add_acc_string(&(curr_acc->restrict_ports), val);
863 else if(CONF_VAR_IS(var, "KEY"))
865 if(strcasecmp(val, "__CHANGEME__") == 0)
868 "[*] KEY value is not properly set in stanza source '%s' in access file: '%s'\n",
869 curr_acc->source, opts->config[CONF_ACCESS_FILE]);
870 clean_exit(opts, NO_FW_CLEANUP, EXIT_FAILURE);
872 add_acc_string(&(curr_acc->key), val);
874 else if(CONF_VAR_IS(var, "FW_ACCESS_TIMEOUT"))
876 add_acc_int(&(curr_acc->fw_access_timeout), val);
878 else if(CONF_VAR_IS(var, "ENABLE_CMD_EXEC"))
880 add_acc_bool(&(curr_acc->enable_cmd_exec), val);
882 else if(CONF_VAR_IS(var, "CMD_EXEC_USER"))
884 add_acc_string(&(curr_acc->cmd_exec_user), val);
891 fprintf(stderr, "Unable to determine UID for CMD_EXEC_USER: %s.\n",
892 errno ? strerror(errno) : "Not a user on this system");
893 clean_exit(opts, NO_FW_CLEANUP, EXIT_FAILURE);
896 curr_acc->cmd_exec_uid = pw->pw_uid;
898 else if(CONF_VAR_IS(var, "REQUIRE_USERNAME"))
900 add_acc_string(&(curr_acc->require_username), val);
902 else if(CONF_VAR_IS(var, "REQUIRE_SOURCE_ADDRESS"))
904 add_acc_bool(&(curr_acc->require_source_address), val);
906 else if(CONF_VAR_IS(var, "REQUIRE_SOURCE")) /* synonym for REQUIRE_SOURCE_ADDRESS */
908 add_acc_bool(&(curr_acc->require_source_address), val);
910 else if(CONF_VAR_IS(var, "GPG_HOME_DIR"))
912 if (is_valid_dir(val))
914 add_acc_string(&(curr_acc->gpg_home_dir), val);
919 "[*] GPG_HOME_DIR directory '%s' stat()/existence problem in stanza source '%s' in access file: '%s'\n",
920 val, curr_acc->source, opts->config[CONF_ACCESS_FILE]);
921 clean_exit(opts, NO_FW_CLEANUP, EXIT_FAILURE);
924 else if(CONF_VAR_IS(var, "GPG_DECRYPT_ID"))
926 add_acc_string(&(curr_acc->gpg_decrypt_id), val);
928 else if(CONF_VAR_IS(var, "GPG_DECRYPT_PW"))
930 if(strcasecmp(val, "__CHANGEME__") == 0)
933 "[*] GPG_DECRYPT_PW value is not properly set in stanza source '%s' in access file: '%s'\n",
934 curr_acc->source, opts->config[CONF_ACCESS_FILE]);
935 clean_exit(opts, NO_FW_CLEANUP, EXIT_FAILURE);
937 add_acc_string(&(curr_acc->gpg_decrypt_pw), val);
939 else if(CONF_VAR_IS(var, "GPG_ALLOW_NO_PW"))
941 if(curr_acc->gpg_decrypt_pw != NULL && curr_acc->gpg_decrypt_pw[0] != '\0')
942 free(curr_acc->gpg_decrypt_pw);
944 add_acc_string(&(curr_acc->gpg_decrypt_pw), "");
946 else if(CONF_VAR_IS(var, "GPG_REQUIRE_SIG"))
948 add_acc_bool(&(curr_acc->gpg_require_sig), val);
950 else if(CONF_VAR_IS(var, "GPG_IGNORE_SIG_VERIFY_ERROR"))
952 add_acc_bool(&(curr_acc->gpg_ignore_sig_error), val);
954 else if(CONF_VAR_IS(var, "GPG_REMOTE_ID"))
956 add_acc_string(&(curr_acc->gpg_remote_id), val);
958 else if(CONF_VAR_IS(var, "ACCESS_EXPIRE"))
960 add_acc_expire_time(opts, &(curr_acc->access_expire_time), val);
962 else if(CONF_VAR_IS(var, "ACCESS_EXPIRE_EPOCH"))
964 add_acc_expire_time_epoch(opts, &(curr_acc->access_expire_time), val);
966 else if(CONF_VAR_IS(var, "FORCE_NAT"))
968 #if FIREWALL_IPTABLES
969 if(strncasecmp(opts->config[CONF_ENABLE_IPT_FORWARDING], "Y", 1) !=0 )
972 "[*] FORCE_NAT requires ENABLE_IPT_FORWARDING to be enabled in fwknopd.conf\n");
973 clean_exit(opts, NO_FW_CLEANUP, EXIT_FAILURE);
975 add_acc_force_nat(opts, curr_acc, val);
978 "[*] FORCE_NAT not supported.\n");
979 clean_exit(opts, NO_FW_CLEANUP, EXIT_FAILURE);
985 "*Ignoring unknown access parameter: '%s' in %s\n",
986 var, opts->config[CONF_ACCESS_FILE]
993 /* Basic check to ensure that we got at least one SOURCE stanza with
994 * a valid KEY defined (valid meaning it has a value that is not
1000 "[*] Could not find valid SOURCE stanza in access file: '%s'\n",
1001 opts->config[CONF_ACCESS_FILE]);
1002 clean_exit(opts, NO_FW_CLEANUP, EXIT_FAILURE);
1005 /* Sanity check the last stanza
1007 if(!acc_data_is_valid(curr_acc))
1010 "[*] Data error in access file: '%s'\n",
1011 opts->config[CONF_ACCESS_FILE]);
1012 clean_exit(opts, NO_FW_CLEANUP, EXIT_FAILURE);
1015 /* Expand our the expandable fields into their respective data buckets.
1018 expand_acc_ent_lists(opts);
1020 /* Make sure default values are set where needed.
1023 set_acc_defaults(opts);
1029 compare_addr_list(acc_int_list_t *source_list, const uint32_t ip)
1035 if((ip & source_list->mask) == (source_list->maddr & source_list->mask))
1041 source_list = source_list->next;
1047 /* Compare the contents of 2 port lists. Return true on a match.
1048 * Match depends on the match_any flag. if match_any is 1 then any
1049 * entry in the incoming data need only match one item to return true.
1050 * Otherwise all entries in the incoming data must have a corresponding
1051 * match in the access port_list.
1054 compare_port_list(acc_port_list_t *in, acc_port_list_t *ac, const int match_any)
1059 acc_port_list_t *tlist;
1067 if(in->proto == tlist->proto && in->port == tlist->port)
1073 tlist = tlist->next;
1078 return(i_cnt == a_cnt);
1081 /* Take a proto/port string (or mulitple comma-separated strings) and check
1082 * them against the list for the given access stanza.
1084 * Return 1 if we are allowed
1087 acc_check_port_access(acc_stanza_t *acc, char *port_str)
1094 acc_port_list_t *o_pl = acc->oport_list;
1095 acc_port_list_t *r_pl = acc->rport_list;
1097 acc_port_list_t *in_pl = NULL;
1101 /* Create our own internal port_list from the incoming SPA data
1104 for(ndx = start; *ndx; ndx++)
1108 strlcpy(buf, start, (ndx-start)+1);
1109 add_port_list_ent(&in_pl, buf);
1113 strlcpy(buf, start, (ndx-start)+1);
1114 add_port_list_ent(&in_pl, buf);
1119 "Unable to create acc_port_list from incoming data: %s", port_str
1124 /* Start with restricted ports (if any). Any match (even if only one
1125 * entry) means not allowed.
1127 if((acc->rport_list != NULL) && (compare_port_list(in_pl, r_pl, 1)))
1130 goto cleanup_and_bail;
1133 /* For open port list, all must match.
1135 if((acc->oport_list != NULL) && (!compare_port_list(in_pl, o_pl, 0)))
1139 free_acc_port_list(in_pl);
1143 /* Take a GPG ID string and check it against the list of allowed
1146 * Return 1 if we are allowed
1149 acc_check_gpg_remote_id(acc_stanza_t *acc, const char *gpg_id)
1151 acc_string_list_t *ndx;
1153 for(ndx = acc->gpg_remote_id_list; ndx != NULL; ndx=ndx->next)
1154 if(strcasecmp(ndx->str, gpg_id) == 0)
1160 /* Dump the configuration
1163 dump_access_list(const fko_srv_options_t *opts)
1167 acc_stanza_t *acc = opts->acc_stanzas;
1169 fprintf(stdout, "Current fwknopd access settings:\n");
1173 fprintf(stderr, "\n ** No Access Settings Defined **\n\n");
1181 "==============================================================\n"
1183 " RESTRICT_PORTS: %s\n"
1184 " KEY: <see the access.conf file>\n"
1185 " FW_ACCESS_TIMEOUT: %i\n"
1186 " ENABLE_CMD_EXEC: %s\n"
1187 " CMD_EXEC_USER: %s\n"
1188 " REQUIRE_USERNAME: %s\n"
1189 " REQUIRE_SOURCE_ADDRESS: %s\n"
1190 " FORCE_NAT (ip): %s\n"
1191 " FORCE_NAT (proto): %s\n"
1192 " FORCE_NAT (port): %d\n"
1193 " ACCESS_EXPIRE: %s" /* asctime() adds a newline */
1194 " GPG_HOME_DIR: %s\n"
1195 " GPG_DECRYPT_ID: %s\n"
1196 " GPG_DECRYPT_PW: <see the access.conf file>\n"
1197 " GPG_REQUIRE_SIG: %s\n"
1198 "GPG_IGNORE_SIG_VERIFY_ERROR: %s\n"
1199 " GPG_REMOTE_ID: %s\n",
1202 (acc->open_ports == NULL) ? "<not set>" : acc->open_ports,
1203 (acc->restrict_ports == NULL) ? "<not set>" : acc->restrict_ports,
1204 //(acc->key == NULL) ? "<not set>" : acc->key,
1205 acc->fw_access_timeout,
1206 acc->enable_cmd_exec ? "Yes" : "No",
1207 (acc->cmd_exec_user == NULL) ? "<not set>" : acc->cmd_exec_user,
1208 (acc->require_username == NULL) ? "<not set>" : acc->require_username,
1209 acc->require_source_address ? "Yes" : "No",
1210 acc->force_nat ? acc->force_nat_ip : "<not set>",
1211 acc->force_nat && acc->force_nat_proto != NULL ? acc->force_nat_proto : "<not set>",
1212 acc->force_nat ? acc->force_nat_port : 0,
1213 (acc->access_expire_time > 0) ? asctime(localtime(&acc->access_expire_time)) : "<not set>\n",
1214 (acc->gpg_home_dir == NULL) ? "<not set>" : acc->gpg_home_dir,
1215 (acc->gpg_decrypt_id == NULL) ? "<not set>" : acc->gpg_decrypt_id,
1216 //(acc->gpg_decrypt_pw == NULL) ? "<not set>" : acc->gpg_decrypt_pw,
1217 acc->gpg_require_sig ? "Yes" : "No",
1218 acc->gpg_ignore_sig_error ? "Yes" : "No",
1219 (acc->gpg_remote_id == NULL) ? "<not set>" : acc->gpg_remote_id
1222 fprintf(stdout, "\n");
1227 fprintf(stdout, "\n");