]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Remove last traces of do_xlat from rlm_ldap, add %{xlat:<attribute>} expansion
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 4 Dec 2012 23:30:14 +0000 (23:30 +0000)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 4 Dec 2012 23:30:46 +0000 (23:30 +0000)
src/main/xlat.c
src/modules/rlm_ldap/rlm_ldap.c

index c3b9370e0859b0096cfd7d118985116d2da8f9b1..94c3785d61e1028cfc3dca89a8580144776e29b7 100644 (file)
@@ -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
index 54a2464c17f8c5f8121eb46bf1c573839e96e930..1b9a80dfaaf5729f05a764f84e123cc87916e813 100644 (file)
@@ -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 },