00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00024
00025
00026
00027 #include "lcmaps_config.h"
00028 #include <stdio.h>
00029 #include <stdlib.h>
00030 #include <string.h>
00031
00032 #if HAVE_MALLOC_H
00033 # include <malloc.h>
00034 #endif
00035
00036
00037 #if HAVE_DLFCN_H
00038 # include <dlfcn.h>
00039 #endif
00040
00041 #include <gssapi.h>
00042
00043
00044 #include "lcmaps_types.h"
00045 #include "lcmaps_log.h"
00046 #include "lcmaps_arguments.h"
00047 #include "lcmaps_defines.h"
00048 #include "_lcmaps_utils.h"
00049 #include "_lcmaps_db_read.h"
00050 #include "_lcmaps_runvars.h"
00051 #include "_lcmaps_cred_data.h"
00052
00053 #include "../evaluationmanager/evaluationmanager.h"
00054
00055
00056
00057
00058
00059 #ifndef NUL
00060 #define NUL '\0'
00061 #endif
00062
00063
00064 #define MAXPROCS 4
00065 #define USE_EVALUATIONMANAGER 1
00066
00067
00068
00069
00070
00076 enum lcmaps_proctype_e
00077 {
00078 INITPROC,
00079 RUNPROC,
00080 TERMPROC,
00081 INTROPROC,
00082 ENDOFPROCS
00083 };
00084
00090 typedef int (*lcmaps_proc_t)();
00091
00102 typedef struct lcmaps_plugindl_s
00103 {
00104 void * handle;
00105 lcmaps_proc_t procs[MAXPROCS];
00106 char pluginname[LCMAPS_MAXPATHLEN+1];
00107 char pluginargs[LCMAPS_MAXARGSTRING+1];
00108 int init_argc;
00109 char * init_argv[LCMAPS_MAXARGS];
00110 int run_argc;
00111 lcmaps_argument_t * run_argv;
00112 struct lcmaps_plugindl_s * next;
00113 }
00114 lcmaps_plugindl_t;
00115
00116
00117
00118
00119 static lcmaps_plugindl_t * PluginInit(lcmaps_db_entry_t *, lcmaps_plugindl_t **);
00120 static lcmaps_proc_t get_procsymbol(void *, char *);
00121 static int print_lcmaps_plugin(int, lcmaps_plugindl_t *);
00122 static int parse_args_plugin(const char *, const char *, char **, int *);
00123 static int clean_plugin_list(lcmaps_plugindl_t **);
00124
00125
00126
00127
00128 static char * lcmaps_db_file_default = NULL;
00129 static char * lcmaps_dir = NULL;
00130 static lcmaps_plugindl_t * plugin_list = NULL;
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00154 int startPluginManager(
00155 )
00156 {
00157 #if USE_EVALUATIONMANAGER
00158 lcmaps_db_entry_t * lcmaps_db_handle=NULL;
00159 #else
00160 lcmaps_db_entry_t ** lcmaps_db_handle=NULL;
00161 #endif
00162 lcmaps_db_entry_t * ihandle=NULL;
00163 lcmaps_plugindl_t * plugin_entry=NULL;
00164 lcmaps_plugindl_t * plugin_entry_cmp=NULL;
00165 char * lcmaps_db_file=NULL;
00166 int ientry;
00167
00168
00169 lcmaps_dir = getenv("LCMAPS_DIR");
00170 lcmaps_dir = (lcmaps_dir ? lcmaps_dir : LCMAPS_ETC_HOME );
00171 lcmaps_db_file_default = getenv("LCMAPS_DB_FILE");
00172 lcmaps_db_file_default = (lcmaps_db_file_default ? lcmaps_db_file_default : "lcmaps.db" );
00173
00174 lcmaps_db_file=lcmaps_genfilename(lcmaps_dir, lcmaps_db_file_default, NULL);
00175
00176 #if USE_EVALUATIONMANAGER
00177
00178
00179
00180 lcmaps_log_debug(2,"lcmaps.mod-startPluginManager(): doing startEvaluationManager(%s)\n",
00181 lcmaps_db_file);
00182 if (startEvaluationManager(lcmaps_db_file) != 0)
00183 {
00184 lcmaps_log(0,"lcmaps.mod-startPluginManager(): startEvaluationManager(%s) failed\n",
00185 lcmaps_db_file);
00186 goto fail_startPluginManager;
00187 }
00188 #endif
00189
00190
00191
00192
00193
00194 lcmaps_log_time(0,"lcmaps.mod-startPluginManager(): Reading LCMAPS database %s\n",
00195 lcmaps_db_file);
00196 #if USE_EVALUATIONMANAGER
00197 if (getPluginNameAndArgs(&lcmaps_db_handle) != 0)
00198 {
00199 lcmaps_log(0,"lcmaps.mod-startPluginManager(): Error fetching list of plugins from evaluation manager\n");
00200 goto fail_startPluginManager;
00201 }
00202 #else
00203 lcmaps_db_handle=lcmaps_db_read(lcmaps_db_file);
00204 #endif
00205
00206 if (lcmaps_db_handle == NULL)
00207 {
00208 #if USE_EVALUATIONMANAGER
00209 lcmaps_log_debug(1,"lcmaps.mod-startPluginManager(): Evaluation manager found no plugins\n");
00210 #else
00211 lcmaps_log_debug(1,"lcmaps.mod-startPluginManager(): no plugins found by lcmaps_db_read()\n");
00212 #endif
00213 goto fail_startPluginManager;
00214 }
00215
00216
00217
00218
00219
00220
00221 ientry=0;
00222 #if USE_EVALUATIONMANAGER
00223 ihandle=lcmaps_db_handle;
00224 #else
00225 ihandle=*lcmaps_db_handle;
00226 #endif
00227 while (ihandle)
00228 {
00229 if (strlen(ihandle->pluginname) > 0)
00230 {
00231 int plugin_count=0;
00232
00233 lcmaps_log_debug(1,"\n");
00234 lcmaps_log_debug(1,"lcmaps.mod-startPluginManager(): initializing plugin %s (db entry %d)\n",
00235 ihandle->pluginname, ientry);
00236 if ((plugin_entry=PluginInit(ihandle,&plugin_list)) == NULL)
00237 {
00238 lcmaps_log(0,"lcmaps.mod-startPluginManager(): error initializing plugin: %s\n",ihandle->pluginname);
00239 goto fail_startPluginManager;
00240 }
00241
00242
00243
00244
00245 plugin_entry_cmp=plugin_list;
00246 while (plugin_entry_cmp)
00247 {
00248 if ( (strncmp(plugin_entry_cmp->pluginname,
00249 plugin_entry->pluginname,
00250 LCMAPS_MAXPATHLEN) == 0)
00251 )
00252 plugin_count++;
00253 if (plugin_count > 1)
00254 {
00255 lcmaps_log(0,"lcmaps.mod-startPluginManager() error: plugin %s already registered as\n",
00256 plugin_entry->pluginname);
00257 goto fail_startPluginManager;
00258 }
00259 plugin_entry_cmp=plugin_entry_cmp->next;
00260 }
00261 }
00262 ientry++;
00263 ihandle=ihandle->next;
00264 }
00265
00266 plugin_entry=plugin_list;
00267 while (plugin_entry)
00268 {
00269 print_lcmaps_plugin(2,plugin_entry);
00270 lcmaps_log_debug(2,"\n");
00271 plugin_entry=plugin_entry->next;
00272 }
00273
00274
00275 #if USE_EVALUATIONMANAGER
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286 #else
00287 if (lcmaps_db_clean())
00288 {
00289 lcmaps_log(0,"lcmaps.mod-startPluginManager() error: could not clean up plugin db structure\n");
00290 goto fail_startPluginManager;
00291 }
00292 lcmaps_log_debug(5,"lcmaps.mod-startPluginManager(): cleaned lcmaps_db list: %p\n",lcmaps_db_handle);
00293 #endif
00294
00295
00296 if (lcmaps_db_file) free(lcmaps_db_file);
00297 return 0;
00298
00299 fail_startPluginManager:
00300
00301 #if USE_EVALUATIONMANAGER
00302
00303
00304
00305
00306
00307 #else
00308 lcmaps_db_clean();
00309 #endif
00310 if (clean_plugin_list(&plugin_list)!=0)
00311 {
00312 lcmaps_log(0,"lcmaps.mod-startPluginManager() error: could not clean up plugin list\n");
00313 }
00314 if (lcmaps_db_file) free(lcmaps_db_file);
00315
00316 return 1;
00317 }
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00353 static lcmaps_plugindl_t * PluginInit(
00354 lcmaps_db_entry_t * db_handle,
00355 lcmaps_plugindl_t ** list
00356 )
00357 {
00358 char * name;
00359 char * pname=NULL;
00360 char * args=NULL;
00361 void * plugin_handle;
00362 lcmaps_proc_t plugin_procs[MAXPROCS];
00363 lcmaps_plugindl_t * pplugin=NULL;
00364 int i;
00365 int retval;
00366
00367 name = db_handle->pluginname;
00368 args = db_handle->pluginargs;
00369
00370
00371 pname = lcmaps_findfile(name);
00372 if (pname == NULL)
00373 {
00374 lcmaps_log(0,
00375 "lcmaps.mod-PluginInit(): plugin %s not found (arguments: %s)\n",
00376 name, args
00377 );
00378 goto fail_PluginInit;
00379 }
00380
00381
00382
00383 plugin_handle=dlopen(pname,RTLD_NOW);
00384 if (!plugin_handle)
00385 {
00386 lcmaps_log(0,"lcmaps.mod-PluginInit(): dlopen error for %s:\n %s\n",
00387 pname,dlerror()
00388 );
00389 goto fail_PluginInit;
00390 }
00391
00392
00393 for (i=0; i < MAXPROCS; ++i)
00394 {
00395 switch (i)
00396 {
00397 case INITPROC:
00398 plugin_procs[i]=get_procsymbol(plugin_handle,"plugin_initialize");
00399 if (plugin_procs[i] == NULL)
00400 {
00401 lcmaps_log(0,"lcmaps.mod-PluginInit(): plugin %s not compliant\n",
00402 name);
00403 lcmaps_log(0,"lcmaps.mod-PluginInit(): missing function \"plugin_initialize()\"\n");
00404 goto fail_PluginInit;
00405 }
00406 else
00407 {
00408 lcmaps_log_debug(2,"lcmaps.mod-PluginInit(): found \"plugin_initialize()\"\n");
00409 }
00410 break;
00411 case RUNPROC:
00412 plugin_procs[i]=get_procsymbol(plugin_handle,"plugin_run");
00413 if (plugin_procs[i] == NULL)
00414 {
00415 lcmaps_log(0,"lcmaps.mod-PluginInit(): plugin %s not compliant\n",
00416 name);
00417 lcmaps_log(0,"lcmaps.mod-PluginInit(): missing function \"plugin_run()\"\n");
00418 goto fail_PluginInit;
00419 }
00420 else
00421 {
00422 lcmaps_log_debug(2,"lcmaps.mod-PluginInit(): found \"plugin_run()\"\n");
00423 }
00424 break;
00425 case TERMPROC:
00426 plugin_procs[i]=get_procsymbol(plugin_handle,"plugin_terminate");
00427 if (plugin_procs[i] == NULL)
00428 {
00429 lcmaps_log(0,"lcmaps.mod-PluginInit(): plugin %s not compliant\n",
00430 name);
00431 lcmaps_log(0,"lcmaps.mod-PluginInit(): missing function \"plugin_terminate()\"\n");
00432 goto fail_PluginInit;
00433 }
00434 else
00435 {
00436 lcmaps_log_debug(2,"lcmaps.mod-PluginInit(): found \"plugin_terminate()\"\n");
00437 }
00438 break;
00439 case INTROPROC:
00440 plugin_procs[i]=get_procsymbol(plugin_handle,"plugin_introspect");
00441 if (plugin_procs[i] == NULL)
00442 {
00443 lcmaps_log(0,"lcmaps.mod-PluginInit(): plugin %s not compliant\n",
00444 name);
00445 lcmaps_log(0,"lcmaps.mod-PluginInit(): missing function \"plugin_introspect()\"\n");
00446 goto fail_PluginInit;
00447 }
00448 else
00449 {
00450 lcmaps_log_debug(2,"lcmaps.mod-PluginInit(): found \"plugin_introspect()\"\n");
00451 }
00452 break;
00453 default:
00454
00455 plugin_procs[i]=NULL;
00456 break;
00457 }
00458 }
00459
00460 if (!*list)
00461 {
00462 lcmaps_log_debug(2,"lcmaps.mod-PluginInit(): creating first pluginlist entry\n");
00463 *list=pplugin=(lcmaps_plugindl_t *)malloc(sizeof(lcmaps_plugindl_t));
00464 }
00465 else
00466 {
00467 lcmaps_log_debug(2,"lcmaps.mod-PluginInit(): creating new pluginlist entry\n");
00468 pplugin=*list;
00469 while (pplugin->next) pplugin=pplugin->next;
00470 pplugin=pplugin->next=(lcmaps_plugindl_t *)malloc(sizeof(lcmaps_plugindl_t));
00471 }
00472 if (!pplugin)
00473 {
00474 lcmaps_log(0,"lcmaps.mod-PluginInit(): error creating new pluginlist entry\n");
00475 goto fail_PluginInit;
00476 }
00477
00478 pplugin->next=NULL;
00479 pplugin->handle=plugin_handle;
00480 pplugin->run_argc=0;
00481 pplugin->run_argv=NULL;
00482 for (i=0; i < MAXPROCS; ++i)
00483 pplugin->procs[i]=plugin_procs[i];
00484 if (pname != NULL)
00485 {
00486 strncpy(pplugin->pluginname,pname,LCMAPS_MAXPATHLEN);
00487 (pplugin->pluginname)[LCMAPS_MAXPATHLEN]=NUL;
00488 }
00489 else
00490 strncpy(pplugin->pluginname,"",LCMAPS_MAXPATHLEN);
00491
00492 if (args != NULL)
00493 {
00494 strncpy(pplugin->pluginargs,args,LCMAPS_MAXARGSTRING);
00495 (pplugin->pluginargs)[LCMAPS_MAXARGSTRING]=NUL;
00496 }
00497 else
00498 strncpy(pplugin->pluginargs,"",LCMAPS_MAXARGSTRING);
00499
00500
00501 if (parse_args_plugin(pname,args,pplugin->init_argv,&(pplugin->init_argc)) )
00502 {
00503 lcmaps_log(0,"lcmaps.mod-PluginInit(): Could not parse arguments for plugin module %s\n",
00504 pname);
00505 goto fail_PluginInit;
00506 }
00507 for (i=0; i < pplugin->init_argc; ++i)
00508 lcmaps_log_debug(4,"%s arg %d = %s\n",pname,i,(pplugin->init_argv)[i]);
00509
00510
00511
00512 retval=(*(pplugin->procs[INITPROC]))(pplugin->init_argc,pplugin->init_argv);
00513 if (retval != LCMAPS_MOD_SUCCESS )
00514 {
00515 lcmaps_log(0,"lcmaps.mod-PluginInit(): \"plugin_initialize()\" failed\n");
00516 goto fail_PluginInit;
00517 }
00518 else
00519 {
00520 lcmaps_log_debug(2,"lcmaps.mod-PluginInit(): \"plugin_initialize()\" succeeded\n");
00521 }
00522
00523
00524 retval=(*(pplugin->procs[INTROPROC]))(&(pplugin->run_argc),&(pplugin->run_argv));
00525 if (retval != LCMAPS_MOD_SUCCESS )
00526 {
00527 lcmaps_log(0,"lcmaps.mod-PluginInit(): \"plugin_introspect()\" failed\n");
00528 goto fail_PluginInit;
00529 }
00530 else
00531 {
00532 lcmaps_log_debug(2,"lcmaps.mod-PluginInit(): \"plugin_introspect()\" succeeded\n");
00533 }
00534
00535
00536 if (pname) { free(pname); pname=NULL; }
00537
00538 return pplugin;
00539
00540 fail_PluginInit:
00541 if (pname) { free(pname); pname=NULL; }
00542 return NULL;
00543 }
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00577 static int parse_args_plugin(
00578 const char * name,
00579 const char * argstring,
00580 char ** xargv,
00581 int * xargc
00582 )
00583 {
00584 int len=0;
00585 int i;
00586 int rc;
00587
00588
00589 len=strlen(name);
00590 if ( (len > 0) && (len < LCMAPS_MAXPATHLEN) )
00591 {
00592 xargv[0]=(char *)malloc(len+1);
00593 if (xargv[0] != NULL)
00594 strncpy(xargv[0],name,len+1);
00595 else
00596 return 1;
00597 }
00598
00599 *xargc=LCMAPS_MAXARGS-1;
00600 if ( ( rc = lcmaps_tokenize(argstring, &xargv[1], xargc, " \t\n") ) )
00601 {
00602 lcmaps_log(0,"lcmaps.mod-parse_args_plugin(): something wrong parsing arguments of %s, rc=%d\n",
00603 name, rc);
00604 (*xargc)++;
00605 return 1;
00606 }
00607 (*xargc)++;
00608 lcmaps_log_debug(3,"lcmaps.mod-parse_args_plugin(): Found %d arguments:\n", *xargc);
00609 for (i=0; i < *xargc; i++)
00610 lcmaps_log_debug(3,"lcmaps.mod-parse_args_plugin(): %d --> %s\n", i, xargv[i]);
00611
00612 return 0;
00613 }
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00638 static lcmaps_proc_t get_procsymbol(
00639 void * handle,
00640 char * symname
00641 )
00642 {
00643 lcmaps_proc_t symhandle;
00644 char *error;
00645
00646 symhandle=dlsym(handle,symname);
00647 if ((error = dlerror()) != NULL)
00648 {
00649 lcmaps_log(0,"lcmaps.mod-get_procsymbol(): dlsym error: %s",error);
00650 return NULL;
00651 }
00652 return symhandle;
00653 }
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00679 static int print_lcmaps_plugin(
00680 int debug_lvl,
00681 lcmaps_plugindl_t * plugin
00682 )
00683 {
00684 int i=0;
00685
00686 lcmaps_log_debug(debug_lvl,"\tplugin name : %s\n",plugin->pluginname);
00687 lcmaps_log_debug(debug_lvl,"\tplugin arguments : %s\n",plugin->pluginargs);
00688 lcmaps_log_debug(debug_lvl,"\tplugin address : x%x\n",plugin);
00689 lcmaps_log_debug(debug_lvl,"\tplugin size : %d\n",sizeof(lcmaps_plugindl_t));
00690 lcmaps_log_debug(debug_lvl,"\tplugin handle : x%x\n",plugin->handle);
00691 lcmaps_log_debug(debug_lvl,"\tplugin_initialize() : x%x\n",plugin->procs[INITPROC]);
00692 lcmaps_log_debug(debug_lvl,"\tplugin_run() : x%x\n",plugin->procs[RUNPROC]);
00693 lcmaps_log_debug(debug_lvl,"\tplugin_terminate() : x%x\n",plugin->procs[TERMPROC]);
00694 lcmaps_log_debug(debug_lvl,"\tplugin_introspect() : x%x\n",plugin->procs[INTROPROC]);
00695 lcmaps_log_debug(debug_lvl,"\tplugin init_argc : %d\n",plugin->init_argc);
00696 for (i=0; i < plugin->init_argc; i++)
00697 lcmaps_log_debug(debug_lvl,"\tplugin init_argv[%2d] : %s\n",i,(plugin->init_argv)[i]);
00698 lcmaps_log_debug(debug_lvl,"\tplugin run_argc : %d\n",plugin->run_argc);
00699 for (i=0; i < plugin->run_argc; i++)
00700 {
00701 char * argType=NULL;
00702
00703 argType=((plugin->run_argv)[i]).argType;
00704 lcmaps_log_debug(debug_lvl,"\tplugin run_argv[%2d] : x%x\n",i,(plugin->run_argv)+i);
00705 lcmaps_log_debug(debug_lvl,"\tplugin run_argv[%2d], argName : %s\n",i,((plugin->run_argv)[i]).argName);
00706 lcmaps_log_debug(debug_lvl,"\tplugin run_argv[%2d], argType : %s\n",i,((plugin->run_argv)[i]).argType);
00707 lcmaps_log_debug(debug_lvl,"\tplugin run_argv[%2d], argInOut : %d\n",i,((plugin->run_argv)[i]).argInOut);
00708 lcmaps_log_debug(debug_lvl,"\tplugin run_argv[%2d], value address : x%x\n",i,((plugin->run_argv)[i]).value);
00709 if (strcmp("char *",argType) == 0)
00710 {
00711 char ** pstring;
00712 if ( ((plugin->run_argv)[i]).value != NULL)
00713 {
00714 pstring = (char **) (((plugin->run_argv)[i]).value);
00715 pstring = (char **) lcmaps_getArgValue(
00716 ((plugin->run_argv)[i]).argName,
00717 ((plugin->run_argv)[i]).argType,
00718 plugin->run_argc,
00719 plugin->run_argv
00720 );
00721 lcmaps_log_debug(debug_lvl,"\tplugin run_argv[%2d], char * value : %s\n",i,*pstring);
00722 }
00723 else
00724 {
00725 lcmaps_log_debug(debug_lvl,"\tplugin run_argv[%2d], char * value : none yet\n",i);
00726 }
00727 }
00728 if (strcmp("int",argType) == 0)
00729 {
00730 int * pint;
00731 if ( ((plugin->run_argv)[i]).value != NULL)
00732 {
00733 pint = (int *) (((plugin->run_argv)[i]).value);
00734 pint = (int *) lcmaps_getArgValue(
00735 ((plugin->run_argv)[i]).argName,
00736 ((plugin->run_argv)[i]).argType,
00737 plugin->run_argc,
00738 plugin->run_argv
00739 );
00740 lcmaps_log_debug(debug_lvl,"\tplugin run_argv[%2d], int value : %d\n",i,*pint);
00741 }
00742 else
00743 {
00744 lcmaps_log_debug(debug_lvl,"\tplugin run_argv[%2d], int value : none yet\n",i);
00745 }
00746 }
00747 }
00748 lcmaps_log_debug(debug_lvl,"\tplugin next : x%x\n",plugin->next);
00749 if (plugin->next != NULL)
00750 lcmaps_log_debug(debug_lvl,"\tplugin_next : %s\n",(plugin->next)->pluginname);
00751 else
00752 lcmaps_log_debug(debug_lvl,"\tplugin_next : last plugin in list\n");
00753
00754 return 1;
00755 }
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768
00780 static int clean_plugin_list(
00781 lcmaps_plugindl_t ** list
00782 )
00783 {
00784 int rc;
00785 lcmaps_plugindl_t * plugin_entry=NULL;
00786
00787 plugin_entry=*list;
00788 while (plugin_entry)
00789 {
00790 lcmaps_plugindl_t * plugin_next;
00791 int i;
00792
00793 rc = plugin_entry->procs[TERMPROC]();
00794 if (rc != LCMAPS_MOD_SUCCESS)
00795 {
00796 lcmaps_log(0,"lcmaps.mod-clean_plugin_list(): failed to terminate plugin module %s\n",
00797 plugin_entry->pluginname);
00798 }
00799 lcmaps_log_debug(1, "lcmaps.mod-clean_plugin_list(): plugin module %s terminated\n",
00800 plugin_entry->pluginname);
00801 dlclose(plugin_entry->handle);
00802
00803 plugin_next=plugin_entry->next;
00804 for (i=0; i < plugin_entry->init_argc; i++)
00805 {
00806 if ((plugin_entry->init_argv)[i] != NULL)
00807 {
00808 lcmaps_log_debug(3,"Freeing %d - %s\n",i,(plugin_entry->init_argv)[i]);
00809 free((plugin_entry->init_argv)[i]);
00810 }
00811 }
00812 free(plugin_entry);
00813 plugin_entry=plugin_next;
00814 }
00815 *list=plugin_entry=NULL;
00816 return 0;
00817 }
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831
00848 int runPluginManager(
00849 lcmaps_request_t request,
00850 lcmaps_cred_id_t lcmaps_cred
00851 )
00852 {
00853 lcmaps_plugindl_t * plugin_entry=NULL;
00854
00855
00856
00857
00858
00859
00860 lcmaps_log_debug(2,"lcmaps.mod-runPluginManager(): extract RunVars\n");
00861 if (lcmaps_extractRunVars(request, lcmaps_cred) != 0)
00862 {
00863 lcmaps_log(0,"lcmaps.mod-runPluginManager(): error in creating list of run variables\n");
00864 return 1;
00865 }
00866
00867 plugin_entry=plugin_list;
00868 while (plugin_entry)
00869 {
00870 void * pvalue=NULL;
00871 char * argName=NULL;
00872 char * argType=NULL;
00873 int iarg=0;
00874
00875 for (iarg=0; iarg < plugin_entry->run_argc; iarg++)
00876 {
00877 argName=(plugin_entry->run_argv+iarg)->argName;
00878 argType=(plugin_entry->run_argv+iarg)->argType;
00879 lcmaps_log_debug(2,
00880 "lcmaps.mod-runPluginManager(): Getting value of \"%s\" of type \"%s\" for plugin \"%s\"\n",
00881 argName, argType, plugin_entry->pluginname);
00882 if ((pvalue=lcmaps_getRunVars(argName, argType)) == NULL)
00883 {
00884 lcmaps_log(0,
00885 "lcmaps.mod-runPluginManager(): could not GET requested variable \"%s\" of type \"%s\" for plugin \"%s\"\n",
00886 argName, argType, plugin_entry->pluginname);
00887 return 1;
00888 }
00889 lcmaps_log_debug(2,
00890 "lcmaps.mod-runPluginManager(): Setting value of \"%s\" of type \"%s\" for plugin \"%s\", address: 0x%x\n",
00891 argName, argType, plugin_entry->pluginname, pvalue);
00892 if (lcmaps_setArgValue(argName, argType, pvalue, plugin_entry->run_argc, &(plugin_entry->run_argv)) != 0)
00893 {
00894 lcmaps_log(0,
00895 "lcmaps.mod-runPluginManager(): could not SET requested variable \"%s\" of type \"%s\" for plugin \"%s\"\n",
00896 argName, argType, plugin_entry->pluginname);
00897 return 1;
00898 }
00899 }
00900 plugin_entry=plugin_entry->next;
00901 }
00902
00903 #if USE_EVALUATIONMANAGER
00904
00905
00906
00907 lcmaps_log_debug(1,"lcmaps.mod-runPluginManager(): Do runEvaluationManager()\n");
00908 if (runEvaluationManager() != 0)
00909 {
00910 lcmaps_log(0,"lcmaps.mod-runPluginManager(): Error running evaluation manager\n");
00911 return 1;
00912 }
00913 lcmaps_log_debug(1,"lcmaps.mod-runPluginManager(): runEvaluationManager() succeeded.\n");
00914 #else
00915
00916
00917
00918 plugin_entry=plugin_list;
00919 while (plugin_entry)
00920 {
00921 print_lcmaps_plugin(2,plugin_entry);
00922 lcmaps_log_debug(2,"\n");
00923 lcmaps_log(0,"lcmaps.mod-runPluginManager(): running %s\n",plugin_entry->pluginname);
00924 if (runPlugin(plugin_entry->pluginname)) {
00925 lcmaps_log(0,"lcmaps.mod-runPluginManager(): plugin %s failed\n",plugin_entry->pluginname);
00926 }
00927 plugin_entry=plugin_entry->next;
00928 }
00929 #endif
00930 return 0;
00931 }
00932
00933
00934
00935
00936
00937
00938
00939
00940
00941
00942
00943
00944
00959 int runPlugin(
00960 const char * pluginname
00961 )
00962 {
00963 lcmaps_plugindl_t * plugin_entry=NULL;
00964 int rc=1;
00965 int foundplugin=0;
00966
00967
00968
00969
00970
00971
00972 plugin_entry=plugin_list;
00973 while (plugin_entry)
00974 {
00975 lcmaps_log_debug(3,"lcmaps.mod-runPlugin(): looking for plugin %s\n",pluginname);
00976 if (strcmp(plugin_entry->pluginname,pluginname) == 0) {
00977 lcmaps_log_time(0,"lcmaps.mod-runPlugin(): found plugin %s\n",plugin_entry->pluginname);
00978 foundplugin++;
00979 break;
00980 }
00981 plugin_entry=plugin_entry->next;
00982 }
00983 if (!foundplugin) {
00984 lcmaps_log(0,"lcmaps.mod-runPlugin(): could not find plugin %s\n",pluginname);
00985 return 1;
00986 }
00987
00988
00989 lcmaps_log_time(0,"lcmaps.mod-runPlugin(): running plugin %s\n",plugin_entry->pluginname);
00990 rc = plugin_entry->procs[RUNPROC](plugin_entry->run_argc, plugin_entry->run_argv);
00991
00992 return rc;
00993 }
00994
00995
00996
00997
00998
00999
01000
01001
01002
01003
01004
01015 int stopPluginManager(
01016 )
01017 {
01018 lcmaps_log_debug(1,"lcmaps.mod-stopPluginManager(): cleaning credential data\n");
01019 printCredData();
01020 if (cleanCredentialData()!=0)
01021 {
01022 lcmaps_log(0,"lcmaps.mod-stopPluginManager() error: could not clean credential data list\n");
01023 return 1;
01024 }
01025 if (clean_plugin_list(&plugin_list)!=0)
01026 {
01027 lcmaps_log(0,"lcmaps.mod-stopPluginManager() error: could not clean up plugin list\n");
01028 return 1;
01029 }
01030 #if USE_EVALUATIONMANAGER
01031 if (stopEvaluationManager() != 0)
01032 {
01033 lcmaps_log(0,"lcmaps.mod-stopPluginManager(): error in stopEvaluationManager()\n");
01034 return 1;
01035 }
01036 #endif
01037 return 0;
01038 }