source: libabac/prover_yap.c @ d037f54

mei_rt2mei_rt2_fix_1
Last change on this file since d037f54 was 8bd77b5, checked in by Mei <mei@…>, 12 years ago

1) convert parser and libabac to use id cred and attr cred like

creddy (move those 2 files to libabac).

2) fix up abac.hh to work with expanded libabac. can now build

structure from python script

3) redid the credential dump using the internal credential table

instead of depending on a search in db.

  • Property mode set to 100644
File size: 1.9 KB
Line 
1
2#include <err.h>
3#include <stdio.h>
4#include <assert.h>
5
6
7#include "abac_internal.h"
8
9#include "options.h"
10
11extern void abac_print_cred_info(abac_credential_t*, FILE*);
12
13int main(int argc, char **argv) {
14    int i, success=0;
15    abac_credential_t *cred=NULL;
16    abac_credential_t **credentials=NULL;
17
18    options_t opts = { 0, };
19    get_options(argc, argv, &opts);
20    abac_context_t *ctx = abac_context_new();
21    abac_context_load_directory(ctx, opts.keystore);
22
23    if(opts.filename) { 
24        credentials = abac_context_credentials(ctx);
25        FILE *fp=fopen(opts.filename,"w+");
26
27        if (credentials != NULL) {
28            for (i = 0; credentials[i] != NULL; ++i) {
29                cred = credentials[i];
30                abac_print_cred_info(cred,fp);
31            }
32            abac_context_credentials_free(credentials);
33        }
34        fclose(fp);
35        return 0;
36    }
37
38    char *query=NULL;
39    char *with=NULL;
40    if(opts.role && opts.principal) {
41        query=opts.role;
42        with=opts.principal;
43        } else {
44            if(opts.oset) {
45                query=opts.oset;
46            } 
47            if(opts.principal) {
48                with=opts.principal;
49            } else if(opts.object) {
50                with=opts.object;
51            }
52            if(with==NULL || query==NULL) {
53                puts("prover eeekkk \n");
54                assert(0);
55            }
56    }
57    credentials = abac_context_query(ctx,
58                            query, with,
59                            &success);
60    if (success)
61        puts("prover success!!");
62        else puts("prover failed!!");
63
64    if (credentials != NULL && success) {
65        puts("credentials needed :");
66        for (i = 0; credentials[i] != NULL; ++i) {
67           cred = credentials[i];
68           abac_print_cred_info(cred,NULL);
69        }
70    }
71    if(credentials)
72        abac_context_credentials_free(credentials);
73    abac_context_free(ctx);
74   
75    return 0;
76}
Note: See TracBrowser for help on using the repository browser.