[test suite] implement different access stanza init strategy, 'complete cycle, include (3)' test passes now

This commit is contained in:
Michael Rash
2015-12-20 18:17:42 -08:00
parent dd2f4c2c38
commit e7f1813962
5 changed files with 35 additions and 16 deletions
+27 -16
View File
@@ -54,6 +54,14 @@
DECLARE_TEST_SUITE(access, "Access test suite");
#endif
static int do_acc_stanza_init = 1;
void enable_acc_stanzas_init(void)
{
do_acc_stanza_init = 1;
return;
}
/* Add an access string entry
*/
static void
@@ -1036,10 +1044,19 @@ free_acc_stanzas(fko_srv_options_t *opts)
static void
acc_stanza_init(fko_srv_options_t *opts)
{
/* Free any resources first (in case of reconfig). Assume non-NULL
* entry needs to be freed.
*/
free_acc_stanzas(opts);
if(do_acc_stanza_init)
{
log_msg(LOG_DEBUG, "Initialize access stanzas");
/* Free any resources first (in case of reconfig). Assume non-NULL
* entry needs to be freed.
*/
free_acc_stanzas(opts);
/* Make sure to only initialize access stanzas once.
*/
do_acc_stanza_init = 0;
}
return;
}
@@ -1355,12 +1372,6 @@ parse_access_folder(fko_srv_options_t *opts, char *access_folder, int *depth)
char include_file[MAX_PATH_LEN] = {0};
struct dirent *dp;
(*depth)++;
if ((*depth) == 1)
{
acc_stanza_init(opts);
}
if(strlen(access_folder) > 1)
chop_char(access_folder, PATH_SEP);
@@ -1466,12 +1477,11 @@ parse_access_file(fko_srv_options_t *opts, char *access_filename, int *depth)
return EXIT_FAILURE;
}
/* Initialize the access list, but only if we are processing the root access.conf.
log_msg(LOG_DEBUG, "Opened access file: %s", access_filename);
/* Initialize the access list
*/
if ((*depth) == 1)
{
acc_stanza_init(opts);
}
acc_stanza_init(opts);
/* Now walk through access file pulling the access entries into the
* current stanza.
@@ -1889,7 +1899,8 @@ parse_access_file(fko_srv_options_t *opts, char *access_filename, int *depth)
}
fclose(file_ptr);
(*depth)--;
if(*depth > 0)
(*depth)--;
if(*depth == 0) //means we just closed the root access.conf
{
+1
View File
@@ -52,6 +52,7 @@ int compare_addr_list(acc_int_list_t *source_list, const uint32_t ip);
int acc_check_port_access(acc_stanza_t *acc, char *port_str);
void dump_access_list(const fko_srv_options_t *opts);
int expand_acc_port_list(acc_port_list_t **plist, char *plist_str);
void enable_acc_stanzas_init(void);
void free_acc_stanzas(fko_srv_options_t *opts);
void free_acc_port_list(acc_port_list_t *plist);
+4
View File
@@ -1020,6 +1020,10 @@ config_init(fko_srv_options_t *opts, int argc, char **argv)
*/
optind = 0;
/* Enable access.conf parsing (in case this is a re-config)
*/
enable_acc_stanzas_init();
/* First, scan the command-line args to see if we are in key-generation
* mode. This is independent of config parsing and other operations, so
* it is done as the very first thing. Also handle printing of the fwknop
+2
View File
@@ -2618,7 +2618,9 @@ sub _client_send_spa_packet() {
for (;;) {
$tries++;
### default stanza regex match
my $server_receive_re = qr/stanza\s.*\sSPA Packet from IP/;
$server_receive_re = $test_hr->{'server_receive_re'}
if $test_hr->{'server_receive_re'};
+1
View File
@@ -174,6 +174,7 @@
'cmdline' => $default_client_hmac_args,
'fwknopd_cmdline' => "$fwknopdCmd -c $cf{'def'} --access-folder conf/access-include/defaults " .
"-d $default_digest_file -p $default_pid_file $intf_str",
'server_receive_re' => qr/stanza\s\#2.*\sSPA Packet from IP/,
'fw_rule_created' => $NEW_RULE_REQUIRED,
'fw_rule_removed' => $NEW_RULE_REMOVED,
'key_file' => $cf{'rc_hmac_b64_key'},