326 |
|
|
327 |
struct stat stat_buf; |
struct stat stat_buf; |
328 |
char report[STRLEN]= {0}; |
char report[STRLEN]= {0}; |
|
static int directory_test_stat_handled= FALSE; |
|
|
static int directory_test_type_handled= FALSE; |
|
329 |
|
|
330 |
if(stat(s->path, &stat_buf) != 0) { |
if(stat(s->path, &stat_buf) != 0) { |
331 |
if(!directory_test_stat_handled) { |
if(! s->event_handled) { |
332 |
Event_post(s, EVENT_START, |
Event_post(s, EVENT_START, |
333 |
"Event: directory '%s' doesn't exist\n", s->name); |
"Event: directory '%s' doesn't exist\n", s->name); |
334 |
directory_test_stat_handled= TRUE; |
s->event_handled= TRUE; |
335 |
} |
} |
336 |
return FALSE; |
return FALSE; |
337 |
} else { |
} else { |
338 |
directory_test_stat_handled= FALSE; |
s->event_handled= FALSE; |
339 |
} |
} |
340 |
|
|
341 |
if(!S_ISDIR(stat_buf.st_mode)) { |
if(!S_ISDIR(stat_buf.st_mode)) { |
342 |
if(!directory_test_type_handled) { |
if(!s->event_handled) { |
343 |
Event_post(s, EVENT_UNMONITOR, |
Event_post(s, EVENT_UNMONITOR, |
344 |
"Event: '%s' is not directory\n", s->name); |
"Event: '%s' is not directory\n", s->name); |
345 |
directory_test_type_handled= TRUE; |
s->event_handled= TRUE; |
346 |
} |
} |
347 |
return FALSE; |
return FALSE; |
348 |
} else { |
} else { |
349 |
directory_test_type_handled= FALSE; |
s->event_handled= FALSE; |
350 |
} |
} |
351 |
|
|
352 |
if(check_perm(s, stat_buf.st_mode, report)) { |
if(check_perm(s, stat_buf.st_mode, report)) { |
353 |
s->perm->event_flag= TRUE; |
s->perm->event_flag= TRUE; |
354 |
if(! eval_actions(s->perm->action, s, report, "permission", |
if(! eval_actions(s->perm->action, s, report, "permission", |
355 |
EVENT_PERMISSION)) |
EVENT_PERMISSION)) |
356 |
return FALSE; |
return FALSE; |
357 |
} |
} |
358 |
|
|
359 |
if(check_uid(s, stat_buf.st_uid, report)) { |
if(check_uid(s, stat_buf.st_uid, report)) { |
360 |
s->uid->event_flag= TRUE; |
s->uid->event_flag= TRUE; |
361 |
if(! eval_actions(s->uid->action, s, report, "uid", EVENT_UID)) |
if(! eval_actions(s->uid->action, s, report, "uid", EVENT_UID)) |
362 |
return FALSE; |
return FALSE; |
363 |
} |
} |
364 |
|
|
365 |
if(check_gid(s, stat_buf.st_gid, report)) { |
if(check_gid(s, stat_buf.st_gid, report)) { |
366 |
s->gid->event_flag= TRUE; |
s->gid->event_flag= TRUE; |
367 |
if(! eval_actions(s->gid->action, s, report, "gid", EVENT_GID)) |
if(! eval_actions(s->gid->action, s, report, "gid", EVENT_GID)) |
368 |
return FALSE; |
return FALSE; |
369 |
} |
} |
370 |
|
|
371 |
return TRUE; |
return TRUE; |
372 |
|
|
382 |
Size_T sl; |
Size_T sl; |
383 |
struct stat stat_buf; |
struct stat stat_buf; |
384 |
char report[STRLEN]= {0}; |
char report[STRLEN]= {0}; |
|
static int file_test_stat_handled= FALSE; |
|
|
static int file_test_type_handled= FALSE; |
|
385 |
|
|
386 |
if(stat(s->path, &stat_buf) != 0) { |
if(stat(s->path, &stat_buf) != 0) { |
387 |
if(! file_test_stat_handled) { |
if(! s->event_handled) { |
388 |
Event_post(s, EVENT_START, "Event: file '%s' doesn't exist\n", s->name); |
Event_post(s, EVENT_START, "Event: file '%s' doesn't exist\n", s->name); |
389 |
file_test_stat_handled= TRUE; |
s->event_handled= TRUE; |
390 |
} |
} |
391 |
return FALSE; |
return FALSE; |
392 |
} else { |
} else { |
393 |
file_test_stat_handled= FALSE; |
s->event_handled= TRUE; |
394 |
} |
} |
395 |
|
|
396 |
if(!S_ISREG(stat_buf.st_mode)) { |
if(!S_ISREG(stat_buf.st_mode)) { |
397 |
if(! file_test_type_handled) { |
if(! s->event_handled) { |
398 |
Event_post(s, EVENT_UNMONITOR, |
Event_post(s, EVENT_UNMONITOR, |
399 |
"Event: '%s' is not regular file\n", s->name); |
"Event: '%s' is not regular file\n", s->name); |
400 |
file_test_type_handled= TRUE; |
s->event_handled= TRUE; |
401 |
} |
} |
402 |
return FALSE; |
return FALSE; |
403 |
} else { |
} else { |
404 |
file_test_type_handled= FALSE; |
s->event_handled= FALSE; |
405 |
} |
} |
406 |
|
|
407 |
if(check_checksum(s, report)) { |
if(check_checksum(s, report)) { |
408 |
s->checksum->event_flag= TRUE; |
s->checksum->event_flag= TRUE; |
409 |
if(! eval_actions(s->checksum->action, s, report, "checksum", |
if(! eval_actions(s->checksum->action, s, report, "checksum", |
410 |
EVENT_CHECKSUM)) |
EVENT_CHECKSUM)) |
411 |
return FALSE; |
return FALSE; |
412 |
} |
} |
413 |
|
|
414 |
if(check_perm(s, stat_buf.st_mode, report)) { |
if(check_perm(s, stat_buf.st_mode, report)) { |
415 |
s->perm->event_flag= TRUE; |
s->perm->event_flag= TRUE; |
416 |
if(! eval_actions(s->perm->action, s, report, "permission", |
if(! eval_actions(s->perm->action, s, report, "permission", |
417 |
EVENT_PERMISSION)) |
EVENT_PERMISSION)) |
418 |
return FALSE; |
return FALSE; |
419 |
} |
} |
420 |
|
|
421 |
if(check_uid(s, stat_buf.st_uid, report)) { |
if(check_uid(s, stat_buf.st_uid, report)) { |
422 |
s->uid->event_flag= TRUE; |
s->uid->event_flag= TRUE; |
423 |
if(! eval_actions(s->uid->action, s, report, "uid", EVENT_UID)) |
if(! eval_actions(s->uid->action, s, report, "uid", EVENT_UID)) |
424 |
return FALSE; |
return FALSE; |
425 |
} |
} |
426 |
|
|
427 |
if(check_gid(s, stat_buf.st_gid, report)) { |
if(check_gid(s, stat_buf.st_gid, report)) { |
428 |
s->gid->event_flag= TRUE; |
s->gid->event_flag= TRUE; |
429 |
if(! eval_actions(s->gid->action, s, report, "gid", EVENT_GID)) |
if(! eval_actions(s->gid->action, s, report, "gid", EVENT_GID)) |
430 |
return FALSE; |
return FALSE; |
431 |
} |
} |
432 |
|
|
433 |
for(sl= s->sizelist; sl; sl= sl->next) { |
for(sl= s->sizelist; sl; sl= sl->next) { |
465 |
Device_T td; |
Device_T td; |
466 |
struct stat stat_buf; |
struct stat stat_buf; |
467 |
char report[STRLEN]= {0}; |
char report[STRLEN]= {0}; |
|
static int device_test_stat_handled= FALSE; |
|
|
static int device_test_read_handled= FALSE; |
|
468 |
|
|
469 |
if(stat(s->path, &stat_buf) != 0) { |
if(stat(s->path, &stat_buf) != 0) { |
470 |
if(!device_test_stat_handled) { |
if(! s->event_handled) { |
471 |
Event_post(s, EVENT_START, "Event: device '%s' doesn't exist\n", s->name); |
Event_post(s, EVENT_START, "Event: device '%s' doesn't exist\n", s->name); |
472 |
device_test_stat_handled= TRUE; |
s->event_handled= TRUE; |
473 |
} |
} |
474 |
return FALSE; |
return FALSE; |
475 |
} else { |
} else { |
476 |
device_test_stat_handled= FALSE; |
s->event_handled= FALSE; |
477 |
} |
} |
478 |
|
|
479 |
if(check_perm(s, stat_buf.st_mode, report)) { |
if(check_perm(s, stat_buf.st_mode, report)) { |
496 |
} |
} |
497 |
|
|
498 |
if(!DeviceInfo_Usage(s->devinfo, s->path)) { |
if(!DeviceInfo_Usage(s->devinfo, s->path)) { |
499 |
if(! device_test_read_handled) { |
if(! s->devinfo->event_handled) { |
500 |
Event_post(s, EVENT_START, |
Event_post(s, EVENT_START, |
501 |
"Event: unable to read device '%s' state\n", |
"Event: unable to read device '%s' state\n", |
502 |
s->path); |
s->path); |
503 |
device_test_read_handled= TRUE; |
s->devinfo->event_handled= TRUE; |
504 |
} |
} |
505 |
return FALSE; |
return FALSE; |
506 |
} else { |
} else { |
507 |
device_test_read_handled= FALSE; |
s->devinfo->event_handled= FALSE; |
508 |
DEBUG("'%s' succeeded getting device statistic for %s\n", s->name, s->path); |
DEBUG("'%s' succeeded getting device statistic for %s\n", s->name, s->path); |
509 |
} |
} |
510 |
|
|