Load versioned libs.
authorfcusack <fcusack>
Sun, 26 May 2002 10:06:41 +0000 (10:06 +0000)
committerfcusack <fcusack>
Sun, 26 May 2002 10:06:41 +0000 (10:06 +0000)
If a module is specified as 'FOO' in radiusd.conf, the module
loader will now try to load rlm_FOO-MAJOR.MINOR.  This can be
overridden by explicitly starting the module name with rlm_,
eg rlm_FOO or rlm_FOO-0.1.  This allows someone to have their
own modules which they don't have to recompile to use against
a newer core (assuming the interface is still compatible--a
method should be added to check this).  This would be useful
for folks that have private modules or modules they wish to
distribute separately from freeradius as a binary.

This will force folks to upgrade the modules when they upgrade
freeradius, a common problem in the past.

It is no longer possible to have a module named rlm_rlm_*, not
that that was ever useful.

src/main/Makefile
src/main/modules.c
src/modules/rules.mak

index ec639bd..0907227 100644 (file)
@@ -14,6 +14,8 @@ CFLAGS                += -I../include $(SNMP_INCLUDE)
 LDFLAGS                += -L../lib
 LIBS           += -lradius $(SNMP_LIBS)
 MODULE_LIBS    = $(STATIC_MODULES)
+VFLAGS         = -DRADIUSD_MAJOR_VERSION=$(RADIUSD_MAJOR_VERSION)
+VFLAGS         += -DRADIUSD_MINOR_VERSION=$(RADIUSD_MINOR_VERSION)
 
 #
 #  Not using shared libraries, add in ALL known static modules
@@ -56,7 +58,7 @@ timestr.o: timestr.c $(INCLUDES)
        $(CC) $(CFLAGS) -c timestr.c
 
 modules.o:  modules.c $(INCLUDES)
-       $(CC) $(CFLAGS) $(INCLTDL) -c modules.c
+       $(CC) $(CFLAGS) $(VFLAGS) $(INCLTDL) -c modules.c
 
 modcall.o:  modcall.c $(INCLUDES)
        $(CC) $(CFLAGS) $(INCLTDL) -c modcall.c
index bb94ff2..aedd1d5 100644 (file)
@@ -198,6 +198,8 @@ static module_list_t *linkto_module(const char *module_name,
 {
        module_list_t **last, *node;
        lt_dlhandle *handle;
+       char module_struct[256];
+       char *p;
 
        /*
         *      Look through the global module library list for the
@@ -238,7 +240,12 @@ static module_list_t *linkto_module(const char *module_name,
        /*
         *      Link to the module's rlm_FOO{} module structure.
         */
-       node->module = (module_t *) lt_dlsym(node->handle, module_name);
+       /* module_name has the version embedded; strip it. */
+       strcpy(module_struct, module_name);
+       p = strrchr(module_struct, '-');
+       if (p)
+               *p = '\0';
+       node->module = (module_t *) lt_dlsym(node->handle, module_struct);
        if (!node->module) {
                radlog(L_ERR|L_CONS, "%s[%d] Failed linking to "
                                "%s structure in %s: %s\n",
@@ -336,9 +343,14 @@ module_instance_t *find_module_instance(const char *instname)
        node->insthandle = NULL;
        
        /*
-        *      Link to the module by name: rlm_FOO
+        *      Link to the module by name: rlm_FOO-major.minor
         */
-       snprintf(module_name, sizeof(module_name), "rlm_%s", name1);
+       if (strncmp(name1, "rlm_", 4))
+               snprintf(module_name, sizeof(module_name), "rlm_%s-%d.%d",
+                       name1, RADIUSD_MAJOR_VERSION, RADIUSD_MINOR_VERSION);
+       else
+               strNcpy(module_name, name1, sizeof(module_name));
+       /* XXX "radiusd.conf" is wrong here; must find cf filename */
        node->entry = linkto_module(module_name,
                        "radiusd.conf", cf_section_lineno(inst_cs));
        if (!node->entry) {
index 62efc3a..3c1a282 100644 (file)
@@ -69,7 +69,8 @@ ifneq ($(TARGET),)
 #
 #######################################################################
 $(TARGET).a: $(STATIC_OBJS)
-       $(LIBTOOL) --mode=link $(LD) -module -static $(CFLAGS) $(RLM_CFLAGS) $^ -o $@ 
+       $(LIBTOOL) --mode=link $(LD) -release $(RADIUSD_VERSION) \
+       -module -static $(CFLAGS) $(RLM_CFLAGS) $^ -o $@ 
 
 #
 #  If the module is in the list of static modules, then the "dynamic"
@@ -93,8 +94,9 @@ LINK_MODE=-static
 endif
 
 $(TARGET).la: $(DYNAMIC_OBJS)
-       $(LIBTOOL) --mode=link $(CC) -module $(LINK_MODE) $(CFLAGS) \
-       $(RLM_CFLAGS) $(RLM_LDFLAGS) -o $@ -rpath $(libdir) $^ $(RLM_LIBS) $(LIBS)
+       $(LIBTOOL) --mode=link $(CC) -release $(RADIUSD_VERSION) \
+       -module $(LINK_MODE) $(CFLAGS) $(RLM_CFLAGS) $(RLM_LDFLAGS) \
+       -o $@ -rpath $(libdir) $^ $(RLM_LIBS) $(LIBS)
 
 #######################################################################
 #