/[pdpsoft]/trunk/grid-mw-security/ees/src/eval_man/pdl.c
ViewVC logotype

Diff of /trunk/grid-mw-security/ees/src/eval_man/pdl.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1214 by aramv, Wed Dec 2 14:13:38 2009 UTC revision 1215 by aramv, Wed Dec 2 15:08:10 2009 UTC
# Line 400  void link_rule_to_plugin(policy_t *polic Line 400  void link_rule_to_plugin(policy_t *polic
400  }  }
401    
402  /* iterates the policies and removes those that are not explicitly named in the passed array of strings */  /* iterates the policies and removes those that are not explicitly named in the passed array of strings */
403  policy_t** reduce_policy_tree(policy_t** policies, int number_of_policies, char* names_of_policies[]){  policy_t* reduce_policy_tree(policy_t* policies, int number_of_policies, char* names_of_policies[]){
404    int i, policy_should_be_removed;    int i, policy_should_be_removed;
405    policy_t *temp_policy = NULL, *previous_policy = NULL;    policy_t *temp_policy = policies, *next_policy = NULL;
406    
407    for(temp_policy = *policies; temp_policy != NULL; previous_policy = temp_policy, temp_policy = temp_policy->next){    while(temp_policy){
408      policy_should_be_removed = 1;      policy_should_be_removed = 1;
409      eef_log(LOG_DEBUG, "Checking policy: %s\n", (temp_policy)->name);      eef_log(LOG_DEBUG, "Checking policy: %s\n", (temp_policy)->name);
410      for(i = 0; i < number_of_policies; i++){      for(i = 0; i < number_of_policies; i++){
# Line 416  policy_t** reduce_policy_tree(policy_t** Line 416  policy_t** reduce_policy_tree(policy_t**
416        }        }
417      }      }
418    
419        next_policy = temp_policy->next;
420    
421      if(policy_should_be_removed){      if(policy_should_be_removed){
422        eef_log(LOG_DEBUG, "Removing not-allowed policy: %s\n", temp_policy->name);        eef_log(LOG_DEBUG, "Removing not-allowed policy: %s\n", temp_policy->name);
423    
424        /* if the head node is deleted, overwrite it with the next node */        /**//* if the head node is deleted, overwrite it with the next node */
425        if(previous_policy == NULL){        /*if(temp_policy == *policies){*/
426          *policies = temp_policy->next;        /**policies = temp_policy->next;*/
427        } else {        /*}*/
428          previous_policy->next = temp_policy->next;  
429        }        /**//* Clean policy fields */
430          /*eef_log(LOG_DEBUG, "Deleted policy: %s\n", temp_policy->name);*/
431        /* Clean policy fields */        /*temp_policy->rules = clean_rules_list(temp_policy->rules);*/
432        eef_log(LOG_DEBUG, "Deleted policy: %s\n", temp_policy->name);        /*free(temp_policy->name);*/
433        temp_policy->rules = clean_rules_list(temp_policy->rules);        /*free(temp_policy);*/
434        free(temp_policy->name);        /*temp_policy = NULL;*/
435        free(temp_policy);        policies = remove_policy_by_name(policies, temp_policy->name);
436      }      }
437        temp_policy = next_policy;
438    }    }
439    
440    return policies;    return policies;
# Line 519  void remove_policy(record_t* policy){ Line 522  void remove_policy(record_t* policy){
522    
523  /*! Removes a policy from the list of policies */  /*! Removes a policy from the list of policies */
524  policy_t* remove_policy_by_name(policy_t* policies, char* policy){  policy_t* remove_policy_by_name(policy_t* policies, char* policy){
525    policy_t *temp_policy = policies, *next_policy = NULL;    policy_t *temp_policy = NULL, *next_policy = NULL, *previous_policy = NULL;
526    
527    while(temp_policy){    for(temp_policy = policies; temp_policy != NULL; ){
528      printf("Iterating to %s\n", temp_policy->name);      printf("Iterating to %s\n", temp_policy->name);
529        if(previous_policy){
530          printf("Previous node was: %s\n", previous_policy->name);
531        }
532      next_policy = temp_policy->next;      next_policy = temp_policy->next;
533    
534      if(strcmp(temp_policy->name, policy) == 0){      if(strcmp(temp_policy->name, policy) == 0){
# Line 538  policy_t* remove_policy_by_name(policy_t Line 544  policy_t* remove_policy_by_name(policy_t
544        eef_log(LOG_DEBUG, "Deleted policy: %s\n", policy);        eef_log(LOG_DEBUG, "Deleted policy: %s\n", policy);
545        free(temp_policy->name);        free(temp_policy->name);
546        free(temp_policy);        free(temp_policy);
547          previous_policy->next = next_policy;
548        /*break;*/        /*break;*/
549      }      }
550    
551        previous_policy = temp_policy;
552    
553      /* Move to next policy */      /* Move to next policy */
554      temp_policy = next_policy;      temp_policy = next_policy;
555    }    }
556    
557    printf("Done removing %s, here is the list\n", policy);    /*print_policies(policies);*/
   print_policies(policies);  
   free(policy);  
558    return policies;    return policies;
559  }  }
560    
# Line 630  EES_RC clean_variables_list(){ Line 637  EES_RC clean_variables_list(){
637  rule_t* clean_rules_list(rule_t* top_rule){  rule_t* clean_rules_list(rule_t* top_rule){
638    rule_t* temp_rule = top_rule;    rule_t* temp_rule = top_rule;
639    if(temp_rule){    if(temp_rule){
     free(temp_rule->state);  
   
640      clean_rules_list(temp_rule->true_branch);      clean_rules_list(temp_rule->true_branch);
641    
642      clean_rules_list(temp_rule->false_branch);      clean_rules_list(temp_rule->false_branch);
643    
644        clean_rules_list(temp_rule->next);
645    
646        free(temp_rule->state);
647      free(temp_rule);      free(temp_rule);
648      temp_rule = NULL;      temp_rule = NULL;
649    }    }

Legend:
Removed from v.1214  
changed lines
  Added in v.1215

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