/[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 1157 by aramv, Fri Nov 20 11:41:10 2009 UTC revision 1158 by aramv, Fri Nov 20 14:04:55 2009 UTC
# Line 300  void print_policies(policy_t* policies){ Line 300  void print_policies(policy_t* policies){
300        if(temp_rule->true_branch){        if(temp_rule->true_branch){
301          eef_log(LOG_DEBUG, "   True branch:  %s\n", temp_rule->true_branch->state);          eef_log(LOG_DEBUG, "   True branch:  %s\n", temp_rule->true_branch->state);
302        }        }
       /*if(temp_rule->true_branch && temp_rule->false_branch){*/  
       /*}*/  
303        if(temp_rule->false_branch){        if(temp_rule->false_branch){
304          eef_log(LOG_DEBUG, "   False branch: %s\n", temp_rule->false_branch->state);          eef_log(LOG_DEBUG, "   False branch: %s\n", temp_rule->false_branch->state);
305        }        }
# Line 310  void print_policies(policy_t* policies){ Line 308  void print_policies(policy_t* policies){
308      }      }
309      temp_policy = temp_policy->next;      temp_policy = temp_policy->next;
310    }    }
311      return;
312  }  }
313    
314    /* tries to link all policy rules to a plugin in the plugin manager */
315  EES_RC link_rules_to_plugins(policy_t* policies){  EES_RC link_rules_to_plugins(policy_t* policies){
316    policy_t *temp_policy = policies;    policy_t *temp_policy = policies;
317    rule_t   *temp_rule   = NULL;    rule_t   *temp_rule   = NULL;
# Line 326  EES_RC link_rules_to_plugins(policy_t* p Line 326  EES_RC link_rules_to_plugins(policy_t* p
326      }      }
327      temp_policy = temp_policy->next;      temp_policy = temp_policy->next;
328    }    }
329      return EES_SUCCESS;
330    }
331    
332    /* iterates the policies and removes those that are not explicitly named in the passed array of strings */
333    policy_t* reduce_policy_tree(policy_t* policies, int number_of_policies, char* names_of_policies[]){
334      int i, policy_should_be_removed;
335      policy_t *temp_policy = policies;
336      while(temp_policy){
337        policy_should_be_removed = 1;
338        printf("Checking policy: %s\n", temp_policy->name);
339        for(i = 0; i < number_of_policies; i++){
340          if(strcmp(temp_policy->name, names_of_policies[i]) == 0){
341            /* if the policy is in the named list, we can continue to the next plugin */
342            printf("Allowed policy: %s\n", names_of_policies[i]);
343            policy_should_be_removed = 0;
344            break;
345          }
346        }
347    
348        if(policy_should_be_removed){
349          printf("Removing not-allowed policy: %s\n", temp_policy->name);
350          remove_policy_by_name(temp_policy->name);
351        }
352        /* Move to next policy */
353        temp_policy = temp_policy->next;
354      }
355      return policies;
356  }  }
357    
358  /*! concatenates two strings */  /*! concatenates two strings */
# Line 381  var_t* get_variable_by_name(char* name){ Line 408  var_t* get_variable_by_name(char* name){
408    return NULL;    return NULL;
409  }  }
410    
 /*TODO*/  
411  /*! Removes a policy from the list of policies */  /*! Removes a policy from the list of policies */
412  void remove_policy(record_t* policy){  void remove_policy(record_t* policy){
413      policy_t *temp_policy = policies_list, *next_policy = NULL;
414    eef_log(LOG_DEBUG, "Deleted policy: %s\n", policy->string);    eef_log(LOG_DEBUG, "Deleted policy: %s\n", policy->string);
415    
416      while(temp_policy){
417        if(strcmp(temp_policy->name, policy->string) == 0){
418          /* target policy was found */
419          next_policy = temp_policy->next;
420    
421          /* Clean policy fields */
422          clean_rules_list(temp_policy->rules);
423          free(temp_policy->name);
424          free(temp_policy);
425        }
426    
427        /* Move to next policy */
428        temp_policy = next_policy;
429      }
430    
431    free(policy->string);    free(policy->string);
432    free(policy);    free(policy);
433      return;
434    }
435    
436    /*! Removes a policy from the list of policies */
437    void remove_policy_by_name(char* policy){
438      policy_t *temp_policy = policies_list, *next_policy = NULL;
439      eef_log(LOG_DEBUG, "Deleted policy: %s\n", policy);
440    
441      while(temp_policy){
442        if(strcmp(temp_policy->name, policy) == 0){
443          /* target policy was found */
444          next_policy = temp_policy->next;
445    
446          /* Clean policy fields */
447          clean_rules_list(temp_policy->rules);
448          free(temp_policy->name);
449          free(temp_policy);
450        }
451    
452        /* Move to next policy */
453        temp_policy = next_policy;
454      }
455      return;
456  }  }
457    
458  /*! converts a string to an array of strings by splitting it at each \t delimiter  /*! converts a string to an array of strings by splitting it at each \t delimiter
# Line 540  EES_RC pdl_term(){ Line 606  EES_RC pdl_term(){
606    
607  /*! TODO */  /*! TODO */
608  EES_RC allow_rules(int val){  EES_RC allow_rules(int val){
609    /*printf("Allowed rules: %i\n", val);*/    /*printf("Allowed rule: %i\n", val);*/
610    return EES_SUCCESS;    return EES_SUCCESS;
611  }  }
612    

Legend:
Removed from v.1157  
changed lines
  Added in v.1158

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