From: Arran Cudbard-Bell Date: Tue, 4 Dec 2012 23:30:14 +0000 (+0000) Subject: Remove last traces of do_xlat from rlm_ldap, add %{xlat:} expansion X-Git-Tag: release_3_0_0_beta1~1429 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=677fdedd00bcd429563fc7cdf8e670588277d253;p=thirdparty%2Ffreeradius-server.git Remove last traces of do_xlat from rlm_ldap, add %{xlat:} expansion --- diff --git a/src/main/xlat.c b/src/main/xlat.c index c3b9370e085..94c3785d61e 100644 --- a/src/main/xlat.c +++ b/src/main/xlat.c @@ -666,6 +666,29 @@ static size_t xlat_string(UNUSED void *instance, REQUEST *request, return len; } +/** + * @brief xlat expand string attribute value + */ +static size_t xlat_xlat(UNUSED void *instance, REQUEST *request, + const char *fmt, char *out, size_t outlen) +{ + VALUE_PAIR *vp; + + while (isspace((int) *fmt)) fmt++; + + if (outlen < 3) { + nothing: + *out = '\0'; + return 0; + } + + if (radius_get_vp(request, fmt, &vp) < 0) goto nothing; + + if (!vp) goto nothing; + + return radius_xlat(out, outlen, vp->vp_strvalue, request, NULL, NULL); +} + #ifdef HAVE_REGEX_H /* * @brief Expand regexp matches %{0} to %{8} @@ -832,6 +855,7 @@ int xlat_register(const char *module, RAD_XLAT_FUNC func, void *instance) XLAT_REGISTER(hex); XLAT_REGISTER(base64); XLAT_REGISTER(string); + XLAT_REGISTER(xlat); XLAT_REGISTER(module); #ifdef HAVE_REGEX_H diff --git a/src/modules/rlm_ldap/rlm_ldap.c b/src/modules/rlm_ldap/rlm_ldap.c index 54a2464c17f..1b9a80dfaaf 100644 --- a/src/modules/rlm_ldap/rlm_ldap.c +++ b/src/modules/rlm_ldap/rlm_ldap.c @@ -64,9 +64,7 @@ typedef struct { * RADIUS attribute to LDAP attribute maps */ VALUE_PAIR_MAP *user_map; /* Applied to users and profiles */ - - int do_xlat; - + /* * Access related configuration */ @@ -264,9 +262,6 @@ static const CONF_PARSER module_config[] = { /* * Terrible things which should be deleted. */ - {"do_xlat", PW_TYPE_BOOLEAN, - offsetof(ldap_instance,do_xlat), NULL, "yes"}, - { "profiles", PW_TYPE_SUBSECTION, 0, NULL, (const void *) attr_config }, { "group", PW_TYPE_SUBSECTION, 0, NULL, (const void *) group_config },