]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Added "instance" to xlat_unregister
authorAlan T. DeKok <aland@freeradius.org>
Fri, 13 Apr 2012 14:58:54 +0000 (16:58 +0200)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 13 Apr 2012 14:58:54 +0000 (16:58 +0200)
This is so that on HUP, a module can re-register, and over-ride
the old value.  When the old module is deleted, it de-registers
its xlat.  But because the instance is now different, it doesn't
delete the *new* xlat

src/include/radiusd.h
src/main/xlat.c
src/modules/rlm_exec/rlm_exec.c
src/modules/rlm_expr/rlm_expr.c
src/modules/rlm_ldap/rlm_ldap.c
src/modules/rlm_mschap/rlm_mschap.c
src/modules/rlm_perl/rlm_perl.c
src/modules/rlm_redis/rlm_redis.c
src/modules/rlm_soh/rlm_soh.c
src/modules/rlm_sql/rlm_sql.c

index 2809100a78e3fb7524962fc7e7fdcc630a3a1442..38890a5f58b99ae88e977e034b29720af17ad63f 100644 (file)
@@ -599,7 +599,8 @@ int            radius_xlat(char * out, int outlen, const char *fmt,
 typedef size_t (*RAD_XLAT_FUNC)(void *instance, REQUEST *, char *, char *, size_t, RADIUS_ESCAPE_STRING func);
 int            xlat_register(const char *module, RAD_XLAT_FUNC func,
                              void *instance);
-void           xlat_unregister(const char *module, RAD_XLAT_FUNC func);
+void           xlat_unregister(const char *module, RAD_XLAT_FUNC func,
+                               void *instance);
 void           xlat_free(void);
 
 /* threads.c */
index 25ea050e88ab59aecf06c6612b3841f37a825382..ca5207d3250fa1dc43bfb913ad2277c3875ede2c 100644 (file)
@@ -795,9 +795,9 @@ int xlat_register(const char *module, RAD_XLAT_FUNC func, void *instance)
  *     We can only have one function to call per name, so the
  *     passing of "func" here is extraneous.
  */
-void xlat_unregister(const char *module, RAD_XLAT_FUNC func)
+void xlat_unregister(const char *module, RAD_XLAT_FUNC func, void *instance)
 {
-       rbnode_t        *node;
+       xlat_t  *c;
        xlat_t          my_xlat;
 
        func = func;            /* -Wunused */
@@ -807,10 +807,12 @@ void xlat_unregister(const char *module, RAD_XLAT_FUNC func)
        strlcpy(my_xlat.module, module, sizeof(my_xlat.module));
        my_xlat.length = strlen(my_xlat.module);
 
-       node = rbtree_find(xlat_root, &my_xlat);
-       if (!node) return;
+       c = rbtree_finddata(xlat_root, &my_xlat);
+       if (!c) return;
+
+       if (c->instance != instance) return;
 
-       rbtree_delete(xlat_root, node);
+       rbtree_deletebydata(xlat_root, c);
 }
 
 /*
index f4c8a46b7f9e83499cef512a7b47b5ac3f49c78c..41002f81a6f15171766265365eb89436866fa89e 100644 (file)
@@ -160,7 +160,7 @@ static int exec_detach(void *instance)
        rlm_exec_t      *inst = instance;
 
        if (inst->xlat_name) {
-               xlat_unregister(inst->xlat_name, exec_xlat);
+               xlat_unregister(inst->xlat_name, exec_xlat, instance);
                free(inst->xlat_name);
        }
 
index 80e1f08aa49d8d36acee7343b4a698f3213dd128..bcb9bb98783afc2a44fe8e1d3c2c311ccab7f31e 100644 (file)
@@ -338,7 +338,7 @@ static int expr_detach(void *instance)
 {
        rlm_expr_t      *inst = instance;
 
-       xlat_unregister(inst->xlat_name, expr_xlat);
+       xlat_unregister(inst->xlat_name, expr_xlat, instance);
        pair_builtincompare_detach();
        free(inst->xlat_name);
 
index a2b5200bb7eef33923a13da5cdb1ae0d0870edd9..edda19d8252d3d8116cbe3c4209555f568411459 100644 (file)
@@ -2636,7 +2636,7 @@ ldap_detach(void *instance)
                free(inst->atts);
 
        paircompare_unregister(PW_LDAP_GROUP, ldap_groupcmp);
-       xlat_unregister(inst->xlat_name,ldap_xlat);
+       xlat_unregister(inst->xlat_name,ldap_xlat, instance);
        free(inst->xlat_name);
 
        free(inst);
index ea700047113389ee81fb7c5f351e8f4c1e13d79b..918befe44db4248257ee9dd233ce0152dd959c76 100644 (file)
@@ -554,7 +554,7 @@ static const CONF_PARSER module_config[] = {
 static int mschap_detach(void *instance){
 #define inst ((rlm_mschap_t *)instance)
        if (inst->xlat_name) {
-               xlat_unregister(inst->xlat_name, mschap_xlat);
+               xlat_unregister(inst->xlat_name, mschap_xlat, instance);
                free(inst->xlat_name);
        }
        free(instance);
index 4682ba507bc5214ccef5dc9335fac7862f644282..122d52db12d43d8c63745d0df74f56738f00344c 100644 (file)
@@ -978,7 +978,7 @@ static int perl_detach(void *instance)
        }
        }
 
-       xlat_unregister(inst->xlat_name, perl_xlat);
+       xlat_unregister(inst->xlat_name, perl_xlat, instance);
        free(inst->xlat_name);
 
 #ifdef USE_ITHREADS
index 515533e1c250d740a05082fbaa4173091cafe14c..5d6140a9104304d1281b08c74b196bbe344b054c 100644 (file)
@@ -268,7 +268,7 @@ static int redis_detach(void *instance)
        redis_poolfree(inst);
 
        if (inst->xlat_name) {
-               xlat_unregister(inst->xlat_name, (RAD_XLAT_FUNC)redis_xlat);
+               xlat_unregister(inst->xlat_name, (RAD_XLAT_FUNC)redis_xlat, instance);
                free(inst->xlat_name);
        }
        free(inst->xlat_name);
index b98a79cb4f41d19390f71df6650abfe329cb1465..92dd867176e8452003b88e2515e275e63bf91ba3 100644 (file)
@@ -108,7 +108,7 @@ static int soh_detach(void *instance) {
        rlm_soh_t       *inst = instance;
 
        if (inst->xlat_name) {
-               xlat_unregister(inst->xlat_name, soh_xlat);
+               xlat_unregister(inst->xlat_name, soh_xlat, instance);
                free(inst->xlat_name);
        }
        free(instance);
index c26bded430a8d8d0f2da5fc40697c2a1671dbfa6..6f75c13adff10cae40fa07a68223f85cda3605f2 100644 (file)
@@ -810,7 +810,7 @@ static int rlm_sql_detach(void *instance)
                }
 
                if (inst->config->xlat_name) {
-                       xlat_unregister(inst->config->xlat_name,(RAD_XLAT_FUNC)sql_xlat);
+                       xlat_unregister(inst->config->xlat_name,(RAD_XLAT_FUNC)sql_xlat, instance);
                        free(inst->config->xlat_name);
                }