[e95d652] | 1 | |
---|
| 2 | /* copied from abac_graph.c |
---|
| 3 | implementation of the low level using |
---|
| 4 | yap prolog |
---|
| 5 | */ |
---|
| 6 | |
---|
| 7 | #include <err.h> |
---|
| 8 | #include <stdio.h> |
---|
| 9 | #include <assert.h> |
---|
| 10 | #include <stdlib.h> |
---|
| 11 | #include <string.h> |
---|
| 12 | #include <Yap/YapInterface.h> |
---|
| 13 | |
---|
[8bd77b5] | 14 | #include "abac_internal.h" |
---|
[e95d652] | 15 | |
---|
[8bd77b5] | 16 | #include "abac_pl_yap.h" |
---|
[e95d652] | 17 | #include "abac_util.h" |
---|
| 18 | |
---|
| 19 | #include "uthash.h" |
---|
| 20 | |
---|
[da5afdf] | 21 | extern abac_list_t *abac_credential_clauses(abac_credential_t *); |
---|
[8bd77b5] | 22 | extern char *abac_id_clause(abac_id_credential_t *); |
---|
| 23 | extern abac_aspect_t *abac_yy_get_rule_tail_aspect(); |
---|
| 24 | extern abac_aspect_t *abac_yy_get_rule_head_aspect(); |
---|
[0d0c3a9] | 25 | |
---|
[bf68132] | 26 | /* XXXX */ |
---|
| 27 | extern YAP_Term YAP_WriteBuffer(YAP_Term, char *, unsigned int, int); |
---|
| 28 | |
---|
[202a7f9] | 29 | static int debug=0; |
---|
[8bd77b5] | 30 | |
---|
[d5bbd3e] | 31 | /* track constraint's external clause's -unique name id */ |
---|
[8bd77b5] | 32 | |
---|
[d5bbd3e] | 33 | static int constraint_label_count=0; |
---|
| 34 | static char *constraint_label="isABAC_constraint"; |
---|
[e95d652] | 35 | |
---|
[da5afdf] | 36 | // pl -- place holder for now |
---|
[e95d652] | 37 | struct _abac_pl_t { |
---|
| 38 | FILE *fptr; |
---|
| 39 | char *fname; |
---|
| 40 | char *yap_certs; |
---|
| 41 | }; |
---|
| 42 | |
---|
[d5bbd3e] | 43 | /***********************************************************/ |
---|
| 44 | static int _get_next_constraint_label_idx() |
---|
| 45 | { |
---|
| 46 | constraint_label_count++; |
---|
| 47 | return constraint_label_count; |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | static int _get_constraint_label_idx() |
---|
| 51 | { |
---|
| 52 | return constraint_label_count; |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | /***********************************************************/ |
---|
| 56 | |
---|
[53e540d] | 57 | static int _insert_clause(char *str) |
---|
[e95d652] | 58 | { |
---|
[202a7f9] | 59 | YAP_Term *eterm; |
---|
[53e540d] | 60 | YAP_Term goalArgs=YAP_ReadBuffer(str, eterm); |
---|
| 61 | char *tmp=YAP_CompileClause(goalArgs); |
---|
| 62 | if (tmp!=NULL) { /* something is wrong */ |
---|
| 63 | printf("error: result of compile clause (%s)\n", tmp); |
---|
| 64 | printf("error: str used (%s)\n", str); |
---|
| 65 | return 1; |
---|
[e95d652] | 66 | } |
---|
[53e540d] | 67 | return 0; |
---|
[e95d652] | 68 | } |
---|
| 69 | |
---|
[53e540d] | 70 | static int _insert_cred_clause(char *cstr) |
---|
[e95d652] | 71 | { |
---|
| 72 | int ret=ABAC_CERT_SUCCESS; |
---|
[53e540d] | 73 | int rc=_insert_clause(cstr); |
---|
| 74 | if (rc) |
---|
| 75 | return ABAC_CERT_BAD_YAP; |
---|
| 76 | return ABAC_CERT_SUCCESS; |
---|
[e95d652] | 77 | } |
---|
| 78 | |
---|
[440ba20] | 79 | void show_yap_db(const char *msg) |
---|
[e95d652] | 80 | { |
---|
| 81 | char lstr[]="listing"; |
---|
[da5afdf] | 82 | YAP_Term *eterm; /* error term */ |
---|
[e95d652] | 83 | |
---|
[53e540d] | 84 | printf("\n\n========= yap db (%s)\n",msg); |
---|
[e95d652] | 85 | YAP_Term goal=YAP_ReadBuffer(lstr, eterm); |
---|
| 86 | int rc =YAP_RunGoal( goal ); |
---|
| 87 | if (rc) { |
---|
| 88 | printf("listing ok.. \n"); |
---|
| 89 | } else { |
---|
| 90 | printf("listing's rc is bad.. \n"); |
---|
| 91 | YAP_Exit(1); |
---|
| 92 | } |
---|
[53e540d] | 93 | printf("========= \n\n"); |
---|
[e95d652] | 94 | } |
---|
| 95 | |
---|
[53e540d] | 96 | /** |
---|
| 97 | * Include some utility routines |
---|
| 98 | */ |
---|
| 99 | abac_pl_t *abac_pl_utility(void) { |
---|
| 100 | /* |
---|
| 101 | append([],L,L). |
---|
| 102 | append([X|L1],L2,[X|L3]):-append(L1,L2,L3). |
---|
| 103 | |
---|
| 104 | appendL([],[]). |
---|
| 105 | appendL([H|T], L) :- |
---|
| 106 | appendL(T,L2), append(H,L2,L). |
---|
| 107 | */ |
---|
| 108 | if(_insert_clause("append([],L,L)")) |
---|
| 109 | YAP_Exit(1); |
---|
| 110 | if(_insert_clause("append([X|L1],L2,[X|L3]):-append(L1,L2,L3)")) |
---|
| 111 | YAP_Exit(1); |
---|
| 112 | if(_insert_clause("appendL([],[])")) |
---|
| 113 | YAP_Exit(1); |
---|
| 114 | if(_insert_clause("appendL([H|T], L) :- appendL(T,L2), append(H,L2,L)")) |
---|
| 115 | YAP_Exit(1); |
---|
[e95d652] | 116 | } |
---|
| 117 | |
---|
[53e540d] | 118 | /** |
---|
| 119 | * Create a new yap structure. |
---|
| 120 | */ |
---|
| 121 | abac_pl_t *abac_pl_new(void) { |
---|
| 122 | |
---|
| 123 | if (YAP_FastInit(NULL) == YAP_BOOT_ERROR) |
---|
| 124 | YAP_Exit(1); |
---|
| 125 | |
---|
| 126 | if (YAP_RunGoal(YAP_MkAtomTerm(YAP_LookupAtom("source")))) { |
---|
[2485307] | 127 | if(debug) fprintf(stderr, "calling source..\n"); |
---|
[53e540d] | 128 | } else { |
---|
[2485307] | 129 | if(debug) fprintf(stderr,"calling source failed..\n"); |
---|
[202a7f9] | 130 | YAP_Exit(1); |
---|
[53e540d] | 131 | } |
---|
| 132 | |
---|
| 133 | abac_pl_utility(); |
---|
| 134 | |
---|
| 135 | abac_pl_t *pl = abac_xmalloc(sizeof(abac_pl_t)); |
---|
| 136 | pl->fptr=NULL; |
---|
| 137 | pl->fname=NULL; |
---|
| 138 | pl->yap_certs=NULL; |
---|
| 139 | return pl; |
---|
[e95d652] | 140 | } |
---|
| 141 | |
---|
[53e540d] | 142 | /** |
---|
[5730a10] | 143 | * Add a credential to the db, not duplicating a copy and so |
---|
| 144 | * don't try to free it after this call. |
---|
[53e540d] | 145 | */ |
---|
| 146 | int abac_pl_add_credential(abac_pl_t *pl, abac_credential_t *cred) |
---|
| 147 | { |
---|
| 148 | int rc=0; |
---|
[202a7f9] | 149 | abac_list_t *clauses=abac_credential_clauses(cred); |
---|
| 150 | if (clauses != NULL) { |
---|
| 151 | char *cur; |
---|
| 152 | abac_list_foreach(clauses, cur, |
---|
| 153 | if(cur) { |
---|
[2485307] | 154 | if(debug) fprintf(stderr,"inserting =>%s\n",cur); |
---|
[202a7f9] | 155 | rc=_insert_cred_clause(cur); |
---|
| 156 | } |
---|
| 157 | ); |
---|
[53e540d] | 158 | } |
---|
| 159 | return rc; |
---|
| 160 | } |
---|
[e95d652] | 161 | |
---|
[8bd77b5] | 162 | int abac_pl_add_type_credential(abac_pl_t *pl, abac_id_credential_t *id_cert) |
---|
[202a7f9] | 163 | { |
---|
| 164 | char *clause=abac_id_clause(id_cert); |
---|
| 165 | if (clause != NULL) { |
---|
| 166 | int rc=_insert_cred_clause(clause); |
---|
| 167 | return rc; |
---|
| 168 | } |
---|
| 169 | return 0; |
---|
| 170 | } |
---|
| 171 | |
---|
[d5bbd3e] | 172 | /* string1(S):- S="abc";S="efg";S="ijk" */ |
---|
[7b548fa] | 173 | char *abac_pl_add_range_constraint_clause(char *var, char *tmplist) |
---|
[d5bbd3e] | 174 | { |
---|
| 175 | int i=_get_next_constraint_label_idx(); |
---|
| 176 | char *tmp=NULL; |
---|
| 177 | asprintf(&tmp,"%s_%d(%s) :- %s", constraint_label, i, var, tmplist); |
---|
| 178 | int rc=_insert_cred_clause(tmp); |
---|
| 179 | free(tmp); |
---|
| 180 | if(rc) |
---|
[7b548fa] | 181 | panic("abac_pl_add_range_constraint_clause, failed to insert"); |
---|
[d5bbd3e] | 182 | asprintf(&tmp,"%s_%d(%s)", constraint_label, i, var); |
---|
| 183 | return tmp; |
---|
| 184 | } |
---|
| 185 | |
---|
[da5afdf] | 186 | /* cases, |
---|
[e95d652] | 187 | ['str'] |
---|
| 188 | ['str1','str2'] |
---|
| 189 | ([] is not possible, and don't care) |
---|
| 190 | */ |
---|
[202a7f9] | 191 | static void _credentials_from_string(abac_stack_t *credentials,char *slist) { |
---|
[e95d652] | 192 | char *cptr=slist; /* current ptr */ |
---|
| 193 | char *sptr; /* string ptr */ |
---|
| 194 | char *ptr; |
---|
[202a7f9] | 195 | int len=0; |
---|
[e95d652] | 196 | char *string; |
---|
| 197 | abac_credential_t *cred=NULL; |
---|
[202a7f9] | 198 | int cnt=0; |
---|
| 199 | |
---|
[e95d652] | 200 | /* find first [' */ |
---|
| 201 | ptr=strstr(cptr,"['"); |
---|
| 202 | if(ptr == NULL) |
---|
| 203 | return; |
---|
| 204 | cptr=ptr+2; |
---|
| 205 | sptr=cptr; |
---|
| 206 | while (1) { |
---|
| 207 | /* find next ',' or '] */ |
---|
| 208 | ptr=strstr(cptr,"','"); |
---|
| 209 | if(ptr!=NULL) { |
---|
| 210 | cptr=ptr+3; |
---|
[202a7f9] | 211 | len=(ptr-sptr); |
---|
[e95d652] | 212 | string=strndup(sptr,len); |
---|
| 213 | cred=abac_credential_lookup(string); |
---|
[202a7f9] | 214 | free(string); |
---|
[e95d652] | 215 | if(cred) { |
---|
[7b548fa] | 216 | int i=abac_stack_unique_push(credentials, cred); |
---|
| 217 | if(i) cnt++; |
---|
[e95d652] | 218 | } else { |
---|
[9b43fc3] | 219 | printf("BAD BAD\n"); |
---|
[e95d652] | 220 | } |
---|
| 221 | sptr=cptr; |
---|
| 222 | } else { |
---|
| 223 | ptr=strstr(cptr,"']"); |
---|
| 224 | if(ptr!=NULL) { |
---|
[202a7f9] | 225 | len=(ptr-sptr); |
---|
[e95d652] | 226 | string=strndup(sptr,len); |
---|
| 227 | cred=abac_credential_lookup(string); |
---|
[202a7f9] | 228 | free(string); |
---|
[e95d652] | 229 | if(cred) { |
---|
[7b548fa] | 230 | int i=abac_stack_unique_push(credentials, cred); |
---|
| 231 | if(i) cnt++; |
---|
[e95d652] | 232 | } else { |
---|
| 233 | printf("BAD BAD BAD\n"); |
---|
| 234 | } |
---|
| 235 | break; |
---|
| 236 | } |
---|
| 237 | } |
---|
| 238 | } |
---|
[202a7f9] | 239 | if(debug) |
---|
[2485307] | 240 | fprintf(stderr,"DEBUG:total %d credentials\n", cnt); |
---|
| 241 | } |
---|
| 242 | |
---|
| 243 | /* MAX 1024x1024, double as it goes */ |
---|
| 244 | static int try_again(int sz, char **tptr) |
---|
| 245 | { |
---|
| 246 | int blk=1024*2; /* 2048 */ |
---|
| 247 | int max=1024*1024; |
---|
| 248 | int size; |
---|
| 249 | char *tmp = NULL; |
---|
| 250 | |
---|
| 251 | if(sz==0) { |
---|
| 252 | size = (sizeof(char) * (blk+1)); |
---|
| 253 | } else { |
---|
| 254 | if (sz>=max) { |
---|
| 255 | size=0; |
---|
| 256 | *tptr=tmp; |
---|
| 257 | return 0; |
---|
| 258 | } |
---|
| 259 | size=sz*2+1; |
---|
| 260 | if(size > max) size=max; |
---|
| 261 | } |
---|
| 262 | |
---|
| 263 | tmp = (char *) YAP_AllocSpaceFromYap(size); |
---|
| 264 | if(tmp==NULL) { |
---|
| 265 | fprintf(stderr,"ERROR: malloc failed !!!\n"); |
---|
| 266 | YAP_Exit(1); |
---|
| 267 | } |
---|
| 268 | *tptr=tmp; |
---|
| 269 | return size; |
---|
[e95d652] | 270 | } |
---|
| 271 | |
---|
[9335cfa] | 272 | /* make a query and extract just 1 set of result */ |
---|
[7727f26] | 273 | static abac_stack_t *_make_yap_query(char *prin, char *rule, char* estring) |
---|
[e95d652] | 274 | { |
---|
[36b100a] | 275 | YAP_Term *eterm0; |
---|
| 276 | YAP_Term *eterm1; |
---|
[e95d652] | 277 | YAP_Term arg[3]; |
---|
[2485307] | 278 | |
---|
[202a7f9] | 279 | abac_stack_t *cred_list = abac_stack_new(); |
---|
| 280 | |
---|
[2485307] | 281 | if(debug) fprintf(stderr," the principal part(%s)\n", prin); |
---|
[7727f26] | 282 | if(prin[0]=='\'' || prin[0]=='"') { |
---|
| 283 | arg[0]=YAP_ReadBuffer(prin,eterm0); |
---|
[36b100a] | 284 | } else { |
---|
[7727f26] | 285 | arg[0]=YAP_MkAtomTerm(YAP_LookupAtom(prin)); |
---|
[36b100a] | 286 | } |
---|
[2485307] | 287 | if(debug) fprintf(stderr," the role/oset part(%s)\n", estring); |
---|
[36b100a] | 288 | arg[1]=YAP_ReadBuffer(estring,eterm1); |
---|
| 289 | |
---|
| 290 | /* var for credential list */ |
---|
[da5afdf] | 291 | arg[2]=YAP_MkVarTerm(); |
---|
[36b100a] | 292 | |
---|
[da5afdf] | 293 | YAP_Atom f = YAP_LookupAtom("isMember"); |
---|
| 294 | YAP_Functor func = YAP_MkFunctor(f, 3); |
---|
| 295 | YAP_Term goal=YAP_MkApplTerm(func, 3, arg); |
---|
| 296 | |
---|
| 297 | int rc =YAP_RunGoal( goal ); |
---|
| 298 | if (rc) { |
---|
| 299 | printf("YAP query succeed\n"); |
---|
[2485307] | 300 | char *tmp=NULL; |
---|
| 301 | int tmp_sz=try_again(0, &tmp); |
---|
| 302 | while(1) { |
---|
[bf68132] | 303 | YAP_WriteBuffer(arg[2], tmp, tmp_sz,YAP_WRITE_HANDLE_VARS); |
---|
[1e51e1b] | 304 | if(strlen(tmp) > 5 && tmp[0]=='\[') |
---|
[2485307] | 305 | break; |
---|
| 306 | tmp_sz=try_again(tmp_sz,&tmp); |
---|
[bf68132] | 307 | if(tmp_sz==0) { |
---|
| 308 | fprintf(stderr," PANIC, run out of heap space..\n"); |
---|
| 309 | YAP_Exit(1); |
---|
| 310 | } |
---|
[2485307] | 311 | } |
---|
[da5afdf] | 312 | /* this is returned as ['string1','string2'] */ |
---|
[2485307] | 313 | if(debug) fprintf(stderr," query answer : %s(%d)\n", tmp, strlen(tmp)); |
---|
[da5afdf] | 314 | _credentials_from_string(cred_list,tmp); |
---|
[2485307] | 315 | if(abac_stack_size(cred_list)==0) { |
---|
| 316 | fprintf(stderr,"CAN NOT retrieve result properly from YAP!!!\n"); |
---|
| 317 | YAP_Exit(1); |
---|
| 318 | } |
---|
[b92a620] | 319 | YAP_FreeSpaceFromYap(tmp); |
---|
[9335cfa] | 320 | /**** XXX |
---|
[da5afdf] | 321 | while (YAP_RestartGoal()) { |
---|
[2485307] | 322 | if(debug) fprintf(stderr,"another success\n"); |
---|
[da5afdf] | 323 | YAP_WriteBuffer(arg[2], tmp, 5000,YAP_WRITE_HANDLE_VARS); |
---|
[2485307] | 324 | if(debug) fprintf(stderr," restart query answer : %s\n", tmp); |
---|
[da5afdf] | 325 | _credentials_from_string(cred_list,tmp); |
---|
| 326 | } |
---|
[9335cfa] | 327 | ***/ |
---|
[da5afdf] | 328 | } else { |
---|
| 329 | printf("YAP query failed\n"); |
---|
| 330 | /* YAP_Exit(1); */ |
---|
| 331 | } |
---|
[08b8da7] | 332 | /*** MEI ***/ |
---|
| 333 | YAP_Reset(); |
---|
[da5afdf] | 334 | return cred_list; |
---|
| 335 | } |
---|
| 336 | |
---|
| 337 | /* 2 types |
---|
| 338 | acme.buys_rocket <- coyote (coyote=prin, acme.buys_rocket=role) |
---|
| 339 | ==> isMember(coyote,role(acme,buys_rocket), L) |
---|
[440ba20] | 340 | acme.buys_rocket <- acme.preferred_customer -- NOT valid |
---|
| 341 | */ |
---|
[8bd77b5] | 342 | static abac_stack_t *_query_with_aspect(abac_pl_t *pl, abac_aspect_t* head, abac_aspect_t* tail) |
---|
[da5afdf] | 343 | { |
---|
| 344 | abac_stack_t *ret=NULL; |
---|
[2485307] | 345 | char *tmp=NULL; |
---|
[da5afdf] | 346 | |
---|
[08b8da7] | 347 | if(0) |
---|
[440ba20] | 348 | show_yap_db("DEBUG:calling within _query_with_aspect"); |
---|
[da5afdf] | 349 | |
---|
[d037f54] | 350 | char *nm; |
---|
| 351 | PROLOG(nm=abac_aspect_principal_name(head);); |
---|
[8bd77b5] | 352 | |
---|
[da5afdf] | 353 | /* could be obj or principal */ |
---|
[7727f26] | 354 | char *prin_nm=NULL; |
---|
[8bd77b5] | 355 | if(abac_aspect_is_object(tail)) { |
---|
| 356 | prin_nm=abac_aspect_object_name(tail); |
---|
[da5afdf] | 357 | } else { |
---|
[d037f54] | 358 | PROLOG(prin_nm=abac_aspect_principal_name(tail);); |
---|
[da5afdf] | 359 | } |
---|
| 360 | |
---|
[8bd77b5] | 361 | if(abac_aspect_aspect_name(tail)!=NULL) { |
---|
| 362 | printf("fail, a.o <- b.o and a.r <- a.r query is not implemented yet !!!\n"); |
---|
[da5afdf] | 363 | YAP_Exit(1); |
---|
| 364 | } |
---|
| 365 | |
---|
[8bd77b5] | 366 | if (prin_nm == NULL || nm == NULL) { |
---|
| 367 | printf("fail, query's call got bad aspect names .. \n"); |
---|
[da5afdf] | 368 | YAP_Exit(1); |
---|
| 369 | } |
---|
| 370 | |
---|
[2485307] | 371 | if(debug) fprintf(stderr,"printing up the yap query ..\n"); |
---|
[d037f54] | 372 | |
---|
| 373 | char *pstring; |
---|
| 374 | PROLOG(pstring=abac_aspect_aspect_param_string(head);); |
---|
| 375 | |
---|
[8bd77b5] | 376 | char *stub=abac_aspect_type_string(head); |
---|
[da5afdf] | 377 | if(pstring) { |
---|
[2485307] | 378 | asprintf(&tmp,"%s(%s,%s,%s)", stub, nm, abac_aspect_aspect_name(head),pstring); |
---|
[da5afdf] | 379 | free(pstring); |
---|
| 380 | } else { |
---|
[2485307] | 381 | asprintf(&tmp,"%s(%s,%s)", stub, nm, abac_aspect_aspect_name(head)); |
---|
[da5afdf] | 382 | } |
---|
| 383 | |
---|
[8bd77b5] | 384 | ret=_make_yap_query(prin_nm,nm,tmp); |
---|
[da5afdf] | 385 | return ret; |
---|
| 386 | } |
---|
| 387 | |
---|
| 388 | /** |
---|
| 389 | * Get all the credentials (attribute/issuer cert pairs) from prolog |
---|
| 390 | * (which returns in string form) |
---|
| 391 | */ |
---|
| 392 | abac_stack_t *abac_pl_credentials(abac_pl_t *pl) |
---|
| 393 | { |
---|
[8bd77b5] | 394 | abac_stack_t *ret=abac_verifier_dump_creds(); |
---|
[da5afdf] | 395 | return ret; |
---|
| 396 | } |
---|
| 397 | |
---|
[5110d42] | 398 | abac_stack_t *abac_pl_principals(abac_pl_t *pl) |
---|
| 399 | { |
---|
| 400 | abac_stack_t *ret=abac_verifier_dump_principals(); |
---|
| 401 | return ret; |
---|
| 402 | } |
---|
| 403 | |
---|
[e95d652] | 404 | /** |
---|
| 405 | * Make a query into prolog db |
---|
| 406 | --role acme.preferred_customer --principal coyote |
---|
| 407 | --role acme.prefer_customer.buy_rockets --principlal coyote |
---|
[da5afdf] | 408 | --oset acme.rockets -- object mrx-21 |
---|
| 409 | --oset acme.villans -- principal coyote |
---|
[e95d652] | 410 | */ |
---|
[da5afdf] | 411 | abac_stack_t *abac_pl_query(abac_pl_t *pl, char *roleoset, char *prinobj) |
---|
[e95d652] | 412 | { |
---|
[202a7f9] | 413 | abac_stack_t *ret=NULL; |
---|
[da5afdf] | 414 | int len=strlen(roleoset)+strlen(prinobj)+5; |
---|
| 415 | char* attr_string=(char *) abac_xmalloc(sizeof(char)*len); |
---|
| 416 | sprintf(attr_string,"%s<-%s", roleoset, prinobj); |
---|
| 417 | |
---|
| 418 | if(debug) |
---|
[2485307] | 419 | fprintf(stderr,"abac_pl_query, query string is (%s)\n",attr_string); |
---|
[e95d652] | 420 | |
---|
[da5afdf] | 421 | /* call into yacc parser */ |
---|
| 422 | abac_reset_yyfptr(attr_string); |
---|
[b5a3da4] | 423 | abac_yy_init(); |
---|
[da5afdf] | 424 | int rc=yyparse(); |
---|
| 425 | if (rc) { |
---|
| 426 | free(attr_string); |
---|
[e95d652] | 427 | return NULL; |
---|
| 428 | } |
---|
| 429 | |
---|
[8bd77b5] | 430 | abac_aspect_t *head_aspect = abac_yy_get_rule_head_aspect(); |
---|
| 431 | abac_aspect_t *tail_aspect = abac_yy_get_rule_tail_aspect(); |
---|
[2efdff5] | 432 | |
---|
[8bd77b5] | 433 | ret=_query_with_aspect(pl,head_aspect,tail_aspect); |
---|
| 434 | |
---|
[e95d652] | 435 | return ret; |
---|
| 436 | } |
---|
| 437 | |
---|
[d9c3886] | 438 | abac_stack_t *abac_pl_query_with_structure(abac_pl_t *pl, abac_aspect_t *head_aspect, abac_aspect_t *tail_aspect) |
---|
| 439 | { |
---|
| 440 | abac_stack_t *ret=NULL; |
---|
| 441 | ret=_query_with_aspect(pl,head_aspect,tail_aspect); |
---|
| 442 | |
---|
| 443 | return ret; |
---|
| 444 | } |
---|
| 445 | |
---|
[e95d652] | 446 | void abac_pl_free(abac_pl_t *pl) { |
---|
| 447 | if(pl->fptr) { |
---|
| 448 | fflush(pl->fptr); |
---|
| 449 | free(pl->fptr); |
---|
| 450 | } |
---|
| 451 | if(pl->fname) { |
---|
| 452 | unlink(pl->fname); |
---|
| 453 | free(pl->fname); |
---|
| 454 | } |
---|
| 455 | free(pl); |
---|
| 456 | } |
---|
| 457 | |
---|