83 |
static int check_timestamps(Service_T); |
static int check_timestamps(Service_T); |
84 |
static int check_timestamp_item(Service_T, Timestamp_T, char *); |
static int check_timestamp_item(Service_T, Timestamp_T, char *); |
85 |
|
|
86 |
|
static int check_size_item(Service_T, Size_T, unsigned long, char *); |
87 |
|
|
88 |
static int check_timeout(Service_T); |
static int check_timeout(Service_T); |
89 |
|
|
90 |
static int check_checksum(Service_T); |
static int check_checksum(Service_T); |
336 |
*/ |
*/ |
337 |
static int check_file(Service_T s) { |
static int check_file(Service_T s) { |
338 |
|
|
339 |
|
Size_T sl; |
340 |
|
char report[STRLEN]; |
341 |
struct stat stat_buf; |
struct stat stat_buf; |
342 |
|
|
343 |
if(stat(s->path, &stat_buf) != 0) { |
if(stat(s->path, &stat_buf) != 0) { |
350 |
return FALSE; |
return FALSE; |
351 |
} |
} |
352 |
|
|
353 |
if( s->perm != -1 && (stat_buf.st_mode & 07777) != s->perm ) { |
if(s->perm != -1) { |
354 |
Event_post(s, EVENT_RESTART, |
if( (stat_buf.st_mode & 07777) != s->perm ) { |
355 |
"Event: '%s' permission test failed -- " |
Event_post(s, EVENT_RESTART, |
356 |
"current permission: %o\n", |
"Event: '%s' permission test failed -- " |
357 |
s->name, stat_buf.st_mode&07777); |
"current permission: %o\n", |
358 |
return FALSE; |
s->name, stat_buf.st_mode&07777); |
359 |
|
return FALSE; |
360 |
|
} |
361 |
|
DEBUG("'%s' file permission check passed [current permission=%o]\n", |
362 |
|
s->name, stat_buf.st_mode&07777); |
363 |
|
} |
364 |
|
|
365 |
|
for(sl= s->sizelist; sl; sl= sl->next) { |
366 |
|
if(!check_size_item(s, sl, (unsigned long)stat_buf.st_size, report)) { |
367 |
|
/* Turn on the object's event_flag to indicate that the size event |
368 |
|
* occured on this particular object */ |
369 |
|
sl->event_flag= TRUE; |
370 |
|
if(! eval_actions(sl->action, s, report, "size", EVENT_SIZE)) { |
371 |
|
return FALSE; |
372 |
|
} |
373 |
|
} |
374 |
} |
} |
|
|
|
|
DEBUG("'%s' file permission check passed [current permission=%o]\n", |
|
|
s->name, stat_buf.st_mode&07777); |
|
375 |
|
|
376 |
return TRUE; |
return TRUE; |
377 |
|
|
386 |
|
|
387 |
Device_T td; |
Device_T td; |
388 |
char report[STRLEN]; |
char report[STRLEN]; |
389 |
|
struct stat stat_buf; |
390 |
|
|
391 |
|
if(stat(s->path, &stat_buf) != 0) { |
392 |
|
Event_post(s, EVENT_RESTART, "Event: device '%s' doesn't exist\n", s->name); |
393 |
|
return FALSE; |
394 |
|
} |
395 |
|
|
396 |
|
if(s->perm != -1) { |
397 |
|
if( (stat_buf.st_mode & 07777) != s->perm ) { |
398 |
|
Event_post(s, EVENT_RESTART, |
399 |
|
"Event: '%s' permission test failed -- " |
400 |
|
"current permission: %o\n", |
401 |
|
s->name, stat_buf.st_mode&07777); |
402 |
|
return FALSE; |
403 |
|
} |
404 |
|
DEBUG("'%s' device permission check passed [current permission=%o]\n", |
405 |
|
s->name, stat_buf.st_mode&07777); |
406 |
|
} |
407 |
|
|
408 |
/* Test devices */ |
/* Test devices */ |
409 |
if(s->devicelist) { |
if(s->devicelist) { |
848 |
return FALSE; |
return FALSE; |
849 |
} |
} |
850 |
|
|
|
|
|
851 |
if(t->test_changes) { |
if(t->test_changes) { |
852 |
if(t->timestamp != timestamp) { |
if(t->timestamp != timestamp) { |
853 |
snprintf(report, STRLEN, "timestamp was changed for %s", t->pathname); |
snprintf(report, STRLEN, "timestamp was changed for %s", t->pathname); |
868 |
return TRUE; |
return TRUE; |
869 |
|
|
870 |
} |
} |
871 |
|
|
872 |
|
|
873 |
|
/** |
874 |
|
* Returns TRUE if the size test succeded, otherwise FALSE |
875 |
|
*/ |
876 |
|
static int check_size_item(Service_T s, Size_T sl, unsigned long size, char *report) { |
877 |
|
|
878 |
|
ASSERT(s); |
879 |
|
ASSERT(sl); |
880 |
|
|
881 |
|
if(sl->test_changes) { |
882 |
|
if(sl->runsize != size) { |
883 |
|
snprintf(report, STRLEN, "size was changed for %s", s->path); |
884 |
|
/* Set the old size to the new value so we do not report |
885 |
|
* this more than once per change */ |
886 |
|
sl->runsize= size; |
887 |
|
return FALSE; |
888 |
|
} |
889 |
|
} else { |
890 |
|
if(compare_value(sl->operator, size, sl->size)) { |
891 |
|
snprintf(report, STRLEN, |
892 |
|
"size test failed for %s -- current size is %lu B", |
893 |
|
s->path, size); |
894 |
|
return FALSE; |
895 |
|
} |
896 |
|
} |
897 |
|
|
898 |
|
DEBUG("'%s' file size check passed [current size=%lu B]\n", |
899 |
|
s->name, size); |
900 |
|
|
901 |
|
return TRUE; |
902 |
|
|
903 |
|
} |
904 |
|
|
905 |
|
|
906 |
/** |
/** |