876 |
|
|
877 |
|
|
878 |
/** |
/** |
879 |
* Returns TRUE if the checksum was changed for any associated |
* Returns TRUE if the checksum was changed for associated |
880 |
* programs and send an alert warning. Also make sure that the program |
* path and send an alert warning. Also make sure that the service |
881 |
* will not be validated, started or restarted again in this |
* will not be validated, started or restarted again in this |
882 |
* session. Returns FALSE if the checksum is the same or not defined |
* session. Returns FALSE if the checksum is the same or not defined |
883 |
* for this service. |
* for this service. |
884 |
*/ |
*/ |
885 |
static int check_checksum(Service_T s) { |
static int check_checksum(Service_T s) { |
886 |
|
|
|
Checksum_T c; |
|
|
|
|
887 |
ASSERT(s); |
ASSERT(s); |
888 |
|
|
889 |
if(!s->def_checksum) { |
if(!s->md5) { |
890 |
return FALSE; |
return FALSE; |
891 |
} |
} |
892 |
|
|
893 |
for(c= s->checksumlist; c; c= c->next) { |
if( !check_md5(s->path, s->md5) ) { |
894 |
if(c->file && c->md5 && !check_md5(c->file, c->md5)) { |
Event_post(s, EVENT_CHECKSUM, "'%s' CHECKSUM ERROR for %s\n", |
895 |
Event_post(s, EVENT_CHECKSUM, "'%s' CHECKSUM ERROR for %s\n", |
s->name, s->path); |
896 |
s->name, c->file); |
return TRUE; |
|
return TRUE; |
|
|
} |
|
897 |
} |
} |
898 |
|
|
899 |
DEBUG("'%s' has valid checksums\n", s->name); |
DEBUG("'%s' has valid checksums\n", s->name); |
919 |
return FALSE; |
return FALSE; |
920 |
} |
} |
921 |
|
|
922 |
if(!(timestamp= get_timestamp(t->pathname, S_IFDIR|S_IFREG))) { |
if(!(timestamp= get_timestamp(s->path, S_IFDIR|S_IFREG))) { |
923 |
snprintf(report, STRLEN, "can't get timestamp for %s", t->pathname); |
snprintf(report, STRLEN, "can't get timestamp for %s", s->path); |
924 |
return FALSE; |
return FALSE; |
925 |
} |
} |
926 |
|
|
927 |
if(t->test_changes) { |
if(t->test_changes) { |
928 |
if(t->timestamp != timestamp) { |
if(t->timestamp != timestamp) { |
929 |
snprintf(report, STRLEN, "timestamp was changed for %s", t->pathname); |
snprintf(report, STRLEN, "timestamp was changed for %s", s->path); |
930 |
/* Set the old timestamp to the new value so we do not report |
/* Set the old timestamp to the new value so we do not report |
931 |
* this more than once per change */ |
* this more than once per change */ |
932 |
t->timestamp= timestamp; |
t->timestamp= timestamp; |
934 |
} |
} |
935 |
} else { |
} else { |
936 |
if(compare_value(t->operator, (int)(now - timestamp), t->time)) { |
if(compare_value(t->operator, (int)(now - timestamp), t->time)) { |
937 |
snprintf(report, STRLEN, "timestamp test failed for %s", t->pathname); |
snprintf(report, STRLEN, "timestamp test failed for %s", s->path); |
938 |
return FALSE; |
return FALSE; |
939 |
} |
} |
940 |
} |
} |
941 |
|
|
942 |
DEBUG("'%s' timestamp test passed for %s\n", s->name, t->pathname); |
DEBUG("'%s' timestamp test passed for %s\n", s->name, s->path); |
943 |
|
|
944 |
return TRUE; |
return TRUE; |
945 |
|
|