/[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 1495 - (show annotations) (download) (as text)
Wed Feb 10 15:05:18 2010 UTC (12 years, 3 months ago) by aramv
File MIME type: text/x-chdr
File size: 2374 byte(s)
Added module for EICs, moved -L flag to CFLAGS - time to test with ETICS
1 #include "eef_library.h"
2 #include "eef_xacml_parser.h"
3 #include "pdl.h"
4 #include "plugin_manager.h"
5
6 static const char* _modules_path; /*! Holds the global path to plug-in modules */
7
8 /**
9 * Try to initialize the AOS, enable logging, initialize the plug-in manager and try to parse the config file and ascertain the module path
10 */
11 EES_RC EEF_Init(char *config_file, FILE* log_file, int number_of_policies, char* names_of_policies[]){
12 start_log(log_file);
13 eef_log(LOG_NOTICE, "EEF initializing");
14
15 if (AOS_Init() == EES_SUCCESS){
16 if(start_plugin_manager() == EES_SUCCESS){
17 return start_pdl_parser(config_file, number_of_policies, names_of_policies);
18 }
19 }
20 return EES_FAILURE;
21 }
22
23 /**
24 * Terminates the parser, stops the plug-in manager, terminates the AOS and closes the log.
25 */
26 EES_RC EEF_Term(){
27
28 eef_log(LOG_INFO, "Cleaning up...");
29 if((pdl_term() == EES_SUCCESS) &&
30 (stop_plugin_manager() == EES_SUCCESS) &&
31 (AOS_Term() == EES_SUCCESS)){
32 stop_log();
33 return EES_SUCCESS;
34 }
35 eef_log(LOG_ERR, "Errors detected\n");
36 eef_log(LOG_NOTICE, "EEF terminating...");
37 stop_log();
38 return EES_FAILURE;
39 }
40
41 /**
42 * Opens the log file or logs to syslog if none was provided.
43 * log mask is set depending on whether ENABLE_DEBUG macro is set to true
44 */
45 EES_RC start_log(FILE* log_file){
46 /* Log file */
47 log_file_fp = log_file;
48
49 if(!log_file_fp){
50 /* logmask for debug */
51 #if ENABLE_DEBUG
52 setlogmask (LOG_UPTO(LOG_DEBUG));
53 eef_log(LOG_DEBUG, "DEBUG MODE ENABLED\n");
54 #else
55 setlogmask (LOG_UPTO(LOG_INFO));
56 #endif
57 } else {
58 /* Open syslog, regardless of use*/
59 openlog ("ees", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_DAEMON);
60 }
61 return EES_SUCCESS;
62
63 }
64
65 /**
66 * Closes the log file
67 */
68 EES_RC stop_log(){
69 if(!log_file_fp){
70 closelog();
71 }
72 return EES_SUCCESS;
73 }
74
75 /**
76 * Sets the global modules path to load plug-ins from
77 */
78 void set_modules_path(const char* path){
79 _modules_path = path;
80 }
81
82 /**
83 * Returns the global modules path to load plug-ins from
84 * 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.
85 */
86 const char* get_modules_path(void){
87 if(_modules_path != NULL){
88 if(strlen(_modules_path)!=0){
89 return _modules_path;
90 }
91 }
92 return MODULE_DIR;
93 }

Properties

Name Value
svn:mergeinfo

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