Esempio n. 1
0
static const char *detect_module_path(bool *valid)
{
	static const char * const pathv[] = {
#if defined (PREFIX)
		"" PREFIX "/lib/baresip/modules",
#else
		"/usr/local/lib/baresip/modules",
		"/usr/lib/baresip/modules",
#endif
	};
	const char *current = pathv[0];
	uint32_t nmax = 0;
	size_t i;

	for (i=0; i<ARRAY_SIZE(pathv); i++) {

		uint32_t n = count_modules(pathv[i]);

		info("%s: detected %u modules\n", pathv[i], n);

		if (n > nmax) {
			nmax = n;
			current = pathv[i];
		}
	}

	if (nmax > 0)
		*valid = true;

	return current;
}
Esempio n. 2
0
int 
modstack_config(struct module_stack* stack, const char* module_conf)
{
        int i;
        verbose(VERB_QUERY, "module config: \"%s\"", module_conf);
        stack->num = count_modules(module_conf);
        if(stack->num == 0) {
                log_err("error: no modules specified");
                return 0;
        }
        if(stack->num > MAX_MODULE) {
                log_err("error: too many modules (%d max %d)",
                        stack->num, MAX_MODULE);
                return 0;
        }
        stack->mod = (struct module_func_block**)calloc((size_t)
                stack->num, sizeof(struct module_func_block*));
        if(!stack->mod) {
                log_err("out of memory");
                return 0;
        }
        for(i=0; i<stack->num; i++) {
                stack->mod[i] = module_factory(&module_conf);
                if(!stack->mod[i]) {
                        log_err("Unknown value for next module: '%s'",
                                module_conf);
                        return 0;
                }
        }
        return 1;
}
Esempio n. 3
0
static void print_trans_maindata(const char *filename)
{
  fprintf(OUT, "struct trans_maindata trans_%s_maindata = {\n", filename);

  /* シンボルの個数(0番anonymousも数える) */
  fprintf(OUT, "  %d, /*count of symbol*/\n", count_symbols());
  /* シンボルの配列 */
  fprintf(OUT, "  trans_%s_maindata_symbols, /*symboltable*/\n", filename);
  /* ファンクタの個数 */
  fprintf(OUT, "  %d, /*count of functor*/\n", lmn_functor_table.next_id);
  /* ファンクタの配列 */
  fprintf(OUT, "  trans_%s_maindata_functors, /*functortable*/\n", filename);
  /* ルールセットの個数 */
  fprintf(OUT, "  %d, /*count of ruleset*/\n", count_rulesets());
  /* ルールセットオブジェクトへのポインタの配列 */
  fprintf(OUT, "  trans_%s_maindata_rulesets, /*rulesettable*/\n", filename);
  /* モジュールの個数 */
  fprintf(OUT, "  %d, /*count of module*/\n", count_modules());
  /* モジュールの配列 */
  fprintf(OUT, "  trans_%s_maindata_modules, /*moduletable*/\n", filename);
  /* シンボルid変換テーブル */
  fprintf(OUT, "  trans_%s_maindata_symbolexchange, /*symbol id exchange table*/\n", filename);
  /* ファンクタid変換テーブル */
  fprintf(OUT, "  trans_%s_maindata_functorexchange, /*functor id exchange table*/\n", filename);
  /* ルールセットid変換テーブル */
  fprintf(OUT, "  trans_%s_maindata_rulesetexchange /*ruleset id exchange table*/\n", filename);
  fprintf(OUT, "};\n\n");
}
Esempio n. 4
0
static void print_trans_modules(const char *filename)
{
  extern st_table_t module_table;
  int count, counter;

  count   = count_modules();
  counter = 0;
  fprintf(OUT, "struct trans_module trans_%s_maindata_modules[%d] = {\n", filename, count);
  st_foreach(module_table, print_trans_module_f, (st_data_t)&counter);
  fprintf(OUT, "};\n\n");
}
Esempio n. 5
0
/*
 * Function called when loading the kernel module.
 * Prints a welcome-message and then does its magic.
 */
int init_module (void)
{
	int ret;

	ROOTKIT_DEBUG("****************************************\n");	
	ROOTKIT_DEBUG("Beginning rootkit detection procedure...\n");
	ROOTKIT_DEBUG("****************************************\n");
	
	/* open the log file */
	fd = filp_open(path, O_CREAT|O_WRONLY|O_APPEND|O_TRUNC, S_IRWXU);
	if(IS_ERR(fd)) {
		ROOTKIT_DEBUG("Error while trying to open the file '%s'! Terminating...\n", path);
		return -EIO;
	}
	
	/* check the sys call table */
	ret = check_syscalls();	
	if(ret < 0) {
		ROOTKIT_DEBUG("Error while checking the system call table!\n");
		return ret;
	}
	
	/* check the processes */
	ret = check_processes();	
	if(ret < 0) {
		ROOTKIT_DEBUG("Error while checking the running processes!\n");
		return ret;
	}
	
	ret = check_netfilter_hooks();
	if(ret < 0) {
		ROOTKIT_DEBUG("Error while checking netfiler hooks!\n");
		return ret;
	}
	
	ret = count_modules();
	if(ret < 0) {
		ROOTKIT_DEBUG("Error while checking the loaded modules!\n");
		return ret;
	}
	
	/* close the log file */
	filp_close(fd, NULL);
	
	/* log the completion */
	ROOTKIT_DEBUG("****************************************\n");	
	ROOTKIT_DEBUG("Check complete. You may now unload.\n");
	ROOTKIT_DEBUG("****************************************\n");
	return 0;
}