/[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 1202 - (show annotations) (download) (as text)
Mon Nov 30 17:14:03 2009 UTC (12 years, 1 month ago) by aramv
File MIME type: text/x-chdr
File size: 3558 byte(s)
Trying to fix open ended rules
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 /* retrieve policy list from the evaluation mananger */
24 parsed_policy_tree = get_policies();
25
26 /* strip policies that are not explicitly passed in the names_of_policies array */
27 parsed_policy_tree = reduce_policy_tree(parsed_policy_tree, number_of_policies, names_of_policies);
28 link_dead_end_rules_in_policy(parsed_policy_tree);
29 link_rules_to_plugins(parsed_policy_tree);
30 print_policies(parsed_policy_tree);
31
32 /* 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 */
33 if(initialize_plugins() == EES_SUCCESS){
34 /* these are callouts to the evaluation manager */
35 return EES_SUCCESS;
36 } else {
37 eef_log(LOG_ERR, "Failed to initialize plug-ins from policy config file %s\n", config_file);
38 }
39 }
40 }
41 }
42 return EES_FAILURE;
43 }
44
45 /*!
46 * Terminates the parser, stops the plug-in manager, terminates the AOS and closes the log.
47 */
48 EES_RC EEF_Term(){
49 eef_log(LOG_INFO, "Cleaning up...");
50 if((pdl_term() == EES_SUCCESS) &&
51 (stop_plugin_manager() == EES_SUCCESS) &&
52 (AOS_Term() == EES_SUCCESS)){
53 stop_log();
54 return EES_SUCCESS;
55 }
56 eef_log(LOG_ERR, "Errors detected\n");
57 eef_log(LOG_NOTICE, "EEF terminating...");
58 stop_log();
59 return EES_FAILURE;
60 }
61
62 /* Opens the log file or logs to syslog if none was provided.
63 * log mask is set depending on whether ENABLE_DEBUG macro is set to true */
64 EES_RC start_log(FILE* log_file){
65 /* Log file */
66 log_file_fp = log_file;
67
68 if(!log_file_fp){
69 /* logmask for debug */
70 #if ENABLE_DEBUG
71 setlogmask (LOG_UPTO(LOG_DEBUG));
72 eef_log(LOG_DEBUG, "DEBUG MODE ENABLED\n");
73 #else
74 setlogmask (LOG_UPTO(LOG_INFO));
75 #endif
76 } else {
77 /* Open syslog, regardless of use*/
78 openlog ("ees", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_DAEMON);
79 }
80 return EES_SUCCESS;
81
82 }
83
84 /* Closes the log file */
85 EES_RC stop_log(){
86 if(!log_file_fp){
87 closelog();
88 }
89 return EES_SUCCESS;
90 }
91
92 /*!
93 * Sets the global modules path to load plug-ins from
94 */
95 void set_modules_path(const char* path){
96 _modules_path = path;
97 }
98
99 /*!
100 * Returns the global modules path to load plug-ins from
101 * 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.
102 */
103 const char* get_modules_path(void){
104 if(_modules_path != NULL){
105 if(strlen(_modules_path)!=0){
106 return _modules_path;
107 }
108 }
109 return MODULE_DIR;
110 }

Properties

Name Value
svn:mergeinfo

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