Ticket #176: filter.patch

File filter.patch, 1.8 KB (added by maxbritov, 7 months ago)

add logit="yes" into filter rules, but it have True even for logit="false"

  • .c

    old new  
    4545    char *buf; 
    4646    nad_cache_t cache; 
    4747    nad_t nad; 
    48     int i, nfilters, filter, from, to, what, error; 
     48    int i, nfilters, filter, from, to, what, error, logit; 
    4949    acl_t list_tail, acl; 
    5050 
    5151    log_debug(ZONE, "loading filter"); 
     
    102102        to = nad_find_attr(nad, filter, -1, "to", NULL); 
    103103        what = nad_find_attr(nad, filter, -1, "what", NULL); 
    104104        error = nad_find_attr(nad, filter, -1, "error", NULL); 
     105        logit = nad_find_attr(nad, filter, -1, "logit", NULL); 
    105106 
    106107        acl = (acl_t) calloc(1, sizeof(struct acl_s)); 
    107108 
     
    138139                } 
    139140            } 
    140141        } 
     142        if(logit > 0) acl->logit = 1; 
    141143 
    142144        if(list_tail != NULL) { 
    143145           list_tail->next = acl; 
     
    150152           list_tail = acl; 
    151153        } 
    152154         
    153         log_debug(ZONE, "added %s rule: from=%s, to=%s, what=%s, error=%d", (acl->error?"deny":"allow"), acl->from, acl->to, acl->what, acl->error); 
     155        log_debug(ZONE, "added %s rule: from=%s, to=%s, what=%s, error=%d, logit=%s", (acl->error?"deny":"allow"), acl->from, acl->to, acl->what, acl->error, (acl->logit?"yes":"no")); 
    154156 
    155157        nfilters++; 
    156158 
     
    196198        if( to != NULL && acl->to != NULL && fnmatch(acl->to, to, 0) != 0 ) continue; 
    197199        if( acl->what != NULL && nad_find_elem_path(nad, 0, -1, acl->what) < 0 ) continue;      /* match packet type */ 
    198200        log_debug(ZONE, "matched packet %s->%s vs rule (%s %s->%s)", from, to, acl->what, acl->from, acl->to); 
     201        if (acl->logit) log_write(r->log, LOG_NOTICE, "filter: %s packet from=%s to=%s vs rule (from=%s to=%s what=%s)",(acl->error?"deny":"allow"), from, to, acl->from, acl->to, acl->what); 
    199202        error = acl->error; 
    200203        break; 
    201204    }