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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1215 - (hide annotations) (download) (as text)
Wed Dec 2 15:08:10 2009 UTC (12 years, 5 months ago) by aramv
File MIME type: text/x-chdr
File size: 3678 byte(s)
Fixed removing policies from policy list
1 aramv 781 #include "eef.h"
2 aramv 586 #include "pdl.h"
3 aramv 484 #include "plugin_manager.h"
4 aramv 429
5 aramv 890 static const char* _modules_path; /*! Holds the global path to plug-in modules */
6 aramv 844
7 aramv 1154 /*! 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 aramv 890 */
9 aramv 1096 EES_RC EEF_Init(char *config_file, FILE* log_file, int number_of_policies, char* names_of_policies[]){
10 aramv 1087 start_log(log_file);
11 aramv 1075 eef_log(LOG_NOTICE, "EEF initializing");
12 aramv 589
13 aramv 1060 if (AOS_Init() == EES_SUCCESS){
14 aramv 1142 if(start_plugin_manager() == EES_SUCCESS){
15 aramv 1068 eef_log(LOG_NOTICE, "Loading config file: %s\n", config_file);
16 aramv 781 if(pdl_init(config_file) == EES_SUCCESS){
17 aramv 890 /* after the config file was successfully read, we can try to set the modules path if one was provided */
18 aramv 1068 eef_log(LOG_NOTICE, "Loaded config file: %s\n", config_file);
19 aramv 1156
20 aramv 1142 /* set the EEF modules path to the path found by the evaluation manager */
21     set_modules_path(get_pdl_path());
22 aramv 1156
23 aramv 1162 /* 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 aramv 1212 if(number_of_policies){
28 aramv 1215 parsed_policy_tree = reduce_policy_tree(parsed_policy_tree, number_of_policies, names_of_policies);
29 aramv 1212 }
30    
31     if(parsed_policy_tree){
32 aramv 1211 /*link_dead_end_rules_in_policy(parsed_policy_tree);*/
33     /*link_rules_to_plugins(parsed_policy_tree);*/
34     }
35 aramv 1212 print_policies(parsed_policy_tree);
36 aramv 1162
37 aramv 1158 /* 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 */
38 aramv 1156 if(initialize_plugins() == EES_SUCCESS){
39 aramv 1158 /* these are callouts to the evaluation manager */
40 aramv 1156 return EES_SUCCESS;
41     } else {
42     eef_log(LOG_ERR, "Failed to initialize plug-ins from policy config file %s\n", config_file);
43     }
44 aramv 589 }
45     }
46 aramv 429 }
47 aramv 781 return EES_FAILURE;
48 aramv 429 }
49    
50 aramv 890 /*!
51     * Terminates the parser, stops the plug-in manager, terminates the AOS and closes the log.
52     */
53 aramv 810 EES_RC EEF_Term(){
54 aramv 887 eef_log(LOG_INFO, "Cleaning up...");
55 aramv 1212 if((pdl_term(parsed_policy_tree) == EES_SUCCESS) &&
56     (stop_plugin_manager() == EES_SUCCESS) &&
57     (AOS_Term() == EES_SUCCESS)){
58 aramv 1087 stop_log();
59 aramv 867 return EES_SUCCESS;
60 aramv 586 }
61 aramv 892 eef_log(LOG_ERR, "Errors detected\n");
62 aramv 1075 eef_log(LOG_NOTICE, "EEF terminating...");
63 aramv 1087 stop_log();
64 aramv 781 return EES_FAILURE;
65 aramv 429 }
66    
67 aramv 1142 /* Opens the log file or logs to syslog if none was provided.
68     * log mask is set depending on whether ENABLE_DEBUG macro is set to true */
69 aramv 1087 EES_RC start_log(FILE* log_file){
70     /* Log file */
71     log_file_fp = log_file;
72    
73     if(!log_file_fp){
74     /* logmask for debug */
75     #if ENABLE_DEBUG
76     setlogmask (LOG_UPTO(LOG_DEBUG));
77     eef_log(LOG_DEBUG, "DEBUG MODE ENABLED\n");
78     #else
79     setlogmask (LOG_UPTO(LOG_INFO));
80     #endif
81     } else {
82     /* Open syslog, regardless of use*/
83     openlog ("ees", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_DAEMON);
84     }
85     return EES_SUCCESS;
86    
87     }
88    
89 aramv 1142 /* Closes the log file */
90 aramv 1087 EES_RC stop_log(){
91     if(!log_file_fp){
92     closelog();
93     }
94     return EES_SUCCESS;
95     }
96    
97 aramv 1142 /*!
98     * Sets the global modules path to load plug-ins from
99     */
100     void set_modules_path(const char* path){
101     _modules_path = path;
102     }
103 aramv 1087
104 aramv 890 /*!
105     * Returns the global modules path to load plug-ins from
106 aramv 1142 * 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.
107 aramv 890 */
108 aramv 844 const char* get_modules_path(void){
109 aramv 1142 if(_modules_path != NULL){
110     if(strlen(_modules_path)!=0){
111     return _modules_path;
112     }
113     }
114     return MODULE_DIR;
115 aramv 844 }

Properties

Name Value
svn:mergeinfo

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