Adds the --access-folder command line option
This commit is contained in:
parent
186101d298
commit
a0c4acd31c
@ -1356,6 +1356,13 @@ parse_access_folder(fko_srv_options_t *opts, char *access_folder, int *depth)
|
|||||||
char include_file[MAX_PATH_LEN] ={0};
|
char include_file[MAX_PATH_LEN] ={0};
|
||||||
struct dirent *dp;
|
struct dirent *dp;
|
||||||
|
|
||||||
|
(*depth)++;
|
||||||
|
if ((*depth) == 1)
|
||||||
|
{
|
||||||
|
acc_stanza_init(opts);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if((ndx = strrchr(access_folder, '/')) != NULL)
|
if((ndx = strrchr(access_folder, '/')) != NULL)
|
||||||
{
|
{
|
||||||
if (strlen(ndx) == 1)
|
if (strlen(ndx) == 1)
|
||||||
|
|||||||
@ -45,6 +45,7 @@
|
|||||||
/* Function Prototypes
|
/* Function Prototypes
|
||||||
*/
|
*/
|
||||||
int parse_access_file(fko_srv_options_t *opts, char *access_filename, int *depth);
|
int parse_access_file(fko_srv_options_t *opts, char *access_filename, int *depth);
|
||||||
|
int parse_access_folder(fko_srv_options_t *opts, char *access_folder, int *depth);
|
||||||
int compare_addr_list(acc_int_list_t *source_list, const uint32_t ip);
|
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);
|
int acc_check_port_access(acc_stanza_t *acc, char *port_str);
|
||||||
void dump_access_list(const fko_srv_options_t *opts);
|
void dump_access_list(const fko_srv_options_t *opts);
|
||||||
|
|||||||
@ -120,6 +120,7 @@ static char *config_map[NUMBER_OF_CONFIG_ENTRIES] = {
|
|||||||
"FWKNOP_RUN_DIR",
|
"FWKNOP_RUN_DIR",
|
||||||
"FWKNOP_CONF_DIR",
|
"FWKNOP_CONF_DIR",
|
||||||
"ACCESS_FILE",
|
"ACCESS_FILE",
|
||||||
|
"ACCESS_FOLDER",
|
||||||
"FWKNOP_PID_FILE",
|
"FWKNOP_PID_FILE",
|
||||||
#if USE_FILE_CACHE
|
#if USE_FILE_CACHE
|
||||||
"DIGEST_FILE",
|
"DIGEST_FILE",
|
||||||
@ -161,6 +162,7 @@ enum {
|
|||||||
DUMP_SERVER_ERR_CODES,
|
DUMP_SERVER_ERR_CODES,
|
||||||
EXIT_AFTER_PARSE_CONFIG,
|
EXIT_AFTER_PARSE_CONFIG,
|
||||||
FAULT_INJECTION_TAG,
|
FAULT_INJECTION_TAG,
|
||||||
|
ACCESS_FOLDER,
|
||||||
NOOP /* Just to be a marker for the end */
|
NOOP /* Just to be a marker for the end */
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -173,6 +175,7 @@ enum {
|
|||||||
static struct option cmd_opts[] =
|
static struct option cmd_opts[] =
|
||||||
{
|
{
|
||||||
{"access-file", 1, NULL, 'a'},
|
{"access-file", 1, NULL, 'a'},
|
||||||
|
{"access-folder", 1, NULL, ACCESS_FOLDER},
|
||||||
{"afl-fuzzing", 0, NULL, 'A'},
|
{"afl-fuzzing", 0, NULL, 'A'},
|
||||||
{"afl-pkt-file", 1, NULL, AFL_PKT_FILE },
|
{"afl-pkt-file", 1, NULL, AFL_PKT_FILE },
|
||||||
{"config-file", 1, NULL, 'c'},
|
{"config-file", 1, NULL, 'c'},
|
||||||
|
|||||||
@ -1202,6 +1202,9 @@ config_init(fko_srv_options_t *opts, int argc, char **argv)
|
|||||||
case 'a':
|
case 'a':
|
||||||
set_config_entry(opts, CONF_ACCESS_FILE, optarg);
|
set_config_entry(opts, CONF_ACCESS_FILE, optarg);
|
||||||
break;
|
break;
|
||||||
|
case ACCESS_FOLDER:
|
||||||
|
set_config_entry(opts, CONF_ACCESS_FOLDER, optarg);
|
||||||
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
/* This was handled earlier */
|
/* This was handled earlier */
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -148,10 +148,16 @@ main(int argc, char **argv)
|
|||||||
fprintf(stdout, "Deleting any existing firewall rules...\n");
|
fprintf(stdout, "Deleting any existing firewall rules...\n");
|
||||||
clean_exit(&opts, FW_CLEANUP, EXIT_SUCCESS);
|
clean_exit(&opts, FW_CLEANUP, EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
if (opts.config[CONF_ACCESS_FOLDER] != NULL) //If we have an access folder, process it
|
||||||
/* Process the access.conf file.
|
{
|
||||||
|
if (parse_access_folder(&opts, opts.config[CONF_ACCESS_FOLDER], &depth) != EXIT_SUCCESS)
|
||||||
|
{
|
||||||
|
clean_exit(&opts, NO_FW_CLEANUP, EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Process the access.conf file, but only if no access.conf folder was specified.
|
||||||
*/
|
*/
|
||||||
if (parse_access_file(&opts, opts.config[CONF_ACCESS_FILE], &depth) != EXIT_SUCCESS)
|
else if (parse_access_file(&opts, opts.config[CONF_ACCESS_FILE], &depth) != EXIT_SUCCESS)
|
||||||
{
|
{
|
||||||
clean_exit(&opts, NO_FW_CLEANUP, EXIT_FAILURE);
|
clean_exit(&opts, NO_FW_CLEANUP, EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -309,6 +309,7 @@ enum {
|
|||||||
CONF_FWKNOP_RUN_DIR,
|
CONF_FWKNOP_RUN_DIR,
|
||||||
CONF_FWKNOP_CONF_DIR,
|
CONF_FWKNOP_CONF_DIR,
|
||||||
CONF_ACCESS_FILE,
|
CONF_ACCESS_FILE,
|
||||||
|
CONF_ACCESS_FOLDER,
|
||||||
CONF_FWKNOP_PID_FILE,
|
CONF_FWKNOP_PID_FILE,
|
||||||
#if USE_FILE_CACHE
|
#if USE_FILE_CACHE
|
||||||
CONF_DIGEST_FILE,
|
CONF_DIGEST_FILE,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user