コード例 #1
0
static int always_instantiate(CONF_SECTION *conf, void **instance)
{
	rlm_always_t *data;

	/*
	 *	Set up a storage area for instance data
	 */
	data = rad_malloc(sizeof(*data));
	if (!data) {
		return -1;
	}
	memset(data, 0, sizeof(*data));

	/*
	 *	If the configuration parameters can't be parsed, then
	 *	fail.
	 */
	if (cf_section_parse(conf, data, module_config) < 0) {
		free(data);
		return -1;
	}

	/*
	 *	Convert the rcode string to an int, and get rid of it
	 */
	data->rcode = str2rcode(data->rcode_str);
	if (data->rcode == -1) {
		free(data);
		return -1;
	}

	*instance = data;

	return 0;
}
コード例 #2
0
ファイル: rlm_always.c プロジェクト: Gejove/freeradius-server
static int always_instantiate(CONF_SECTION *conf, void **instance)
{
	rlm_always_t *inst;

	/*
	 *	Set up a storage area for instance data
	 */
	*instance = inst = talloc_zero(conf, rlm_always_t);
	if (!inst) {
		return -1;
	}

	/*
	 *	If the configuration parameters can't be parsed, then
	 *	fail.
	 */
	if (cf_section_parse(conf, inst, module_config) < 0) {
		return -1;
	}

	/*
	 *	Convert the rcode string to an int, and get rid of it
	 */
	inst->rcode = str2rcode(inst->rcode_str);
	if (inst->rcode == RLM_MODULE_UNKNOWN) {
		return -1;
	}

	return 0;
}
コード例 #3
0
static int mod_instantiate(UNUSED CONF_SECTION *conf, void *instance)
{
	rlm_always_t *inst = instance;

	/*
	 *	Convert the rcode string to an int, and get rid of it
	 */
	inst->rcode = str2rcode(inst->rcode_str);
	if (inst->rcode == RLM_MODULE_UNKNOWN) {
		return -1;
	}

	return 0;
}
コード例 #4
0
static int sometimes_instantiate(CONF_SECTION *conf, void **instance)
{
	rlm_sometimes_t *inst;

	/*
	 *	Set up a storage area for instance data
	 */
	inst = rad_malloc(sizeof(*inst));
	if (!inst) {
		return -1;
	}
	memset(inst, 0, sizeof(*inst));

	/*
	 *	If the configuration parameters can't be parsed, then
	 *	fail.
	 */
	if (cf_section_parse(conf, inst, module_config) < 0) {
		sometimes_detach(inst);
		return -1;
	}

	/*
	 *	Convert the rcode string to an int, and get rid of it
	 */
	inst->rcode = str2rcode(inst->rcode_str);
	if (inst->rcode == -1) {
		sometimes_detach(inst);
		return -1;
	}

	inst->da = dict_attrbyname(inst->key);
	if (!inst->da) {
		radlog(L_ERR, "rlm_sometimes; Unknown attributes %s", inst->key);
		return -1;
		return -1;
	}

	*instance = inst;

	return 0;
}