/* * Parse a configuration section, and populate a HV. * This function is recursively called (allows to have nested hashes.) */ static void perl_parse_config(CONF_SECTION *cs, int lvl, HV *rad_hv) { if (!cs || !rad_hv) return; int indent_section = (lvl + 1) * 4; int indent_item = (lvl + 2) * 4; DEBUG("%*s%s {", indent_section, " ", cf_section_name1(cs)); CONF_ITEM *ci = NULL; while ((ci = cf_item_next(cs, ci))) { /* * This is a section. * Create a new HV, store it as a reference in current HV, * Then recursively call perl_parse_config with this section and the new HV. */ if (cf_item_is_section(ci)) { CONF_SECTION *sub_cs = cf_item_to_section(ci); char const *key = cf_section_name1(sub_cs); /* hash key */ HV *sub_hv; SV *ref; if (!key) continue; if (hv_exists(rad_hv, key, strlen(key))) { WARN("Ignoring duplicate config section '%s'", key); continue; } sub_hv = newHV(); ref = newRV_inc((SV*) sub_hv); (void)hv_store(rad_hv, key, strlen(key), ref, 0); perl_parse_config(sub_cs, lvl + 1, sub_hv); } else if (cf_item_is_pair(ci)){ CONF_PAIR *cp = cf_item_to_pair(ci); char const *key = cf_pair_attr(cp); /* hash key */ char const *value = cf_pair_value(cp); /* hash value */ if (!key || !value) continue; /* * This is an item. * Store item attr / value in current HV. */ if (hv_exists(rad_hv, key, strlen(key))) { WARN("Ignoring duplicate config item '%s'", key); continue; } (void)hv_store(rad_hv, key, strlen(key), newSVpvn(value, strlen(value)), 0); DEBUG("%*s%s = %s", indent_item, " ", key, value); } } DEBUG("%*s}", indent_section, " "); }
/* * Do any per-module initialization that is separate to each * configured instance of the module. e.g. set up connections * to external databases, read configuration files, set up * dictionary entries, etc. * * If configuration information is given in the config section * that must be referenced in later calls, store a handle to it * in *instance otherwise put a null pointer there. */ static int mod_instantiate(CONF_SECTION *conf, void *instance) { rlm_yubikey_t *inst = instance; DICT_VALUE *dval; inst->name = cf_section_name2(conf); if (!inst->name) { inst->name = cf_section_name1(conf); } dval = dict_valbyname(PW_AUTH_TYPE, 0, inst->name); if (dval) { inst->auth_type = dval->value; } else { inst->auth_type = 0; } if (YUBIKEY_UID_SIZE > MAX_STRING_LEN) { DEBUGE("rlm_yubikey: YUBIKEY_UID_SIZE too big"); return -1; } xlat_register("modhextohex", modhex_to_hex_xlat, inst); return 0; }
/* * Ensure that the unlang sections are compiled. */ static int mod_instantiate(UNUSED void *instance, CONF_SECTION *listen_cs) { int rcode; CONF_SECTION *server_cs; vp_tmpl_rules_t parse_rules; memset(&parse_rules, 0, sizeof(parse_rules)); parse_rules.dict_def = dict_freeradius; rad_assert(listen_cs); server_cs = cf_item_to_section(cf_parent(listen_cs)); rad_assert(strcmp(cf_section_name1(server_cs), "server") == 0); rcode = unlang_compile_subsection(server_cs, "new", "client", MOD_AUTHORIZE, &parse_rules); if (rcode < 0) return rcode; if (rcode == 0) { cf_log_err(server_cs, "Failed finding 'new client { ... }' section of virtual server %s", cf_section_name2(server_cs)); return -1; } rcode = unlang_compile_subsection(server_cs, "add", "client", MOD_POST_AUTH, &parse_rules); if (rcode < 0) return rcode; rcode = unlang_compile_subsection(server_cs, "deny", "client", MOD_POST_AUTH, &parse_rules); if (rcode < 0) return rcode; return 0; }
/* * Do any per-module initialization that is separate to each * configured instance of the module. e.g. set up connections * to external databases, read configuration files, set up * dictionary entries, etc. * * If configuration information is given in the config section * that must be referenced in later calls, store a handle to it * in *instance otherwise put a null pointer there. */ static int mod_instantiate(CONF_SECTION *conf, void *instance) { rlm_expr_t *inst = instance; inst->xlat_name = cf_section_name2(conf); if (!inst->xlat_name) { inst->xlat_name = cf_section_name1(conf); } xlat_register(inst->xlat_name, expr_xlat, NULL, inst); /* * FIXME: unregister these, too */ xlat_register("rand", rand_xlat, NULL, inst); xlat_register("randstr", randstr_xlat, NULL, inst); xlat_register("urlquote", urlquote_xlat, NULL, inst); xlat_register("escape", escape_xlat, NULL, inst); xlat_register("tolower", lc_xlat, NULL, inst); xlat_register("toupper", uc_xlat, NULL, inst); xlat_register("md5", md5_xlat, NULL, inst); xlat_register("sha1", sha1_xlat, NULL, inst); #ifdef HAVE_OPENSSL_EVP_H xlat_register("sha256", sha256_xlat, NULL, inst); xlat_register("sha512", sha512_xlat, NULL, inst); #endif xlat_register("base64", base64_xlat, NULL, inst); xlat_register("base64tohex", base64_to_hex_xlat, NULL, inst); /* * Initialize various paircompare functions */ pair_builtincompare_add(instance); return 0; }
/* * Do any per-module initialization that is separate to each * configured instance of the module. e.g. set up connections * to external databases, read configuration files, set up * dictionary entries, etc. * * If configuration information is given in the config section * that must be referenced in later calls, store a handle to it * in *instance otherwise put a null pointer there. */ static int expr_instantiate(CONF_SECTION *conf, void **instance) { rlm_expr_t *inst; char *xlat_name; /* * Set up a storage area for instance data */ inst = rad_malloc(sizeof(rlm_expr_t)); if (!inst) return -1; memset(inst, 0, sizeof(rlm_expr_t)); xlat_name = cf_section_name2(conf); if (xlat_name == NULL) xlat_name = cf_section_name1(conf); if (xlat_name){ inst->xlat_name = strdup(xlat_name); xlat_register(xlat_name, expr_xlat, inst); } *instance = inst; return 0; }
/* * Do any per-module initialization that is separate to each * configured instance of the module. e.g. set up connections * to external databases, read configuration files, set up * dictionary entries, etc. * * If configuration information is given in the config section * that must be referenced in later calls, store a handle to it * in *instance otherwise put a null pointer there. */ static int mod_instantiate(CONF_SECTION *conf, void *instance) { rlm_expr_t *inst = instance; inst->xlat_name = cf_section_name2(conf); if (!inst->xlat_name) { inst->xlat_name = cf_section_name1(conf); } xlat_register(inst->xlat_name, expr_xlat, inst); xlat_register("rand", rand_xlat, inst); xlat_register("randstr", randstr_xlat, inst); xlat_register("urlquote", urlquote_xlat, inst); xlat_register("escape", escape_xlat, inst); xlat_register("tolower", lc_xlat, inst); xlat_register("toupper", uc_xlat, inst); xlat_register("md5", md5_xlat, inst); xlat_register("tobase64", base64_xlat, inst); xlat_register("base64tohex", base64_to_hex_xlat, inst); /* * Initialize various paircompare functions */ pair_builtincompare_add(); return 0; }
static int mod_instantiate(CONF_SECTION *conf, void *instance) { module_instance_t *modinst; rlm_rediswho_t *inst = instance; inst->xlat_name = cf_section_name2(conf); if (!inst->xlat_name) inst->xlat_name = cf_section_name1(conf); inst->cs = conf; modinst = module_instantiate(cf_section_find("modules"), inst->redis_instance_name); if (!modinst) { ERROR("rediswho: failed to find module instance \"%s\"", inst->redis_instance_name); return -1; } if (strcmp(modinst->entry->name, "rlm_redis") != 0) { ERROR("rediswho: Module \"%s\"" " is not an instance of the redis module", inst->redis_instance_name); return -1; } inst->redis_inst = (REDIS_INST *) modinst->insthandle; return 0; }
static int mod_instantiate(void *instance, CONF_SECTION *listen_cs) { int rcode; CONF_SECTION *server_cs; proto_detail_process_t *inst = talloc_get_type_abort(instance, proto_detail_process_t); vp_tmpl_rules_t parse_rules; memset(&parse_rules, 0, sizeof(parse_rules)); parse_rules.dict_def = dict_freeradius; rad_assert(listen_cs); server_cs = cf_item_to_section(cf_parent(listen_cs)); rad_assert(strcmp(cf_section_name1(server_cs), "server") == 0); rcode = unlang_compile_subsection(server_cs, "recv", NULL, inst->recv_type, &parse_rules); if (rcode < 0) return rcode; if (rcode == 0) { cf_log_err(server_cs, "Failed finding 'recv { ... }' section of virtual server %s", cf_section_name2(server_cs)); return -1; } rcode = unlang_compile_subsection(server_cs, "send", "ok", inst->send_type, &parse_rules); if (rcode < 0) return rcode; rcode = unlang_compile_subsection(server_cs, "send", "fail", inst->send_type, &parse_rules); if (rcode < 0) return rcode; return 0; }
static int mod_bootstrap(void *instance, CONF_SECTION *conf) { rlm_unbound_t *inst = instance; inst->name = cf_section_name2(conf); if (!inst->name) inst->name = cf_section_name1(conf); if (inst->timeout > 10000) { cf_log_err(conf, "timeout must be 0 to 10000"); return -1; } MEM(inst->xlat_a_name = talloc_typed_asprintf(inst, "%s-a", inst->name)); MEM(inst->xlat_aaaa_name = talloc_typed_asprintf(inst, "%s-aaaa", inst->name)); MEM(inst->xlat_ptr_name = talloc_typed_asprintf(inst, "%s-ptr", inst->name)); if (xlat_register(inst, inst->xlat_a_name, xlat_a, NULL, NULL, 0, XLAT_DEFAULT_BUF_LEN, false) || xlat_register(inst, inst->xlat_aaaa_name, xlat_aaaa, NULL, NULL, 0, XLAT_DEFAULT_BUF_LEN, false) || xlat_register(inst, inst->xlat_ptr_name, xlat_ptr, NULL, NULL, 0, XLAT_DEFAULT_BUF_LEN, false)) { cf_log_err(conf, "Failed registering xlats"); return -1; } return 0; }
static int mod_instantiate(CONF_SECTION *conf, void *instance) { static bool version_done; REDIS_INST *inst = instance; if (!version_done) { version_done = true; INFO("rlm_redis: libhiredis version: %i.%i.%i", HIREDIS_MAJOR, HIREDIS_MINOR, HIREDIS_PATCH); } inst->xlat_name = cf_section_name2(conf); if (!inst->xlat_name) inst->xlat_name = cf_section_name1(conf); xlat_register(inst->xlat_name, redis_xlat, NULL, inst); /* FIXME! */ inst->pool = fr_connection_pool_module_init(conf, inst, mod_conn_create, NULL, NULL); if (!inst->pool) { return -1; } inst->redis_query = rlm_redis_query; inst->redis_finish_query = rlm_redis_finish_query; return 0; }
static int mod_bootstrap(void *instance, CONF_SECTION *conf) { rlm_redis_t *inst = instance; char *name; xlat_t const *xlat; inst->name = cf_section_name2(conf); if (!inst->name) inst->name = cf_section_name1(conf); xlat_register(inst, inst->name, redis_xlat, NULL, NULL, 0, XLAT_DEFAULT_BUF_LEN, false); /* * %{redis_node:<key>[ idx]} */ name = talloc_asprintf(NULL, "%s_node", inst->name); xlat = xlat_async_register(inst, name, redis_node_xlat); xlat_async_instantiate_set(xlat, redis_xlat_instantiate, rlm_redis_t *, NULL, inst); talloc_free(name); name = talloc_asprintf(NULL, "%s_remap", inst->name); xlat = xlat_async_register(inst, name, redis_remap_xlat); xlat_async_instantiate_set(xlat, redis_xlat_instantiate, rlm_redis_t *, NULL, inst); talloc_free(name); return 0; }
static int krb5_instantiate(CONF_SECTION *conf, void *instance) { rlm_krb5_t *inst = instance; krb5_error_code ret; #ifndef HEIMDAL_KRB5 krb5_keytab keytab; char keytab_name[200]; char *princ_name; #endif #ifdef HEIMDAL_KRB5 DEBUG("Using Heimdal Kerberos library"); #else DEBUG("Using MIT Kerberos library"); #endif #ifndef KRB5_IS_THREAD_SAFE if (!krb5_is_thread_safe()) { WDEBUG("libkrb5 is not threadsafe, recompile it, and the server with thread support enabled"); WDEBUG("rlm_krb5 will run in single threaded mode, performance may be degraded"); } else { WDEBUG("Build time libkrb5 was not threadsafe, but run time library claims to be"); WDEBUG("Reconfigure and recompile rlm_krb5 to enable thread support"); } #endif inst->xlat_name = cf_section_name2(conf); if (!inst->xlat_name) { inst->xlat_name = cf_section_name1(conf); } ret = krb5_init_context(&inst->context); if (ret) { ERROR("rlm_krb5 (%s): context initialisation failed: %s", inst->xlat_name, rlm_krb5_error(NULL, ret)); return -1; } /* * Split service principal into service and host components * they're needed to build the server principal in MIT, * and to set the validation service in Heimdal. */ if (inst->service_princ) { size_t len; /* Service principal appears to contain a host component */ inst->hostname = strchr(inst->service_princ, '/'); if (inst->hostname) { len = (inst->hostname - inst->service_princ); inst->hostname++; } else { len = strlen(inst->service_princ); } if (len) { inst->service = talloc_array(inst, char, (len + 1)); strlcpy(inst->service, inst->service_princ, len + 1); } }
/* * Instantiate the module. */ static int mod_instantiate(void *instance, CONF_SECTION *conf) { rlm_logtee_t *inst = instance; char prefix[100]; /* * Escape filenames only if asked. */ if (inst->file.escape) { inst->file.escape_func = rad_filename_escape; } else { inst->file.escape_func = rad_filename_make_safe; } inst->log_dst = fr_str2int(logtee_dst_table, inst->log_dst_str, LOGTEE_DST_INVALID); if (inst->log_dst == LOGTEE_DST_INVALID) { cf_log_err(conf, "Invalid log destination \"%s\"", inst->log_dst_str); return -1; } inst->name = cf_section_name2(conf); if (!inst->name) inst->name = cf_section_name1(conf); snprintf(prefix, sizeof(prefix), "rlm_logtee (%s)", inst->name); FR_SIZE_BOUND_CHECK("buffer_depth", inst->buffer_depth, >=, (size_t)1); FR_SIZE_BOUND_CHECK("buffer_depth", inst->buffer_depth, <=, (size_t)1000000); /* 1 Million messages */ /* * Setup the logging destination */ switch (inst->log_dst) { case LOGTEE_DST_FILE: cf_log_err(conf, "Teeing to files NYI"); return -1; case LOGTEE_DST_UNIX: #ifndef HAVE_SYS_UN_H cf_log_err(conf, "Unix sockets are not supported on this sytem"); return -1; #endif case LOGTEE_DST_UDP: break; case LOGTEE_DST_TCP: break; case LOGTEE_DST_INVALID: rad_assert(0); break; } inst->delimiter_len = talloc_array_length(inst->delimiter) - 1; return 0; }
/** Iterate over all client attribute pairs and create client pair data using JSON element names * * If we hit a CONF_SECTION we recurse and process its CONF_PAIRS as well to support nested * configurations sections. * * @param client The new client config section using the mapped names. * @param map The client attribute section from the module configuration. * @param json JSON object representation of a client document fetched from Couchbase. * @param docid Document id. * @return Returns 0 on success, -1 on error. */ int _mod_client_map_section(CONF_SECTION *client, CONF_SECTION const *map, json_object *json, char const *docid) { CONF_ITEM const *ci; for (ci = cf_item_find_next(map, NULL); ci != NULL; ci = cf_item_find_next(map, ci)) { CONF_PAIR const *cp; char const *attribute; char const *element; json_object *jval; /* * Recursively process map subsection */ if (cf_item_is_section(ci)) { CONF_SECTION *cs, *cc; /* local scoped for new section */ cs = cf_itemtosection(ci); cc = cf_section_alloc(client, cf_section_name1(cs), cf_section_name2(cs)); if (!cc) return -1; cf_section_add(client, cc); if (_mod_client_map_section(cc, cs, json, docid) != 0) { return -1; } /* continue on to the next item */ continue; } /* create pair from item and get attribute name and value */ cp = cf_itemtopair(ci); attribute = cf_pair_attr(cp); element = cf_pair_value(cp); /* attempt to find element in json object */ if (!json_object_object_get_ex(json, element, &jval)) { /* skip this item */ continue; } /* allocate config pair */ cp = cf_pair_alloc(client, attribute, json_object_get_string(jval), T_OP_SET, T_SINGLE_QUOTED_STRING); /* check pair */ if (!cp) { ERROR("rlm_couchbase: failed allocating config pair '%s' = '%s'", attribute, json_object_get_string(jval)); return -1; } /* add pair to section */ cf_item_add(client, cf_pairtoitem(cp)); } /* return success */ return 0; }
static int mod_bootstrap(void *instance, CONF_SECTION *conf) { rlm_redis_t *inst = instance; inst->name = cf_section_name2(conf); if (!inst->name) inst->name = cf_section_name1(conf); xlat_register(inst, inst->name, redis_xlat, NULL, NULL, 0, XLAT_DEFAULT_BUF_LEN, false); return 0; }
static int mod_bootstrap(void *instance, CONF_SECTION *conf) { rlm_delay_t *inst = instance; xlat_t const *xlat; inst->xlat_name = cf_section_name2(conf); if (!inst->xlat_name) inst->xlat_name = cf_section_name1(conf); xlat = xlat_async_register(inst, inst->xlat_name, xlat_delay); xlat_async_instantiate_set(xlat, mod_xlat_instantiate, rlm_delay_t *, NULL, inst); return 0; }
static int rediswho_instantiate(CONF_SECTION * conf, void ** instance) { module_instance_t *modinst; rlm_rediswho_t *inst; /* * Set up a storage area for instance data */ inst = *instance = rad_malloc(sizeof (*inst)); memset(inst, 0, sizeof (*inst)); /* * If the configuration parameters can't be parsed, then * fail. */ if (cf_section_parse(conf, inst, module_config) < 0) { free(inst); return -1; } inst->xlat_name = cf_section_name2(conf); if (!inst->xlat_name) inst->xlat_name = cf_section_name1(conf); inst->xlat_name = strdup(inst->xlat_name); inst->cs = conf; modinst = find_module_instance(cf_section_find("modules"), inst->redis_instance_name, 1); if (!modinst) { radlog(L_ERR, "rediswho: failed to find module instance \"%s\"", inst->redis_instance_name); rediswho_detach(inst); return -1; } if (strcmp(modinst->entry->name, "rlm_redis") != 0) { radlog(L_ERR, "rediswho: Module \"%s\"" " is not an instance of the redis module", inst->redis_instance_name); rediswho_detach(inst); return -1; } inst->redis_inst = (REDIS_INST *) modinst->insthandle; return 0; }
/** * Instantiate module. * @param[in] conf Module config. * @param[in] instance Module instance. * @return Zero on success. */ static int mod_instantiate(CONF_SECTION *conf, void *instance) { rlm_mongodb_t *inst = instance; inst->name = cf_section_name2(conf); if (!inst->name) { inst->name = cf_section_name1(conf); } if (!strcasecmp(inst->cfg.action, "get")) { inst->action = RLM_MONGODB_GET; cf_log_err_cs(conf, "action 'get' is not implemented"); goto err; } else if (!strcasecmp(inst->cfg.action, "set")) { inst->action = RLM_MONGODB_SET; } else { cf_log_err_cs(conf, "invalid 'action', use'get' or 'set'"); goto err; } if (inst->cfg.remove && inst->cfg.update_query) { cf_log_err_cs(conf, "'update_query' and 'remove' can't be used at the same time"); goto err; } else if (!inst->cfg.remove && !inst->cfg.update_query) { cf_log_err_cs(conf, "'update_query' or 'remove' must be set for 'set' action"); goto err; } if (!cf_pair_find(conf, "pool")) { if (!inst->cfg.server) { cf_log_err_cs(conf, "Invalid or missing 'server' option"); goto err; } } else { if (inst->cfg.server) { cf_log_err_cs(conf, "Can't use server option when foreign connection pool specified"); goto err; } } mongoc_init(); mongoc_log_set_handler(mongoc_log_handler, inst); inst->pool = fr_connection_pool_module_init(conf, inst, mod_conn_create, NULL, inst->name); if (!inst->pool) { goto err; } return 0; err: return -1; }
static int mod_bootstrap(CONF_SECTION *conf, void *instance) { rlm_perl_t *inst = instance; char const *xlat_name; xlat_name = cf_section_name2(conf); if (!xlat_name) xlat_name = cf_section_name1(conf); xlat_register(xlat_name, perl_xlat, NULL, inst); return 0; }
static int mod_instantiate(CONF_SECTION *conf, void *instance) { const char *name; rlm_soh_t *inst = instance; name = cf_section_name2(conf); if (!name) name = cf_section_name1(conf); inst->xlat_name = name; if (!inst->xlat_name) return -1; xlat_register(inst->xlat_name, soh_xlat, inst); return 0; }
static int mod_bootstrap(void *instance, CONF_SECTION *conf) { rlm_date_t *inst = instance; inst->xlat_name = cf_section_name2(conf); if (!inst->xlat_name) { inst->xlat_name = cf_section_name1(conf); } xlat_register(inst, inst->xlat_name, xlat_date_convert, NULL, NULL, 0, XLAT_DEFAULT_BUF_LEN, true); return 0; }
static int mod_bootstrap(CONF_SECTION *conf, void *instance) { REDIS_INST *inst = instance; INFO("rlm_redis: libhiredis version: %i.%i.%i", HIREDIS_MAJOR, HIREDIS_MINOR, HIREDIS_PATCH); inst->xlat_name = cf_section_name2(conf); if (!inst->xlat_name) inst->xlat_name = cf_section_name1(conf); xlat_register(inst->xlat_name, redis_xlat, NULL, inst); return 0; }
static int mod_bootstrap(void *instance, CONF_SECTION *conf) { rlm_perl_t *inst = instance; char const *xlat_name; xlat_name = cf_section_name2(conf); if (!xlat_name) xlat_name = cf_section_name1(conf); xlat_register(inst, xlat_name, perl_xlat, NULL, NULL, 0, XLAT_DEFAULT_BUF_LEN, false); return 0; }
static int mod_bootstrap(void *instance, CONF_SECTION *conf) { char const *name; rlm_soh_t *inst = instance; name = cf_section_name2(conf); if (!name) name = cf_section_name1(conf); inst->xlat_name = name; if (!inst->xlat_name) return -1; xlat_register(inst, inst->xlat_name, soh_xlat, NULL, NULL, 0, XLAT_DEFAULT_BUF_LEN, true); return 0; }
static int mod_bootstrap(CONF_SECTION *conf, void *instance) { rlm_rest_t *inst = instance; inst->xlat_name = cf_section_name2(conf); if (!inst->xlat_name) inst->xlat_name = cf_section_name1(conf); /* * Register the rest xlat function */ xlat_register(inst->xlat_name, rest_xlat, rest_uri_escape, inst); xlat_register("jsonquote", jsonquote_xlat, NULL, inst); return 0; }
/** Set which types of packets we can parse * * @param[in] ctx to allocate data in (instance of rlm_radius). * @param[out] out Where to write the parsed data. * @param[in] parent Base structure address. * @param[in] ci #CONF_PAIR specifying the name of the type module. * @param[in] rule unused. * @return * - 0 on success. * - -1 on failure. */ static int type_parse(UNUSED TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, UNUSED CONF_PARSER const *rule) { char const *type_str = cf_pair_value(cf_item_to_pair(ci)); CONF_SECTION *cs = cf_item_to_section(cf_parent(ci)); fr_dict_enum_t const *type_enum; uint32_t code; /* * Must be the RADIUS module */ rad_assert(cs && (strcmp(cf_section_name1(cs), "radius") == 0)); /* * Allow the process module to be specified by * packet type. */ type_enum = fr_dict_enum_by_alias(attr_packet_type, type_str, -1); if (!type_enum) { invalid_code: cf_log_err(ci, "Unknown or invalid RADIUS packet type '%s'", type_str); return -1; } code = type_enum->value->vb_uint32; /* * Status-Server packets cannot be proxied. */ if (code == FR_CODE_STATUS_SERVER) { cf_log_err(ci, "Invalid setting of 'type = Status-Server'. Status-Server packets cannot be proxied."); return -1; } if (!code || (code >= FR_MAX_PACKET_CODE) || (!type_interval_config[code].name)) goto invalid_code; /* * If we're doing async proxying, push the timers for the * various packet types. */ cf_section_rule_push(cs, &type_interval_config[code]); memcpy(out, &code, sizeof(code)); return 0; }
static int mod_bootstrap(CONF_SECTION *conf, void *instance) { rlm_cache_t *inst = instance; inst->cs = conf; inst->xlat_name = cf_section_name2(conf); if (!inst->xlat_name) inst->xlat_name = cf_section_name1(conf); /* * Register the cache xlat function */ xlat_register(inst->xlat_name, cache_xlat, NULL, inst); return 0; }
static int mod_instantiate(CONF_SECTION *conf, void *instance) { rlm_idn_t *inst = instance; char const *xlat_name; xlat_name = cf_section_name2(conf); if (!xlat_name) { xlat_name = cf_section_name1(conf); } inst->xlat_name = xlat_name; xlat_register(inst->xlat_name, xlat_idna, NULL, inst); return 0; }
static int mod_bootstrap(void *instance, CONF_SECTION *conf) { rlm_chap_t *inst = instance; inst->name = cf_section_name2(conf); if (!inst->name) inst->name = cf_section_name1(conf); if (fr_dict_enum_add_alias_next(attr_auth_type, inst->name) < 0) { PERROR("Failed adding %s alias", attr_auth_type->name); return -1; } inst->auth_type = fr_dict_enum_by_alias(attr_auth_type, inst->name, -1); rad_assert(inst->auth_type); return 0; }
static int redis_instantiate(CONF_SECTION *conf, void **instance) { REDIS_INST *inst; const char *xlat_name; /* * Set up a storage area for instance data */ inst = rad_malloc(sizeof (REDIS_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) { free(inst); return -1; } xlat_name = cf_section_name2(conf); if (!xlat_name) xlat_name = cf_section_name1(conf); inst->xlat_name = strdup(xlat_name); xlat_register(inst->xlat_name, (RAD_XLAT_FUNC)redis_xlat, inst); inst->pool = fr_connection_pool_init(conf, inst, redis_create_conn, NULL, redis_delete_conn); if (!inst->pool) { redis_detach(inst); return -1; } inst->redis_query = rlm_redis_query; inst->redis_finish_query = rlm_redis_finish_query; inst->redis_escape_func = redis_escape_func; *instance = inst; return 0; }