void gc_mail_list(Mail_T *m) { ASSERT(m); if((*m)->next) gc_mail_list(&(*m)->next); FREE((*m)->to); FREE((*m)->from); FREE((*m)->replyto); FREE((*m)->subject); FREE((*m)->message); FREE(*m); }
void gc() { destroy_hosts_allow(); gc_protocols(); if(Run.doprocess) { delprocesstree(&oldptree, oldptreesize); delprocesstree(&ptree, ptreesize); } if(servicelist) _gc_service_list(&servicelist); if(servicegrouplist) _gc_servicegroup(&servicegrouplist); if(Run.credentials) _gcath(&Run.credentials); if(Run.maillist) gc_mail_list(&Run.maillist); if(Run.mailservers) _gc_mail_server(&Run.mailservers); if(Run.mmonits) _gc_mmonit(&Run.mmonits); if(Run.eventlist) gc_event(&Run.eventlist); FREE(Run.eventlist_dir); FREE(Run.mygroup); FREE(Run.localhostname); FREE(Run.httpsslpem); FREE(Run.httpsslclientpem); FREE(Run.bind_addr); FREE(Run.MailFormat.from); FREE(Run.MailFormat.subject); FREE(Run.MailFormat.message); FREE(Run.mail_hostname); }
/** * Notify registred users about the event * @param E An Event object * @return If failed, return HANDLER_ALERT flag or HANDLER_SUCCEEDED if succeeded */ int handle_alert(Event_T E) { Service_T s; int rv = HANDLER_SUCCEEDED; ASSERT(E); s= Event_get_source(E); if(!s) { LogError("Aborting alert\n"); return rv; } if(s->maillist || Run.maillist) { Mail_T m; Mail_T n; Mail_T list= NULL; /* * Build a mail-list with local recipients that has registered interest * for this event. */ for(m= s->maillist; m; m= m->next) { if( /* particular event notification type is allowed for given recipient */ IS_EVENT_SET(m->events, Event_get_id(E)) && ( /* state change notification is sent always */ E->state_changed || /* in the case that the state is failed for more cycles we check * whether we should send the reminder */ (E->state && m->reminder && E->count % m->reminder == 0) ) ) { Mail_T tmp= NULL; NEW(tmp); copy_mail(tmp, m); substitute(&tmp, E); replace_bare_linefeed(&tmp); tmp->next= list; list= tmp; DEBUG("%s notification is sent to %s\n", Event_get_description(E), m->to); } } /* * Build a mail-list with global recipients that has registered interest * for this event. Recipients which are defined in the service localy * overrides the same recipient events which are registered globaly. */ for(m= Run.maillist; m; m= m->next) { int skip= FALSE; for(n= s->maillist; n; n= n->next) { if(IS(m->to, n->to)) { skip= TRUE; break; } } if( /* the local service alert definition has not overrided the global one */ !skip && /* particular event notification type is allowed for given recipient */ IS_EVENT_SET(m->events, Event_get_id(E)) && ( /* state change notification is sent always */ E->state_changed || /* in the case that the state is failed for more cycles we check * whether we should send the reminder */ (E->state && m->reminder && E->count % m->reminder == 0) ) ) { Mail_T tmp= NULL; NEW(tmp); copy_mail(tmp, m); substitute(&tmp, E); replace_bare_linefeed(&tmp); tmp->next= list; list= tmp; DEBUG("%s notification is sent to %s\n", Event_get_description(E), m->to); } } if(list) { if(!sendmail(list)) rv = HANDLER_ALERT; gc_mail_list(&list); } } return rv; }
static void _gc_service(Service_T *s) { ASSERT(s&&*s); if((*s)->portlist) _gcppl(&(*s)->portlist); if((*s)->filesystemlist) _gcfilesystem(&(*s)->filesystemlist); if((*s)->icmplist) _gcicmp(&(*s)->icmplist); if((*s)->maillist) gc_mail_list(&(*s)->maillist); if((*s)->resourcelist) _gcpql(&(*s)->resourcelist); if((*s)->inf) _gc_inf(&(*s)->inf); if((*s)->timestamplist) _gcptl(&(*s)->timestamplist); if((*s)->actionratelist) _gcparl(&(*s)->actionratelist); if((*s)->sizelist) _gcso(&(*s)->sizelist); if((*s)->matchlist) _gcmatch(&(*s)->matchlist); if((*s)->checksum) _gcchecksum(&(*s)->checksum); if((*s)->perm) _gcperm(&(*s)->perm); if((*s)->uid) _gcuid(&(*s)->uid); if((*s)->gid) _gcgid(&(*s)->gid); if((*s)->dependantlist) _gcpdl(&(*s)->dependantlist); if((*s)->start) gccmd(&(*s)->start); if((*s)->stop) gccmd(&(*s)->stop); if((*s)->action_DATA) _gc_eventaction(&(*s)->action_DATA); if((*s)->action_EXEC) _gc_eventaction(&(*s)->action_EXEC); if((*s)->action_INVALID) _gc_eventaction(&(*s)->action_INVALID); if((*s)->action_NONEXIST) _gc_eventaction(&(*s)->action_NONEXIST); if((*s)->action_PID) _gc_eventaction(&(*s)->action_PID); if((*s)->action_PPID) _gc_eventaction(&(*s)->action_PPID); if((*s)->action_FSFLAG) _gc_eventaction(&(*s)->action_FSFLAG); if((*s)->action_MONIT_START) _gc_eventaction(&(*s)->action_MONIT_START); if((*s)->action_MONIT_STOP) _gc_eventaction(&(*s)->action_MONIT_STOP); if((*s)->action_MONIT_RELOAD) _gc_eventaction(&(*s)->action_MONIT_RELOAD); if((*s)->action_ACTION) _gc_eventaction(&(*s)->action_ACTION); if((*s)->eventlist) gc_event(&(*s)->eventlist); FREE((*s)->name); FREE((*s)->path); (*s)->next= NULL; FREE(*s); }
static void _gc_service(Service_T *s) { ASSERT(s&&*s); if ((*s)->program) { if ((*s)->program->P) Process_free(&(*s)->program->P); if ((*s)->program->C) Command_free(&(*s)->program->C); if ((*s)->program->args) gccmd(&(*s)->program->args); StringBuffer_free(&((*s)->program->output)); FREE((*s)->program); } if((*s)->portlist) _gcppl(&(*s)->portlist); if((*s)->filesystemlist) _gcfilesystem(&(*s)->filesystemlist); if((*s)->icmplist) _gcicmp(&(*s)->icmplist); if((*s)->maillist) gc_mail_list(&(*s)->maillist); if((*s)->resourcelist) _gcpql(&(*s)->resourcelist); if((*s)->inf) _gc_inf(&(*s)->inf); if((*s)->timestamplist) _gcptl(&(*s)->timestamplist); if((*s)->actionratelist) _gcparl(&(*s)->actionratelist); if((*s)->sizelist) _gcso(&(*s)->sizelist); if((*s)->matchlist) _gcmatch(&(*s)->matchlist); if((*s)->matchignorelist) _gcmatch(&(*s)->matchignorelist); if((*s)->checksum) _gcchecksum(&(*s)->checksum); if((*s)->perm) _gcperm(&(*s)->perm); if ((*s)->statuslist) _gcstatus(&(*s)->statuslist); if ((*s)->every.type == EVERY_CRON || (*s)->every.type == EVERY_NOTINCRON) FREE((*s)->every.spec.cron); if((*s)->uid) _gcuid(&(*s)->uid); if((*s)->euid) _gcuid(&(*s)->euid); if((*s)->gid) _gcgid(&(*s)->gid); if((*s)->pidlist) _gcpid(&(*s)->pidlist); if((*s)->ppidlist) _gcppid(&(*s)->ppidlist); if((*s)->dependantlist) _gcpdl(&(*s)->dependantlist); if((*s)->start) gccmd(&(*s)->start); if((*s)->stop) gccmd(&(*s)->stop); if((*s)->action_DATA) _gc_eventaction(&(*s)->action_DATA); if((*s)->action_EXEC) _gc_eventaction(&(*s)->action_EXEC); if((*s)->action_INVALID) _gc_eventaction(&(*s)->action_INVALID); if((*s)->action_NONEXIST) _gc_eventaction(&(*s)->action_NONEXIST); if((*s)->action_FSFLAG) _gc_eventaction(&(*s)->action_FSFLAG); if((*s)->action_MONIT_START) _gc_eventaction(&(*s)->action_MONIT_START); if((*s)->action_MONIT_STOP) _gc_eventaction(&(*s)->action_MONIT_STOP); if((*s)->action_MONIT_RELOAD) _gc_eventaction(&(*s)->action_MONIT_RELOAD); if((*s)->action_ACTION) _gc_eventaction(&(*s)->action_ACTION); if((*s)->eventlist) gc_event(&(*s)->eventlist); FREE((*s)->name); FREE((*s)->path); (*s)->next = NULL; FREE(*s); }