]> 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 15:08:44 +0000 (17:08 +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 a0012058d96984c468004e61673b2063103361ab..f247cfab98b98134e7fc9c998320460cd4918fed 100644 (file)
@@ -716,7 +716,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 990bdf1e7f5326b2d7c1cb591e42bc634cfb1a50..92c6ab52c45d23f9c06b5558617942fa2005e3a7 100644 (file)
@@ -883,9 +883,9 @@ int xlat_register(const char *module, RAD_XLAT_FUNC func, void *instance)
  * @param func Unused
  * @return Void.
  */
-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 */
@@ -895,10 +895,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 1dcc38665bf7311b392a175b5e7fd2f94ea0fd08..9d8298cc4979b9a3e012d853186e4340a72f1416 100644 (file)
@@ -162,7 +162,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 b98afa775bba1d914c0be8a34e2a84f34d4e7937..abd3e285d26a4f9a173f33ba2ba90d03a2b005ab 100644 (file)
@@ -337,7 +337,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 6d53e1db6b110e0bf9a220b63f1f8273c7a10a70..91d367a971e29cabcdb33826ead320e0e40619df 100644 (file)
@@ -2596,7 +2596,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 7e8be0c537d70b08342e24629b6b4830dc29be40..8496aa62fdd885c879e37261a86237a0b111e24d 100644 (file)
@@ -582,7 +582,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 61411c4ca31b02e2b5d9cac55cc5513e4008f544..1b410b2d02723fcb0f1bb204931c0bb052dbf6fc 100644 (file)
@@ -1000,7 +1000,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 144f319faea8f24cbad0f72d671cce0d512e1b0a..958c125e96a138c357d819ff2d4cbd7ecfb76f7d 100644 (file)
@@ -232,7 +232,7 @@ static int redis_detach(void *instance)
        fr_connection_pool_delete(inst->pool);
 
        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 4f3d673b3cc1d235208fc3f580ea26a240196551..1e459f9fa6b40be8dd8244acd4904d7687f24823 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 2fc0684fbb4f6ad621ae54cb983e4e1eb2d065d6..36a67bfdd422da6400ef12924263e700b5582499 100644 (file)
@@ -804,7 +804,7 @@ static int rlm_sql_detach(void *instance)
                if (inst->pool) sql_poolfree(inst);
 
                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);
                }