Example #1
0
int url_check_init_service(ci_service_xdata_t * srv_xdata,
                           struct ci_server_conf *server_conf)
{
     unsigned int xops;
     struct lookup_db *int_db;
     ci_debug_printf(2, "Initialization of url_check module......\n");
     ci_service_set_preview(srv_xdata, 0);
     xops = CI_XCLIENTIP | CI_XSERVERIP;
     xops |= CI_XAUTHENTICATEDUSER | CI_XAUTHENTICATEDGROUPS;
     ci_service_set_xopts(srv_xdata, xops);

     /*initialize mempools          */
     URL_CHECK_DATA_POOL = ci_object_pool_register("url_check_data", 
						   sizeof(struct url_check_data));

     if (URL_CHECK_DATA_POOL < 0)
	 return CI_ERROR;
     /*Add internal database lookups*/
     int_db = new_lookup_db("ALL", DB_INTERNAL, CHECK_HOST, NULL,
			    all_lookup_db,
			    NULL);
     if(int_db)
       return add_lookup_db(int_db);

     return CI_OK;
}
int postInitImageClassificationService(void)
{
uint16_t category;
	ci_thread_rwlock_init(&imageclassify_rwlock);
	ci_thread_rwlock_wrlock(&imageclassify_rwlock);

	/*Initialize object pools*/
	IMAGEDETECTED_POOL = ci_object_pool_register("image_detected_t", sizeof(image_detected_t) * num_image_categories);

	if(IMAGEDETECTED_POOL < 0) {
		ci_debug_printf(1, " srvclassify_init_service: error registering object_pool image_detected_t\n");
		ci_thread_rwlock_unlock(&imageclassify_rwlock);
		return CI_ERROR;
	}

	IMAGEDETECTEDCOUNT_POOL = ci_object_pool_register("image_detected_count_t", sizeof(image_detected_count_t) * num_image_categories);

	if(IMAGEDETECTEDCOUNT_POOL < 0) {
		ci_debug_printf(1, " srvclassify_init_service: error registering object_pool image_detected_count_t\n");
		ci_object_pool_unregister(IMAGEDETECTED_POOL);
		ci_thread_rwlock_unlock(&imageclassify_rwlock);
		return CI_ERROR;
	}

	if(num_image_categories)
	{
		for(category = 0; category < num_image_categories; category++)
		{
			if(ci_thread_mutex_init(&imageCategories[category].mutex) != 0)
			{
				ci_debug_printf(1, "srv_classify_image: Couldn't init category mutex\n");
			}
			if(ci_thread_cond_init(&imageCategories[category].cond) != 0)
			{
				ci_debug_printf(1, "srv_classify_image: Couldn't init category condition lock variable\n");
			}
		}
	}

	ci_thread_rwlock_unlock(&imageclassify_rwlock);
	return CI_OK;
}
Example #3
0
int srvclamav_init_service(ci_service_xdata_t * srv_xdata,
                           struct ci_server_conf *server_conf)
{
     int ret, i;
     magic_db = server_conf->MAGIC_DB;
     scantypes = (int *) malloc(ci_magic_types_num(magic_db) * sizeof(int));
     scangroups = (int *) malloc(ci_magic_groups_num(magic_db) * sizeof(int));

     for (i = 0; i < ci_magic_types_num(magic_db); i++)
          scantypes[i] = 0;
     for (i = 0; i < ci_magic_groups_num(magic_db); i++)
          scangroups[i] = 0;


     ci_debug_printf(10, "Going to initialize srvclamav\n");
     ret = init_virusdb();
     if (!ret)
          return 0;
     srv_clamav_xdata = srv_xdata;      /*Needed by db_reload command */
     set_istag(srv_clamav_xdata);
     ci_service_set_preview(srv_xdata, 1024);
     ci_service_enable_204(srv_xdata);
     ci_service_set_transfer_preview(srv_xdata, "*");
 

     /*Initialize object pools*/
     AVREQDATA_POOL = ci_object_pool_register("av_req_data_t", sizeof(av_req_data_t));

     if(AVREQDATA_POOL < 0) {
	 ci_debug_printf(1, " srvclamav_init_service: error registering object_pool av_req_data_t\n");
	 return 0;
     }
     /*initialize service commands */
     register_command("srv_clamav:dbreload", MONITOR_PROC_CMD | CHILDS_PROC_CMD,
                      dbreload_command);

     return 1;
}
Example #4
0
sg_db_t *sg_init_db(char *home)
{
    sg_db_t *sg_db;
    
    if(SGDB_T_POOL < 0 )
	SGDB_T_POOL = ci_object_pool_register("sg_db_t", sizeof(sg_db_t));

    if(SGDB_T_POOL < 0 )
	return NULL;

    sg_db = ci_object_pool_alloc(SGDB_T_POOL);
    if(!sg_db)
	return NULL;

    sg_db->env_db=NULL;
    sg_db->domains_db=NULL;
    sg_db->urls_db=NULL;

    sg_db->env_db = db_setup(home);
    if(sg_db->env_db==NULL){
	ci_object_pool_free(sg_db);
	return NULL;
    }

    sg_db->domains_db = sg_open_db(sg_db->env_db, "domains.db", domainCompare);
    sg_db->urls_db = sg_open_db(sg_db->env_db, "urls.db", compare_str);

    if(sg_db->domains_db == NULL && sg_db->urls_db== NULL) {
	sg_close_db(sg_db);
	ci_object_pool_free(sg_db);
	return NULL;
    }

    ci_debug_printf(5,"DBs opened\n");
    ci_debug_printf(5,"Finished initialisation\n");
    return sg_db;
}