/[pdpsoft]/trunk/grid-mw-security/ees/src/app/aos_threading_test.c
ViewVC logotype

Contents of /trunk/grid-mw-security/ees/src/app/aos_threading_test.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1754 - (show annotations) (download) (as text)
Thu Jun 10 16:35:55 2010 UTC (11 years, 7 months ago) by aramv
File MIME type: text/x-chdr
File size: 2565 byte(s)
Fixed most memleaks in localaccount/localgroup plugin
1 #define _MULTI_THREADED
2 #define NUM_THREADS 2
3
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <pthread.h>
7 #include "eef_library.h"
8 #include "cgul/log_to_file/log_to_file.h"
9
10 EES_RC add_dummy_aos_obligation(void); /* adds some stuff to the AOS */
11
12 /**
13 * Adds some dummy uid/gid obligations in the AOS
14 */
15 EES_RC add_dummy_aos_obligation(void){
16 aos_context_t *_context, *_another_context;
17 aos_attribute_t *_uid, *_gid;
18
19 char* _uid_str = "1234";
20 char* _gid_str = "1234";
21
22 /*fill aos */
23 _uid = createAttribute();
24 _gid = createAttribute();
25
26 setAttributeId(_uid, "posix-uid");
27 setAttributeValue(_uid, _uid_str, strlen(_uid_str));
28 setAttributeId(_gid, "posix-gid");
29 setAttributeValue(_gid, _gid_str, strlen(_gid_str));
30
31 if((_context = createContext(OBLIGATION)) != NULL){
32 setContextObligationId(_context, "uidgid");
33
34 addAttribute(_context, _uid);
35 addAttribute(_context, _gid);
36
37 addContext(_context);
38 }
39 if((_another_context = createContext(ANY)) != NULL){
40 addContext(_another_context);
41 }
42 return EES_SUCCESS;
43 }
44
45 int main (int argc, char* argv[]){
46 char* config_file;
47 pthread_t threads[NUM_THREADS];
48 long t;
49 int rc;
50 void* status;
51
52 /*sleep(10);*/
53
54 aos_attribute_t* pemstring;
55 aos_context_t* _context;
56 aos_attribute_t *_uid, *_gid;
57
58 char* _uid_str = "1234";
59 char* _gid_str = "1234";
60
61 if(argc > 1){
62 config_file = argv[1];
63 } else {
64 config_file = "examples/example_1.pdl";
65 }
66
67 cgul_openlog("/tmp/aos_threading_test_log");
68 cgul_set_ident(BINARY_NAME);
69 cgul_set_log_options(CGUL_SYSLOG | CGUL_LOGFILE | CGUL_STDERR);
70 #if ENABLE_DEBUG
71 cgul_set_log_options(cgul_get_log_options() | CGUL_STDDEBUG);
72 #endif
73
74 /* reuse this part when implementing SIGHUP */
75 cgul_log(LOG_INFO, "Parsing config file %s\n", config_file);
76 if(EEF_init(config_file, cgul_log) == EES_FAILURE){
77 EEF_log(LOG_ERR, "Failed to parse config file (%s), exiting...", config_file);
78 } else {
79
80 add_dummy_aos_obligation();
81 /*EEF_run();*/
82 /*aos_dump_argslist();*/
83 aos_start_threading();
84 /* start threading */
85 for(t=0; t < NUM_THREADS; t++){
86 printf("Creating thread %li!\n", t);
87 rc = pthread_create(&threads[t], NULL, (void * (*)(void *)) EEF_run, (void*)(t));
88 rc = pthread_join(threads[t], &status);
89 }
90 }
91 /*sleep(10);*/
92 /*AOS_Clean();*/
93 if(EEF_term() == EES_SUCCESS){
94 EEF_log(LOG_NOTICE, "EEF terminated!\n");
95 } else {
96 EEF_log(LOG_ERR, "Error while terminating EEF!\n");
97 }
98 cgul_closelog();
99
100 /*sleep(10);*/
101
102 pthread_exit(NULL);
103 return 0;
104 }
105

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