Commit 1dab35f3 authored by Jon Kåre Hellan's avatar Jon Kåre Hellan

Avoid premature exit when a category doesn't exist in config file.


git-svn-id: file:///home/svn/mapi/trunk@1238 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent bbf0c6cd
......@@ -32,6 +32,7 @@ static int dagipfbpffilter_instance(mapidflib_function_instance_t *instance,
mapiFunctArg* fargs=instance->args;
char *binpath, *filter_string = getargstr(&fargs);
int rc = MFUNCT_COULD_NOT_APPLY_FUNCT;
conf_category_entry_t *cat;
if(filter_string == NULL)
return MFUNCT_INVALID_ARGUMENT_1;
......@@ -45,7 +46,8 @@ static int dagipfbpffilter_instance(mapidflib_function_instance_t *instance,
/* We merely check whether we can execute the loading script. */
if (pc_load(CONFDIR "/" CONF_FILE)) {
binpath = pc_get_param(pc_get_category("dag"), "ipf_loader_bin");
cat = pc_get_category("dag");
binpath = cat ? pc_get_param(cat, "ipf_loader_bin") : NULL;
if (binpath && *binpath && (access(binpath, X_OK) == 0))
rc = 0;
pc_close();
......@@ -62,9 +64,12 @@ static int dagipfbpffilter_init(mapidflib_function_instance_t *instance,
FILE *fp;
mapiFunctArg* fargs=instance->args;
char *binpath = NULL, *tmpfile, *command, *filter_string = getargstr(&fargs);
conf_category_entry_t *cat;
if (pc_load(CONFDIR "/" CONF_FILE))
binpath = pc_get_param(pc_get_category("dag"), "ipf_loader_bin");
if (pc_load(CONFDIR "/" CONF_FILE)) {
cat = pc_get_category("dag");
binpath = cat ? pc_get_param(cat, "ipf_loader_bin") : NULL;
}
if ((binpath == NULL) || (*binpath == '\0') || (filter_string == NULL)) {
pc_close();
......
......@@ -641,10 +641,12 @@ mapidrv_create_flow (int devid, int fd, char **devtype)
/* DSM */
if (pc_load(CONFDIR "/" CONF_FILE)) {
char *disable_dsm = pc_get_param(pc_get_category("dag"), "disable_dsm");
conf_category_entry_t *cat = pc_get_category("dag");
char *disable_dsm = cat ? pc_get_param(cat, "disable_dsm") : NULL;
if (!disable_dsm || !*disable_dsm || strcmp(disable_dsm, "1")) {
char *binpath = pc_get_param(pc_get_category("dag"), "dsm_loader_bin");
char *binpath
= cat ? pc_get_param(cat, "dsm_loader_bin") : NULL;
if (binpath && *binpath && (access(binpath, X_OK) == 0)) {
......@@ -884,7 +886,8 @@ int dagdsm_build_bpffilter(boolean_t check_only, char *new_filter_string, mapid_
/* First we check whether we can execute the dsm_loader binary at all. */
if (pc_load(CONFDIR "/" CONF_FILE)) {
binpath = pc_get_param(pc_get_category("dag"), "dsm_loader_bin");
conf_category_entry_t *cat = pc_get_category("dag");
binpath = cat ? pc_get_param(cat, "dsm_loader_bin") : NULL;
if (binpath && *binpath && (access(binpath, X_OK) == 0)) {
if ((xml_filter = dagdsm_bpf_xprintf(filter, always_match)) != NULL) {
int tmpfd;
......
......@@ -258,6 +258,7 @@ int conf_parser(void)
conf_parameter_t *VO_list = NULL;
struct stat stat_buf;
char *tmp = NULL;
conf_category_entry_t *cat;
/*
* Parse in vod.conf
......@@ -265,7 +266,8 @@ int conf_parser(void)
if(pc_load("./vod.conf") != 1)
return(-1);
if((tmp = pc_get_param(pc_get_category("ca"), "ip")) == NULL)
cat = pc_get_category("ca");
if(cat == NULL || (tmp = pc_get_param(cat, "ip")) == NULL)
{
fprintf(stderr, "Could not find CA address in configuration file. Check the file vod.conf for bad syntax.\n");
return(-1);
......@@ -273,7 +275,7 @@ int conf_parser(void)
else
ca_addr = strdup(tmp);
if((tmp = pc_get_param(pc_get_category("ca"), "port")) == NULL)
if(cat == NULL || (tmp = pc_get_param(cat, "port")) == NULL)
{
fprintf(stderr, "Could not find CA port info in configuration file. Check vod.conf for bad syntax.\n");
return(-1);
......@@ -281,7 +283,8 @@ int conf_parser(void)
else
ca_port = atoi(tmp);
if((tmp = pc_get_param(pc_get_category("main"), "socket")) == NULL)
cat = pc_get_category("main");
if(cat == NULL || (tmp = pc_get_param(cat, "socket")) == NULL)
{
fprintf(stderr, "Could not load VOd listening socket info from configuration file..\nUsing /tmp/vod.sock ..\n");
vodsock = strdup("/tmp/vod.sock");
......@@ -289,14 +292,15 @@ int conf_parser(void)
else
vodsock = strdup(tmp);
if((tmp = pc_get_param(pc_get_category("files"), "nicfile")) == NULL)
cat = pc_get_category("files");
if(cat == NULL || (tmp = pc_get_param(cat, "nicfile")) == NULL)
{
fprintf(stderr, "Could not load NIC file info from configuration file..\nUsing ./nic.conf ..\n");
}
else
nicfile = strdup(tmp);
if((tmp = pc_get_param(pc_get_category("files"), "policiesfile")) == NULL)
if(cat == NULL || (tmp = pc_get_param(cat, "policiesfile")) == NULL)
{
fprintf(stderr, "Could not load policies file info from configuration file..\nUsing ./policies.conf ..\n");
}
......@@ -320,6 +324,12 @@ int conf_parser(void)
nic_mod_time = stat_buf.st_mtime;
nic = pc_get_category("interfaces");
if (nic == NULL)
{
fprintf(stderr, "no interfaces in config file.\n");
return(-1);
}
VO_list = nic->params;
build_nics(VO_list);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment