/[pdpsoft]/trunk/grid-mw-security/ees/src/eef/eef_common.c
ViewVC logotype

Contents of /trunk/grid-mw-security/ees/src/eef/eef_common.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1158 - (show annotations) (download) (as text)
Fri Nov 20 14:04:55 2009 UTC (12 years, 2 months ago) by aramv
File MIME type: text/x-chdr
File size: 3304 byte(s)
Added code to specify allowed policies and clean those not allowed
1 #include "eef.h"
2 #include "pdl.h"
3 #include "plugin_manager.h"
4
5 static const char* _modules_path; /*! Holds the global path to plug-in modules */
6
7 /*! Try to initialize the AOS, enable logging, initialize the plug-in manager and try to parse the config file and ascertain the module path
8 */
9 EES_RC EEF_Init(char *config_file, FILE* log_file, int number_of_policies, char* names_of_policies[]){
10 start_log(log_file);
11 eef_log(LOG_NOTICE, "EEF initializing");
12
13 if (AOS_Init() == EES_SUCCESS){
14 if(start_plugin_manager() == EES_SUCCESS){
15 eef_log(LOG_NOTICE, "Loading config file: %s\n", config_file);
16 if(pdl_init(config_file) == EES_SUCCESS){
17 /* after the config file was successfully read, we can try to set the modules path if one was provided */
18 eef_log(LOG_NOTICE, "Loaded config file: %s\n", config_file);
19
20 /* set the EEF modules path to the path found by the evaluation manager */
21 set_modules_path(get_pdl_path());
22
23 /* this is a callout to the plugin manager, which dlopen()'s the plugin, dlsym()'s the plugin's functions and calls the plugin's initialize function */
24 if(initialize_plugins() == EES_SUCCESS){
25 /* these are callouts to the evaluation manager */
26 parsed_policy_tree = get_policies();
27 parsed_policy_tree = reduce_policy_tree(parsed_policy_tree, number_of_policies, names_of_policies);
28 link_rules_to_plugins(parsed_policy_tree);
29 return EES_SUCCESS;
30 } else {
31 eef_log(LOG_ERR, "Failed to initialize plug-ins from policy config file %s\n", config_file);
32 }
33 }
34 }
35 }
36 return EES_FAILURE;
37 }
38
39 /*!
40 * Terminates the parser, stops the plug-in manager, terminates the AOS and closes the log.
41 */
42 EES_RC EEF_Term(){
43 eef_log(LOG_INFO, "Cleaning up...");
44 if((pdl_term() == EES_SUCCESS) &&
45 (stop_plugin_manager() == EES_SUCCESS) &&
46 (AOS_Term() == EES_SUCCESS)){
47 stop_log();
48 return EES_SUCCESS;
49 }
50 eef_log(LOG_ERR, "Errors detected\n");
51 eef_log(LOG_NOTICE, "EEF terminating...");
52 stop_log();
53 return EES_FAILURE;
54 }
55
56 /* Opens the log file or logs to syslog if none was provided.
57 * log mask is set depending on whether ENABLE_DEBUG macro is set to true */
58 EES_RC start_log(FILE* log_file){
59 /* Log file */
60 log_file_fp = log_file;
61
62 if(!log_file_fp){
63 /* logmask for debug */
64 #if ENABLE_DEBUG
65 setlogmask (LOG_UPTO(LOG_DEBUG));
66 eef_log(LOG_DEBUG, "DEBUG MODE ENABLED\n");
67 #else
68 setlogmask (LOG_UPTO(LOG_INFO));
69 #endif
70 } else {
71 /* Open syslog, regardless of use*/
72 openlog ("ees", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_DAEMON);
73 }
74 return EES_SUCCESS;
75
76 }
77
78 /* Closes the log file */
79 EES_RC stop_log(){
80 if(!log_file_fp){
81 closelog();
82 }
83 return EES_SUCCESS;
84 }
85
86 /*!
87 * Sets the global modules path to load plug-ins from
88 */
89 void set_modules_path(const char* path){
90 _modules_path = path;
91 }
92
93 /*!
94 * Returns the global modules path to load plug-ins from
95 * This can be either the _modules_path as set by the set_modules_path() function or the MODULE_DIR path macro generated by the configure script.
96 */
97 const char* get_modules_path(void){
98 if(_modules_path != NULL){
99 if(strlen(_modules_path)!=0){
100 return _modules_path;
101 }
102 }
103 return MODULE_DIR;
104 }

Properties

Name Value
svn:mergeinfo

grid.support@nikhef.nl
ViewVC Help
Powered by ViewVC 1.1.28