Last change
on this file was
65e3c6b,
checked in by Mei <mei@…>, 11 years ago
|
1) fixed an off by one bug in expand_key
|
-
Property mode set to
100644
|
File size:
1.5 KB
|
Line | |
---|
1 | /** |
---|
2 | ctxtQuery4. |
---|
3 | |
---|
4 | testing mnemonic part of libabac in c |
---|
5 | |
---|
6 | call: ./ctxtQuery4_r coyote_attr.xml |
---|
7 | |
---|
8 | gcc -g -I/home/mei/Deter/abac0-master-new/libabac -c ctxtQuery4.c -o ctxtQuery4.o |
---|
9 | gcc -g -o ctxtQuery4_r ctxtQuery4.o -L/home/mei/Deter/abac0-master-new/libabac/.libs -labac -lm -lpthread -Wl,-rpath |
---|
10 | **/ |
---|
11 | |
---|
12 | #define _GNU_SOURCE |
---|
13 | #include <err.h> |
---|
14 | #include <stdio.h> |
---|
15 | #include <assert.h> |
---|
16 | |
---|
17 | #include <abac.h> |
---|
18 | |
---|
19 | extern char *abac_id_keyid(abac_id_t *id); |
---|
20 | |
---|
21 | int main(int argc, char **argv) { |
---|
22 | int i, success=0; |
---|
23 | abac_credential_t *cred=NULL; |
---|
24 | abac_credential_t **credentials=NULL; |
---|
25 | |
---|
26 | abac_context_t *ctx = abac_context_new(); |
---|
27 | int rc; |
---|
28 | |
---|
29 | rc=abac_context_load_attribute_file(ctx, argv[1]); |
---|
30 | if(rc!=0) { |
---|
31 | printf("can not open file %s\n", argv[1]); |
---|
32 | return 1; |
---|
33 | } |
---|
34 | |
---|
35 | credentials=abac_context_credentials(ctx); |
---|
36 | for (i = 0; credentials[i] != NULL; ++i) { |
---|
37 | cred = credentials[i]; |
---|
38 | printf("credential %s <- %s\n", |
---|
39 | abac_role_string(abac_credential_head(cred)), |
---|
40 | abac_role_string(abac_credential_tail(cred))); |
---|
41 | printf("short credential %s <- %s\n", |
---|
42 | abac_role_short_string(abac_credential_head(cred),ctx), |
---|
43 | abac_role_short_string(abac_credential_tail(cred),ctx)); |
---|
44 | } |
---|
45 | if(credentials) |
---|
46 | abac_context_credentials_free(credentials); |
---|
47 | |
---|
48 | abac_context_free(ctx); |
---|
49 | return 0; |
---|
50 | } |
---|
51 | |
---|
52 | |
---|
Note: See
TracBrowser
for help on using the repository browser.