Changeset 180

Show
Ignore:
Timestamp:
04/28/07 23:56:58 (17 months ago)
Author:
smoku
Message:

Dynamically loading auth/reg/storage modules. Closes #52

Location:
trunk
Files:
9 modified
1 copied
14 moved

Legend:

Unmodified
Added
Removed
  • trunk/c2s/authreg.c

    r177 r180  
    2020 
    2121#include "c2s.h" 
    22  
    2322#include <stringprep.h> 
     23#include <dlfcn.h> 
    2424 
    2525/* authreg module manager */ 
    26  
    27 /* if you add a module, you'll need to update these arrays */ 
    28  
    29 #ifdef STORAGE_MYSQL 
    30 extern int ar_mysql_init(authreg_t); 
    31 #endif 
    32 #ifdef STORAGE_PGSQL 
    33 extern int ar_pgsql_init(authreg_t); 
    34 #endif 
    35 #ifdef STORAGE_DB 
    36 extern int ar_db_init(authreg_t); 
    37 #endif 
    38 #ifdef STORAGE_LDAP 
    39 extern int ar_ldap_init(authreg_t); 
    40 #endif 
    41 #ifdef STORAGE_PAM 
    42 extern int ar_pam_init(authreg_t); 
    43 #endif 
    44 #ifdef STORAGE_PIPE 
    45 extern int ar_pipe_init(authreg_t); 
    46 #endif 
    47 #ifdef STORAGE_ANON 
    48 extern int ar_anon_init(authreg_t); 
    49 #endif 
    50 #ifdef STORAGE_SQLITE 
    51 extern int ar_sqlite_init(authreg_t); 
    52 #endif 
    53  
    54 static const char *module_names[] = { 
    55 #ifdef STORAGE_MYSQL 
    56     "mysql", 
    57 #endif 
    58 #ifdef STORAGE_PGSQL 
    59     "pgsql", 
    60 #endif 
    61 #ifdef STORAGE_DB 
    62     "db", 
    63 #endif 
    64 #ifdef STORAGE_LDAP 
    65     "ldap", 
    66 #endif 
    67 #ifdef STORAGE_PAM 
    68     "pam", 
    69 #endif 
    70 #ifdef STORAGE_PIPE 
    71     "pipe", 
    72 #endif 
    73 #ifdef STORAGE_ANON 
    74     "anon", 
    75 #endif 
    76 #ifdef STORAGE_SQLITE 
    77     "sqlite", 
    78 #endif 
    79     NULL 
    80 }; 
    81  
    82 ar_module_init_fn module_inits[] = { 
    83 #ifdef STORAGE_MYSQL 
    84     ar_mysql_init, 
    85 #endif 
    86 #ifdef STORAGE_PGSQL 
    87     ar_pgsql_init, 
    88 #endif 
    89 #ifdef STORAGE_DB 
    90     ar_db_init, 
    91 #endif 
    92 #ifdef STORAGE_LDAP 
    93     ar_ldap_init, 
    94 #endif 
    95 #ifdef STORAGE_PAM 
    96     ar_pam_init, 
    97 #endif 
    98 #ifdef STORAGE_PIPE 
    99     ar_pipe_init, 
    100 #endif 
    101 #ifdef STORAGE_ANON 
    102     ar_anon_init, 
    103 #endif 
    104 #ifdef STORAGE_SQLITE 
    105     ar_sqlite_init, 
    106 #endif 
    107     NULL 
    108 }; 
    10926 
    11027typedef struct _authreg_error_st { 
     
    11734/** get a handle for the named module */ 
    11835authreg_t authreg_init(c2s_t c2s, char *name) { 
    119     int n; 
    120     ar_module_init_fn init = NULL; 
     36    char mod_fullpath[PATH_MAX], *modules_path; 
     37    ar_module_init_fn init_fn = NULL; 
    12138    authreg_t ar; 
    122  
    123     /* hunt it down */ 
    124     n = 0; 
    125     while(module_names[n] != NULL) 
    126     { 
    127         if(strcmp(module_names[n], name) == 0) 
    128         { 
    129             init = module_inits[n]; 
    130             break; 
    131         } 
    132         n++; 
    133     } 
    134  
    135     if(init == NULL) 
    136     { 
    137         log_write(c2s->log, LOG_ERR, "no such auth module '%s'", name); 
     39    void *handle; 
     40 
     41    /* load authreg module */ 
     42    modules_path = config_get_one(c2s->config, "authreg.path", 0); 
     43    if (modules_path != NULL) 
     44        log_write(c2s->log, LOG_NOTICE, "modules search path: %s", modules_path); 
     45    else 
     46        log_write(c2s->log, LOG_NOTICE, "modules search path undefined, using default: "LIBRARY_DIR); 
     47 
     48    log_write(c2s->log, LOG_INFO, "loading '%s' authreg module", name); 
     49#ifndef WIN32 
     50    if (modules_path != NULL) 
     51        snprintf(mod_fullpath, PATH_MAX, "%s/authreg_%s.so", modules_path, name); 
     52    else 
     53        snprintf(mod_fullpath, PATH_MAX, "%s/authreg_%s.so", LIBRARY_DIR, name); 
     54    handle = dlopen(mod_fullpath, RTLD_LAZY); 
     55    if (handle != NULL) 
     56        init_fn = dlsym(handle, "ar_init"); 
     57#else 
     58    if (modules_path != NULL) 
     59        snprintf(mod_fullpath, PATH_MAX, "%s\\authreg_%s.dll", modules_path, name); 
     60    else 
     61        snprintf(mod_fullpath, PATH_MAX, "authreg_%s.dll", name); 
     62    handle = (void*) LoadLibrary(mod_fullpath); 
     63    if (handle != NULL) 
     64        init_fn = GetProcAddress((HMODULE) handle, "ar_init"); 
     65#endif 
     66 
     67    if (handle != NULL && init_fn != NULL) { 
     68        log_debug(ZONE, "preloaded module '%s' (not initialized yet)", name); 
     69    } else { 
     70#ifndef WIN32 
     71        log_write(c2s->log, LOG_ERR, "failed loading authreg module '%s' (%s)", name, dlerror()); 
     72        if (handle != NULL) 
     73            dlclose(handle); 
     74#else 
     75        log_write(c2s->log, LOG_ERR, "failed loading authreg module '%s' (errcode: %x)", name, GetLastError()); 
     76        if (handle != NULL) 
     77            FreeLibrary((HMODULE) handle); 
     78#endif 
    13879        return NULL; 
    13980    } 
     
    14687 
    14788    /* call the initialiser */ 
    148     if((init)(ar) != 0) 
    149     { 
    150         log_write(c2s->log, LOG_ERR, "failed to initialise auth module '%s'", name); 
     89    if((init_fn)(ar) != 0) 
     90    { 
     91        log_write(c2s->log, LOG_ERR, "failed to initialize auth module '%s'", name); 
    15192        authreg_free(ar); 
    15293        return NULL; 
     
    162103     
    163104    /* its good */ 
    164     log_write(c2s->log, LOG_NOTICE, "initialised auth module '%s'", name); 
     105    log_write(c2s->log, LOG_NOTICE, "initialized auth module '%s'", name); 
    165106 
    166107    return ar; 
  • trunk/c2s/Makefile.am

    r175 r180  
    1 INCLUDES = -DCONFIG_DIR=\"$(sysconfdir)\" \ 
    2             $(MYSQL_CFLAGS) \ 
    3             $(PGSQL_CFLAGS) 
    4  
    51bin_PROGRAMS = c2s 
    62 
    7 c2s_SOURCES = authreg.c authreg_anon.c authreg_db.c authreg_ldap.c authreg_pam.c authreg_pipe.c bind.c c2s.c main.c sm.c 
    8  
    9 # MySQL support 
    10 if STORAGE_MYSQL 
    11 c2s_SOURCES += authreg_mysql.c 
    12 endif 
    13  
    14 # PostgreSQL support 
    15 if STORAGE_PGSQL 
    16 c2s_SOURCES += authreg_pgsql.c 
    17 endif 
    18  
    19 # SQLite3 support 
    20 if STORAGE_SQLITE 
    21 c2s_SOURCES += authreg_sqlite.c 
    22 endif 
    23  
     3c2s_SOURCES = authreg.c bind.c c2s.c main.c sm.c 
     4c2s_CPPFLAGS = -DCONFIG_DIR=\"$(sysconfdir)\" -DLIBRARY_DIR=\"$(pkglibdir)\" 
     5c2s_LDFLAGS = -Wl,-export-dynamic 
    246 
    257noinst_HEADERS = c2s.h 
     
    2810            $(top_builddir)/mio/libmio.la \ 
    2911            $(top_builddir)/util/libutil.la \ 
    30             $(top_builddir)/subst/libsubst.la \ 
    31             $(MYSQL_LIBS)   \ 
    32             $(PGSQL_LIBS)   \ 
    33             $(SQLITE_LIBS) 
    34  
     12            $(top_builddir)/subst/libsubst.la  
  • trunk/configure.in

    r177 r180  
    2929dnl basic tools 
    3030AC_PROG_CC 
     31AM_PROG_CC_C_O 
    3132AC_PROG_MAKE_SET 
    3233 
     
    328329AC_MSG_CHECKING([if user wants MySQL support]) 
    329330AC_ARG_ENABLE([mysql],  
    330         AC_HELP_STRING([--enable-mysql], [enable MySQL authreg/storage support (no)]), 
     331        AC_HELP_STRING([--enable-mysql], [enable MySQL auth/reg/storage support (no)]), 
    331332        [enable_mysql=$enableval have_mysql=no], 
    332333        [enable_mysql=no         have_mysql=no]) 
     
    368369AC_MSG_CHECKING([if user wants PostgreSQL support]) 
    369370AC_ARG_ENABLE([pgsql],  
    370         AC_HELP_STRING([--enable-pgsql], [enable PostgreSQL authreg/storage support (no)]), 
     371        AC_HELP_STRING([--enable-pgsql], [enable PostgreSQL auth/reg/storage support (no)]), 
    371372        [enable_pgsql=$enableval have_pgsql=no], 
    372373        [enable_pgsql=no         have_pgsql=no]) 
     
    409410AC_MSG_CHECKING([if user wants SQLite3 support]) 
    410411AC_ARG_ENABLE([sqlite], 
    411         AS_HELP_STRING([--enable-sqlite], [enable SQLite3 authreg/storage support (no)]), 
     412        AS_HELP_STRING([--enable-sqlite], [enable SQLite3 auth/reg/storage support (no)]), 
    412413        [enable_sqlite=$enableval have_sqlite=no], 
    413414        [enable_sqlite=no         have_sqlite=no]) 
     
    430431                 
    431432dnl berkeley db 
    432 AC_ARG_ENABLE(db, AC_HELP_STRING([--enable-db], [enable Berkeley DB authreg/storage support (no)]), 
     433AC_ARG_ENABLE(db, AC_HELP_STRING([--enable-db], [enable Berkeley DB auth/reg/storage support (no)]), 
    433434              want_db=$enableval, want_db=no) 
    434435if test "x-$want_db" = "x-yes" ; then 
     
    466467        AC_MSG_ERROR([Berkeley DB >= 4.1.24 not found]) 
    467468    else 
    468         AC_DEFINE(STORAGE_DB,1,[Define to 1 if you want to use Berkeley DB for authreg/storage.]) 
    469     fi 
    470 fi 
     469        DB_LIBS="-l$lib" 
     470        AC_DEFINE(STORAGE_DB,1,[Define to 1 if you want to use Berkeley DB for auth/reg/storage.]) 
     471    fi 
     472fi 
     473AC_SUBST(DB_LIBS) 
     474AM_CONDITIONAL(STORAGE_DB, [test "x-$have_db_version" = "x-yes"]) 
    471475 
    472476 
     
    495499                                       AC_MSG_RESULT(no)) 
    496500    fi 
    497     if test "x-$want_ldap" = "x-yes" -a "x-$have_ldap_version" = "x-" ; then 
     501    if test "x-$have_ldap_version" = "x-" ; then 
    498502        AC_MSG_ERROR([OpenLDAP client libraries >= 2.1.0 not found]) 
    499503    else 
     504        LDAP_LIBS="-llber -lldap" 
    500505        AC_DEFINE(STORAGE_LDAP,1,[Define to 1 if you want to use OpenLDAP for auth/reg.]) 
    501506    fi 
    502507fi 
     508AC_SUBST(LDAP_LIBS) 
     509AM_CONDITIONAL(STORAGE_LDAP, [test "x-$have_ldap_version" = "x-yes"]) 
    503510 
    504511 
     
    514521        AC_MSG_ERROR([PAM application libraries not found]) 
    515522    else 
     523        have_pam="yes" 
     524        PAM_LIBS="-lpam" 
    516525        AC_DEFINE(STORAGE_PAM,1,[Define to 1 if you want to use PAM for auth/reg.]) 
    517526    fi 
    518527fi 
     528AC_SUBST(PAM_LIBS) 
     529AM_CONDITIONAL(STORAGE_PAM, [test "x-$have_pam" = "x-yes"]) 
    519530 
    520531 
     
    532543        AC_MSG_ERROR([Pipe auth/reg requirements (sys/wait.h, fork(), pipe(), wait()) not found]) 
    533544    else 
     545        have_pipe="yes" 
    534546        AC_DEFINE(STORAGE_PIPE,1,[Define to 1 if you want to use pipes for auth/reg.]) 
    535547    fi 
    536548fi 
     549AM_CONDITIONAL(STORAGE_PIPE, [test "x-$have_pipe" = "x-yes"]) 
    537550 
    538551 
     
    543556    AC_DEFINE(STORAGE_ANON,1,[Define to 1 if you want anonymous auth.]) 
    544557fi 
     558AM_CONDITIONAL(STORAGE_ANON, [test "x-$want_anon" = "x-yes"]) 
    545559 
    546560 
     
    551565    AC_DEFINE(STORAGE_FS,1,[Define to 1 if you want to use the filesystem for storage.]) 
    552566fi 
     567AM_CONDITIONAL(STORAGE_FS, [test "x-$want_fs" = "x-yes"]) 
     568 
    553569 
    554570dnl Oracle 
     
    557573        [ ac_oracle_home="$withval" ]) 
    558574 
    559 AC_ARG_ENABLE(oracle, AC_HELP_STRING([--enable-oracle], [enable Oracle authreg/storage support (no)]), 
     575AC_ARG_ENABLE(oracle, AC_HELP_STRING([--enable-oracle], [enable Oracle auth/reg/storage support (no)]), 
    560576              want_oracle=$enableval, want_oracle=no) 
    561577if test "x-$want_oracle" = "x-yes" ; then 
     
    578594                    CPPFLAGS="$save_cppflags" 
    579595                    LIBS="$save_libs" 
    580                      LDFLAGS="$save_ldflags" 
     596                    LDFLAGS="$save_ldflags" 
    581597                fi 
    582598       fi 
     
    588604        AC_MSG_ERROR([Oracle client libraries not found]) 
    589605    else 
    590         AC_DEFINE(STORAGE_ORACLE,1,[Define to 1 if you want to use Oracle for authreg/storage.]) 
    591     fi 
    592 fi 
     606        have_oracle="yes" 
     607        ORACLE_CPPFLAGS="-I$ac_oracle_home/rdbms/demo -I$ac_oracle_home/rdbms/public" 
     608        ORACLE_LIBS="-L$ac_oracle_home/lib" 
     609        ORACLE_LDFLAGS="-Wl,-rpath,$ac_oracle_home/lib" 
     610        AC_DEFINE(STORAGE_ORACLE,1,[Define to 1 if you want to use Oracle for auth/reg/storage.]) 
     611    fi 
     612fi 
     613AC_SUBST(ORACLE_CPPFLAGS) 
     614AC_SUBST(ORACLE_LIBS) 
     615AC_SUBST(ORACLE_LDFLAGS) 
     616AM_CONDITIONAL(STORAGE_ORACLE, [test "x-$have_pam" = "x-yes"]) 
    593617 
    594618 
     
    821845          s2s/Makefile \ 
    822846          sm/Makefile \ 
     847          storage/Makefile \ 
    823848          Doxyfile) 
  • trunk/etc/c2s.xml.dist.in

    r165 r180  
    255255  <!-- Authentication/registration database configuration --> 
    256256  <authreg> 
     257    <!-- Dynamic authreg modules path --> 
     258    <path>@pkglibdir@</path> 
     259 
    257260    <!-- Backend module to use --> 
    258261    <module>mysql</module> 
  • trunk/etc/sm.xml.dist.in

    r162 r180  
    7171  <!-- Storage database configuration --> 
    7272  <storage> 
     73    <!-- Dynamic storage modules path --> 
     74    <path>@pkglibdir@</path> 
     75 
    7376    <!-- By default, we use the MySQL driver for all storage --> 
    7477    <driver>mysql</driver> 
  • trunk/Makefile.am

    r77 r180  
    11EXTRA_DIST = PROTOCOL Doxyfile.in README.win32 contrib 
    22 
    3 SUBDIRS = etc tools man mio subst sx util c2s resolver router s2s sm 
     3SUBDIRS = etc tools man mio subst sx util c2s resolver router s2s sm storage 
    44 
    55docs: Doxyfile 
  • trunk/sm/Makefile.am

    r175 r180  
    1 INCLUDES = -DCONFIG_DIR=\"$(sysconfdir)\" \ 
    2            -DLIBRARY_DIR=\"$(pkglibdir)\" \ 
    3                    $(MYSQL_CFLAGS) 
    4                    $(PGSQL_CFLAGS) 
     1bin_PROGRAMS = sm 
    52 
    6 bin_PROGRAMS = sm 
    73pkglib_LTLIBRARIES = mod_active.la \ 
    84                  mod_announce.la \ 
     
    2925 
    3026noinst_HEADERS = sm.h 
     27 
    3128sm_SOURCES = aci.c \ 
    3229             dispatch.c \ 
     
    4037             sm.c \ 
    4138             user.c \ 
    42              storage.c \ 
    43              storage_db.c \ 
    44              storage_fs.c \ 
    45              storage_oracle.c 
     39             storage.c  
    4640 
     41sm_CPPFLAGS = -DCONFIG_DIR=\"$(sysconfdir)\" -DLIBRARY_DIR=\"$(pkglibdir)\" 
    4742sm_LDFLAGS = -Wl,-export-dynamic 
    4843sm_LDADD = $(top_builddir)/sx/libsx.la \ 
    4944           $(top_builddir)/mio/libmio.la \ 
    5045           $(top_builddir)/util/libutil.la \ 
    51            $(top_builddir)/subst/libsubst.la \ 
    52            $(MYSQL_LIBS)    \ 
    53            $(PGSQL_LIBS)    \ 
    54            $(SQLITE_LIBS) 
    55  
    56 if STORAGE_MYSQL 
    57 sm_SOURCES += storage_mysql.c 
    58 endif 
    59  
    60 if STORAGE_PGSQL 
    61 sm_SOURCES += storage_pgsql.c 
    62 endif 
    63  
    64 if STORAGE_SQLITE 
    65 sm_SOURCES += storage_sqlite.c 
    66 endif 
     46           $(top_builddir)/subst/libsubst.la  
    6747 
    6848mod_active_la_SOURCES = mod_active.c 
  • trunk/sm/mm.c

    r161 r180  
    4646    mm_t mm; 
    4747    int celem, melem, attr, *nlist = NULL; 
    48     char id[13], name[32], mod_fullpath[512], arg[1024], *modules_path; 
     48    char id[13], name[32], mod_fullpath[PATH_MAX], arg[1024], *modules_path; 
    4949    mod_chain_t chain = (mod_chain_t) NULL; 
    5050    mod_instance_t **list = NULL, mi; 
     
    6464        log_write(sm->log, LOG_NOTICE, "modules search path: %s", modules_path); 
    6565    else 
    66         log_write(sm->log, LOG_WARNING, "modules search path undefined !"); 
     66        log_write(sm->log, LOG_NOTICE, "modules search path undefined, using deafult: "LIBRARY_DIR); 
    6767 
    6868    celem = nad_find_elem(sm->config->nad, celem, -1, "chain", 1); 
     
    173173                #ifndef WIN32 
    174174                  if (modules_path != NULL) 
    175                       snprintf(mod_fullpath, 512, "%s/mod_%s.so", modules_path, name); 
     175                      snprintf(mod_fullpath, PATH_MAX, "%s/mod_%s.so", modules_path, name); 
    176176                  else 
    177                       snprintf(mod_fullpath, 512, "%s/mod_%s.so", LIBRARY_DIR, name); 
     177                      snprintf(mod_fullpath, PATH_MAX, "%s/mod_%s.so", LIBRARY_DIR, name); 
    178178                  mod->handle = dlopen(mod_fullpath, RTLD_LAZY); 
    179179                  if (mod->handle != NULL) 
     
    181181                #else 
    182182                  if (modules_path != NULL) 
    183                       snprintf(mod_fullpath, 512, "%smod_%s.dll", modules_path, name); 
     183                      snprintf(mod_fullpath, PATH_MAX, "%s\\mod_%s.dll", modules_path, name); 
    184184                  else 
    185                       snprintf(mod_fullpath, 512, "mod_%s.dll", name); 
     185                      snprintf(mod_fullpath, PATH_MAX, "mod_%s.dll", name); 
    186186                  mod->handle = (void*) LoadLibrary(mod_fullpath); 
    187187                  if (mod->handle != NULL) 
  • trunk/sm/storage.c

    r156 r180  
    2626  */ 
    2727 
    28 /* these functions implement a multiplexor to get calls to the correct driver 
    29  * for the given type */ 
    30  
    3128#include "sm.h" 
    32  
    3329#include <ctype.h> 
    34  
    35 /* if you add a driver, you'll need to update these arrays */ 
    36 #ifdef STORAGE_DB 
    37 extern st_ret_t st_db_init(st_driver_t); 
    38 #endif 
    39 #ifdef STORAGE_FS 
    40 extern st_ret_t st_fs_init(st_driver_t); 
    41 #endif 
    42 #ifdef STORAGE_MYSQL 
    43 extern st_ret_t st_mysql_init(st_driver_t); 
    44 #endif 
    45 #ifdef STORAGE_PGSQL 
    46 extern st_ret_t st_pgsql_init(st_driver_t); 
    47 #endif 
    48 #ifdef STORAGE_ORACLE 
    49 extern st_ret_t st_oracle_init(st_driver_t); 
    50 #endif 
    51 #ifdef STORAGE_SQLITE 
    52 extern st_ret_t st_sqlite_init(st_driver_t); 
    53 #endif 
    54  
    55 static const char *st_driver_names[] = { 
    56 #ifdef STORAGE_DB 
    57     "db", 
    58 #endif 
    59 #ifdef STORAGE_FS 
    60     "fs", 
    61 #endif 
    62 #ifdef STORAGE_MYSQL 
    63     "mysql", 
    64 #endif 
    65 #ifdef STORAGE_PGSQL 
    66     "pgsql", 
    67 #endif 
    68 #ifdef STORAGE_ORACLE 
    69     "oracle", 
    70 #endif 
    71 #ifdef STORAGE_SQLITE 
    72     "sqlite", 
    73 #endif 
    74     NULL 
    75 }; 
    76  
    77 static st_driver_init_fn st_driver_inits[] = { 
    78 #ifdef STORAGE_DB 
    79     st_db_init, 
    80 #endif 
    81 #ifdef STORAGE_FS 
    82     st_fs_init, 
    83 #endif 
    84 #ifdef STORAGE_MYSQL 
    85     st_mysql_init, 
    86 #endif 
    87 #ifdef STORAGE_PGSQL 
    88     st_pgsql_init, 
    89 #endif 
    90 #ifdef STORAGE_ORACLE 
    91     st_oracle_init, 
    92 #endif 
    93 #ifdef STORAGE_SQLITE 
    94     st_sqlite_init, 
    95 #endif 
    96     NULL 
    97 }; 
     30#include <dlfcn.h> 
    9831 
    9932 
    10033storage_t storage_new(sm_t sm) { 
    10134    storage_t st; 
    102     int i, j; 
     35    int i; 
    10336    config_elem_t elem; 
    10437    char *type; 
     
    11750        for(i = 0; i < elem->nvalues; i++) { 
    11851            type = j_attr((const char **) elem->attrs[i], "type");  
    119             for(j = 0; st_driver_names[j] != NULL; j++) { 
    120                 if(strcmp(elem->values[i], st_driver_names[j]) == 0) { 
    121                     if(type == NULL) 
    122                         ret = storage_add_type(st, st_driver_names[j], NULL); 
    123                     else 
    124                         ret = storage_add_type(st, st_driver_names[j], type); 
    125                     /* Initialisation of storage type failed */ 
    126                     if (ret != st_SUCCESS) { 
    127                       free(st); 
    128                       return NULL; 
    129                     } 
    130                 } 
     52            ret = storage_add_type(st, elem->values[i], type); 
     53            /* Initialisation of storage type failed */ 
     54            if (ret != st_SUCCESS) { 
     55              free(st); 
     56              return NULL; 
    13157            } 
    13258        } 
     
    15581st_ret_t storage_add_type(storage_t st, const char *driver, const char *type) { 
    15682    st_driver_t drv; 
    157     st_driver_init_fn init = NULL; 
     83    st_driver_init_fn init_fn = NULL; 
     84    char mod_fullpath[PATH_MAX], *modules_path; 
    15885    int i; 
    15986    st_ret_t ret; 
     87    void *handle; 
    16088 
    16189    /* startup, see if we've already registered this type */ 
     
    178106    } 
    179107 
     108    /* set modules path */ 
     109    modules_path = config_get_one(st->sm->config, "storage.path", 0); 
     110 
    180111    /* get the driver */ 
    181112    drv = xhash_get(st->drivers, driver); 
     
    183114        log_debug(ZONE, "driver not loaded, trying to init"); 
    184115 
    185         /* find the init function */ 
    186         for(i = 0; st_driver_names[i] != NULL; i++) { 
    187             if(strcmp(driver, st_driver_names[i]) == 0) { 
    188                 init = st_driver_inits[i]; 
    189                 break; 
    190             } 
    191         } 
    192  
    193         /* d'oh */ 
    194         if(init == NULL) { 
    195             log_debug(ZONE, "no init function for driver '%s'", driver); 
    196  
     116        log_write(st->sm->log, LOG_INFO, "loading '%s' storage module", driver); 
     117#ifndef WIN32