abac0-leakabac0-meimei-idtvf-new-xml
Last change
on this file since 4423f47 was
4721618,
checked in by Mei <mei@…>, 11 years ago
|
1) tested out python and perl test scripts along with
abac_chunk_t calls in libabac's abac.hh
|
-
Property mode set to
100644
|
File size:
1.6 KB
|
Rev | Line | |
---|
[7f25a67f] | 1 | #include <err.h> |
---|
| 2 | #include <stdio.h> |
---|
| 3 | |
---|
[6ede88c] | 4 | #include <abac.h> |
---|
[4721618] | 5 | #include "abac_list.h" |
---|
[7af34ed] | 6 | #include "options.h" |
---|
| 7 | |
---|
[7f25a67f] | 8 | int main(int argc, char **argv) { |
---|
[4e426c9] | 9 | int i, success; |
---|
[401a054] | 10 | abac_credential_t *cred; |
---|
[dc62c68] | 11 | |
---|
[7af34ed] | 12 | options_t opts = { 0, }; |
---|
| 13 | get_options(argc, argv, &opts); |
---|
[7f25a67f] | 14 | |
---|
[390f749] | 15 | abac_context_t *ctx = abac_context_new(); |
---|
[7af34ed] | 16 | abac_context_load_directory(ctx, opts.keystore); |
---|
[186cb75] | 17 | |
---|
[461541a] | 18 | if(opts.rulefile) { |
---|
| 19 | FILE *fp=fopen(opts.rulefile,"w+"); |
---|
| 20 | if(fp) { |
---|
| 21 | abac_credential_t **credentials = abac_context_credentials(ctx); |
---|
| 22 | if (credentials != NULL) |
---|
| 23 | for (i = 0; credentials[i] != NULL; ++i) { |
---|
| 24 | cred = credentials[i]; |
---|
| 25 | fprintf(fp,"%s <- %s\n", |
---|
| 26 | abac_role_string(abac_credential_head(cred)), |
---|
| 27 | abac_role_string(abac_credential_tail(cred)) |
---|
| 28 | ); |
---|
| 29 | } |
---|
| 30 | abac_context_credentials_free(credentials); |
---|
| 31 | fclose(fp); |
---|
| 32 | } |
---|
| 33 | } |
---|
| 34 | |
---|
[401a054] | 35 | abac_credential_t **credentials = abac_context_query(ctx, |
---|
[7af34ed] | 36 | opts.role, opts.principal, |
---|
[4e426c9] | 37 | &success |
---|
[dc62c68] | 38 | ); |
---|
| 39 | |
---|
[4e426c9] | 40 | if (success) |
---|
| 41 | puts("success"); |
---|
[605ee1d] | 42 | else |
---|
| 43 | puts("fail, here's a partial proof"); |
---|
[4e426c9] | 44 | |
---|
| 45 | if (credentials != NULL) |
---|
| 46 | for (i = 0; credentials[i] != NULL; ++i) { |
---|
| 47 | cred = credentials[i]; |
---|
| 48 | printf("credential %s <- %s\n", |
---|
| 49 | abac_role_string(abac_credential_head(cred)), |
---|
[9a411d7] | 50 | abac_role_string(abac_credential_tail(cred)) |
---|
[4e426c9] | 51 | ); |
---|
| 52 | } |
---|
| 53 | |
---|
[3c4fd68] | 54 | abac_context_credentials_free(credentials); |
---|
[902d079] | 55 | |
---|
[390f749] | 56 | abac_context_free(ctx); |
---|
[ea401bc] | 57 | |
---|
[7f25a67f] | 58 | return 0; |
---|
| 59 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.