Update of /cvsroot/sblim/sfcb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30425 Modified Files: Makefile.am cmpios.h control.c httpAdapter.c providerDrv.c sfcb.cfg.pre.in sfcb.init-none.in sfcb.init-redhat.in sfcb.init-suse.in Log Message: Bug fixed: 1218183. Adds support for the providerDirs variable in sfcb.cfg. This basically removes the need to have the providers in the libary path. On the other hand, providers in the library path will not be loaded automatically any more if not in providerDirs! Index: sfcb.init-suse.in =================================================================== RCS file: /cvsroot/sblim/sfcb/sfcb.init-suse.in,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- sfcb.init-suse.in 27 Apr 2005 11:53:13 -0000 1.1 +++ sfcb.init-suse.in 13 Jun 2005 12:50:33 -0000 1.2 @@ -21,13 +21,6 @@ export LD_LIBRARY_PATH fi -# Add CMPI directory -if [ -z "$LD_LIBRARY_PATH" ] || echo $LD_LIBRARY_PATH | grep -qv @libdir@/cmpi -then - LD_LIBRARY_PATH=@libdir@/cmpi:$LD_LIBRARY_PATH - export LD_LIBRARY_PATH -fi - start() { echo -n "Starting sfcb: " startproc @sbindir@/sfcbd -d Index: Makefile.am =================================================================== RCS file: /cvsroot/sblim/sfcb/Makefile.am,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- Makefile.am 6 Jun 2005 16:05:23 -0000 1.25 +++ Makefile.am 13 Jun 2005 12:50:33 -0000 1.26 @@ -32,6 +32,7 @@ AM_CPPFLAGS=-DSFCB_CONFDIR=\"$(sfcbconfdir)\" \ -DSFCB_STATEDIR=\"$(sfcbstatedir)\" + -DSFCB_LIBDIR=\"$(libdir)\" SUBDIRS=. $(MOFC_DIR) Index: sfcb.init-none.in =================================================================== RCS file: /cvsroot/sblim/sfcb/sfcb.init-none.in,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- sfcb.init-none.in 27 Apr 2005 11:53:13 -0000 1.1 +++ sfcb.init-none.in 13 Jun 2005 12:50:33 -0000 1.2 @@ -12,13 +12,6 @@ export LD_LIBRARY_PATH fi -# Add CMPI directory -if [ -z "$LD_LIBRARY_PATH" ] || echo $LD_LIBRARY_PATH | grep -qv @libdir@/cmpi -then - LD_LIBRARY_PATH=@libdir@/cmpi:$LD_LIBRARY_PATH - export LD_LIBRARY_PATH -fi - start() { echo -n "Starting sfcb: " @sbindir@/sfcbd -d && echo "done." && return 0 || Index: providerDrv.c =================================================================== RCS file: /cvsroot/sblim/sfcb/providerDrv.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- providerDrv.c 9 Jun 2005 21:10:34 -0000 1.15 +++ providerDrv.c 13 Jun 2005 12:50:33 -0000 1.16 @@ -25,6 +25,8 @@ #include <signal.h> #include <pthread.h> #include <time.h> +#include <sys/stat.h> +#include <unistd.h> #include "providerMgr.h" #include "utilft.h" @@ -36,7 +38,7 @@ #include "trace.h" #include "queryOperation.h" #include "selectexp.h" - +#include "control.h" #define PROVCHARS(p) (p && *((char*)p)) ? (char*)p : NULL @@ -88,35 +90,41 @@ unsigned long provTimeoutInterval=25; static int stopping=0; -void libraryName(const char *location, char *fullName) +void libraryName(const char *dir, const char *location, char *fullName) { -#if defined(PEGASUS_PLATFORM_WIN32_IX86_MSVC) - strcpy(fullName, location); - strcat(fullName, ".dll"); -#elif defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU) - strcpy(fullName, "lib"); - strcat(fullName, location); - strcat(fullName, ".so"); -#elif defined(PEGASUS_OS_HPUX) -#ifdef PEGASUS_PLATFORM_HPUX_PARISC_ACC - strcpy(fullName, "lib"); - strcat(fullName, location); - strcat(fullName, ".so"); -#else - strcpy(fullName, "lib"); - strcat(fullName, location); - strcat(fullName, ".so"); -#endif -#elif defined(PEGASUS_OS_OS400) +#if defined(CMPI_PLATFORM_WIN32_IX86_MSVC) + if (dir) { + sprintf(fullName,"%s\\%s.dll",dir,location); + } else { + sprintf(fullName,"%s.dll",location); + } +#elif defined(CMPI_PLATFORM_LINUX_GENERIC_GNU) + if (dir) { + sprintf(fullName,"%s/lib%s.so",dir,location); + } else { + sprintf(fullName,"lib%s.so",location); + } +#elif defined(CMPI_OS_HPUX) + if (dir) { + sprintf(fullName,"%s/lib%s.so",dir,location); + } else { + sprintf(fullName,"lib%s.so",location); + } +#elif defined(CMPI_OS_OS400) + if (dir) { strcpy(fullName, location); -#elif defined(PEGASUS_OS_DARWIN) - strcpy(fullName, "lib"); - strcat(fullName, location); - strcat(fullName, ".dylib"); +#elif defined(CMPI_OS_DARWIN) + if (dir) { + sprintf(fullName,"%s/lib%s.dylib",dir,location); + } else { + sprintf(fullName,"lib%s.dylib",location); + } #else - strcpy(fullName, "lib"); - strcat(fullName, location); - strcat(fullName, ".so"); + if (dir) { + sprintf(fullName,"%s/lib%s.so",dir,location); + } else { + sprintf(fullName,"lib%s.so",location); + } #endif } @@ -1652,13 +1660,44 @@ static int doLoadProvider(ProviderInfo *info, char *dlName) { + char *dirs,*dir,*dirlast, *dircpy; + char *fullname; + struct stat stbuf; + _SFCB_ENTER(TRACE_PROVIDERDRV, "doLoadProvider"); - libraryName((char *) info->location, dlName); - info->library = dlopen(dlName, RTLD_NOW); + if (getControlChars("providerDirs",&dirs) != 0) { + mlogf(M_ERROR,M_SHOW,"*** No provider directories configured.\n"); + abort(); + } + + + libraryName(NULL, (char *) info->location, dlName); + + dircpy = strdup(dirs); + fullname = malloc(strlen(dircpy)+strlen(dlName)+2); /* sufficient */ + dir=strtok_r(dircpy," \t",&dirlast); + info->library = NULL; + while (dir) { + libraryName(dir, (char *) info->location, fullname); + if (stat(fullname,&stbuf) == 0) { + info->library = dlopen(fullname, RTLD_NOW); + if (info->library == NULL) { + mlogf(M_ERROR,M_SHOW,"*** dlopen error: %s\n",dlerror()); + } else { + _SFCB_TRACE(1, ("--- Loaded provider library %s for %s-%d", + fullname, + info->providerName, + currentProc)); + } + break; + } + dir=strtok_r(NULL, " \t", &dirlast); + } + free(dircpy); + free(fullname); if (info->library == NULL) { - mlogf(M_ERROR,M_SHOW,"*** dlopen error: %s\n",dlerror()); _SFCB_RETURN(-1); } Index: sfcb.init-redhat.in =================================================================== RCS file: /cvsroot/sblim/sfcb/sfcb.init-redhat.in,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- sfcb.init-redhat.in 27 Apr 2005 11:53:13 -0000 1.1 +++ sfcb.init-redhat.in 13 Jun 2005 12:50:33 -0000 1.2 @@ -21,13 +21,6 @@ export LD_LIBRARY_PATH fi -# Add CMPI directory -if [ -z "$LD_LIBRARY_PATH" ] || echo $LD_LIBRARY_PATH | grep -qv @libdir@/cmpi -then - LD_LIBRARY_PATH=@libdir@/cmpi:$LD_LIBRARY_PATH - export LD_LIBRARY_PATH -fi - start() { echo -n "Starting sfcb: " daemon @sbindir@/sfcbd -d && Index: sfcb.cfg.pre.in =================================================================== RCS file: /cvsroot/sblim/sfcb/sfcb.cfg.pre.in,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- sfcb.cfg.pre.in 10 Mar 2005 15:40:46 -0000 1.2 +++ sfcb.cfg.pre.in 13 Jun 2005 12:50:33 -0000 1.3 @@ -11,3 +11,4 @@ sslKeyFilePath: @sysconfdir@/sfcb/file.pem sslCertificateFilePath: @sysconfdir@/sfcb/server.pem registrationDir: @localstatedir@/lib/sfcb/registration +providerDirs: @libdir@ @libdir@/cmpi Index: control.c =================================================================== RCS file: /cvsroot/sblim/sfcb/control.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- control.c 6 Jun 2005 16:05:23 -0000 1.8 +++ control.c 13 Jun 2005 12:50:33 -0000 1.9 @@ -40,6 +40,10 @@ #define SFCB_STATEDIR "/var/lib/sfcb" #endif +#ifndef SFCB_LIBDIR +#define SFCB_LIBDIR "/usr/lib" +#endif + typedef struct control { char *id; int type; @@ -79,6 +83,7 @@ {"sslCertificateFilePath", 0, SFCB_CONFDIR "/server.pem"}, {"registrationDir", 0, SFCB_STATEDIR "/registration"}, + {"providerDirs", 3, SFCB_LIBDIR " " SFCB_LIBDIR "/cmpi" }, /* 3: unstripped */ }; int setupControl(char *fn) @@ -127,8 +132,15 @@ case 2: for (i=0; i<sizeof(init)/sizeof(Control); i++) { if (strcmp(rv.id, init[i].id) == 0) { - init[i].strValue=strdup(cntlGetVal(&rv)); - goto ok; + if (init[i].type == 3) { + /* unstripped character string */ + init[i].strValue=strdup(rv.val); + if (strchr(init[i].strValue,'\n')) + *(strchr(init[i].strValue,'\n')) = 0; + } else { + init[i].strValue=strdup(cntlGetVal(&rv)); + } + goto ok; } } mlogf(M_ERROR,M_SHOW,"--- invalid control statement: \n\t%d: %s\n", n, stmt); @@ -160,7 +172,7 @@ Control *ctl; int rc = -1; if ((ctl = ct->ft->get(ct, id))) { - if (ctl->type == 0) { + if (ctl->type == 0 || ctl->type == 3) { *val = ctl->strValue; return 0; } Index: cmpios.h =================================================================== RCS file: /cvsroot/sblim/sfcb/cmpios.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- cmpios.h 9 Mar 2005 12:25:11 -0000 1.1.1.1 +++ cmpios.h 13 Jun 2005 12:50:33 -0000 1.2 @@ -37,7 +37,7 @@ long tv_nsec; }; -#elif defined( PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) +#elif defined( CMPI_PLATFORM_ZOS_ZSERIES_IBM) #define CMPI_THREAD_CDECL __cdecl #define CMPI_THREAD_KEY_TYPE pthread_key_t Index: httpAdapter.c =================================================================== RCS file: /cvsroot/sblim/sfcb/httpAdapter.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- httpAdapter.c 3 Jun 2005 10:31:57 -0000 1.9 +++ httpAdapter.c 13 Jun 2005 12:50:33 -0000 1.10 @@ -75,7 +75,7 @@ static int httpWorkSem; extern char *decode64(char *data); -extern void libraryName(const char *location, char *fullName); +extern void libraryName(const char* dir, const char *location, char *fullName); extern void *loadLibib(const char *libname); extern int getControlChars(char *id, char **val); extern void *loadLibib(const char *libname); @@ -156,7 +156,7 @@ char *ln; int err=1; if (getControlChars("basicAuthlib", &ln)==0) { - libraryName(ln,dlName); + libraryName(NULL,ln,dlName); if ((authLib=dlopen(dlName, RTLD_LAZY))) { authenticate= dlsym(authLib, "_sfcBasicAuthenticate"); if (authenticate) err=0; |