107 |
|
|
108 |
static int check_timeout(Service_T); |
static int check_timeout(Service_T); |
109 |
|
|
110 |
static int check_checksum(Service_T); |
static int check_checksum(Service_T, char *); |
111 |
static int check_perm(Service_T, mode_t); |
static int check_perm(Service_T, mode_t, char *); |
112 |
static int check_uid(Service_T, uid_t); |
static int check_uid(Service_T, uid_t, char *); |
113 |
static int check_gid(Service_T, gid_t); |
static int check_gid(Service_T, gid_t, char *); |
114 |
|
|
115 |
static void do_validate(Service_T, ProcessTree_T *, int); |
static void do_validate(Service_T, ProcessTree_T *, int); |
116 |
static int do_not_validate(Service_T); |
static int do_not_validate(Service_T); |
322 |
return FALSE; |
return FALSE; |
323 |
} |
} |
324 |
|
|
325 |
if(check_perm(s, stat_buf.st_mode)) { |
if(check_perm(s, stat_buf.st_mode, report)) { |
326 |
s->perm->event_flag= TRUE; |
s->perm->event_flag= TRUE; |
327 |
if(! eval_actions(s->perm->action, s, report, "permission", |
if(! eval_actions(s->perm->action, s, report, "permission", |
328 |
EVENT_PERMISSION)) |
EVENT_PERMISSION)) |
329 |
return FALSE; |
return FALSE; |
330 |
} |
} |
331 |
|
|
332 |
if(check_uid(s, stat_buf.st_uid)) { |
if(check_uid(s, stat_buf.st_uid, report)) { |
333 |
s->uid->event_flag= TRUE; |
s->uid->event_flag= TRUE; |
334 |
if(! eval_actions(s->uid->action, s, report, "uid", EVENT_UID)) |
if(! eval_actions(s->uid->action, s, report, "uid", EVENT_UID)) |
335 |
return FALSE; |
return FALSE; |
336 |
} |
} |
337 |
|
|
338 |
if(check_gid(s, stat_buf.st_gid)) { |
if(check_gid(s, stat_buf.st_gid, report)) { |
339 |
s->gid->event_flag= TRUE; |
s->gid->event_flag= TRUE; |
340 |
if(! eval_actions(s->gid->action, s, report, "gid", EVENT_GID)) |
if(! eval_actions(s->gid->action, s, report, "gid", EVENT_GID)) |
341 |
return FALSE; |
return FALSE; |
366 |
return FALSE; |
return FALSE; |
367 |
} |
} |
368 |
|
|
369 |
if(check_checksum(s)) { |
if(check_checksum(s, report)) { |
370 |
s->checksum->event_flag= TRUE; |
s->checksum->event_flag= TRUE; |
371 |
if(! eval_actions(s->checksum->action, s, report, "checksum", |
if(! eval_actions(s->checksum->action, s, report, "checksum", |
372 |
EVENT_CHECKSUM)) |
EVENT_CHECKSUM)) |
373 |
return FALSE; |
return FALSE; |
374 |
} |
} |
375 |
|
|
376 |
if(check_perm(s, stat_buf.st_mode)) { |
if(check_perm(s, stat_buf.st_mode, report)) { |
377 |
s->perm->event_flag= TRUE; |
s->perm->event_flag= TRUE; |
378 |
if(! eval_actions(s->perm->action, s, report, "permission", |
if(! eval_actions(s->perm->action, s, report, "permission", |
379 |
EVENT_PERMISSION)) |
EVENT_PERMISSION)) |
380 |
return FALSE; |
return FALSE; |
381 |
} |
} |
382 |
|
|
383 |
if(check_uid(s, stat_buf.st_uid)) { |
if(check_uid(s, stat_buf.st_uid, report)) { |
384 |
s->uid->event_flag= TRUE; |
s->uid->event_flag= TRUE; |
385 |
if(! eval_actions(s->uid->action, s, report, "uid", EVENT_UID)) |
if(! eval_actions(s->uid->action, s, report, "uid", EVENT_UID)) |
386 |
return FALSE; |
return FALSE; |
387 |
} |
} |
388 |
|
|
389 |
if(check_gid(s, stat_buf.st_gid)) { |
if(check_gid(s, stat_buf.st_gid, report)) { |
390 |
s->gid->event_flag= TRUE; |
s->gid->event_flag= TRUE; |
391 |
if(! eval_actions(s->gid->action, s, report, "gid", EVENT_GID)) |
if(! eval_actions(s->gid->action, s, report, "gid", EVENT_GID)) |
392 |
return FALSE; |
return FALSE; |
423 |
return FALSE; |
return FALSE; |
424 |
} |
} |
425 |
|
|
426 |
if(check_perm(s, stat_buf.st_mode)) { |
if(check_perm(s, stat_buf.st_mode, report)) { |
427 |
s->perm->event_flag= TRUE; |
s->perm->event_flag= TRUE; |
428 |
if(! eval_actions(s->perm->action, s, report, "permission", |
if(! eval_actions(s->perm->action, s, report, "permission", |
429 |
EVENT_PERMISSION)) |
EVENT_PERMISSION)) |
430 |
return FALSE; |
return FALSE; |
431 |
} |
} |
432 |
|
|
433 |
if(check_uid(s, stat_buf.st_uid)) { |
if(check_uid(s, stat_buf.st_uid, report)) { |
434 |
s->uid->event_flag= TRUE; |
s->uid->event_flag= TRUE; |
435 |
if(! eval_actions(s->uid->action, s, report, "uid", EVENT_UID)) |
if(! eval_actions(s->uid->action, s, report, "uid", EVENT_UID)) |
436 |
return FALSE; |
return FALSE; |
437 |
} |
} |
438 |
|
|
439 |
if(check_gid(s, stat_buf.st_gid)) { |
if(check_gid(s, stat_buf.st_gid, report)) { |
440 |
s->gid->event_flag= TRUE; |
s->gid->event_flag= TRUE; |
441 |
if(! eval_actions(s->gid->action, s, report, "gid", EVENT_GID)) |
if(! eval_actions(s->gid->action, s, report, "gid", EVENT_GID)) |
442 |
return FALSE; |
return FALSE; |
844 |
* Returns FALSE if the checksum is the same or not defined |
* Returns FALSE if the checksum is the same or not defined |
845 |
* for this service. |
* for this service. |
846 |
*/ |
*/ |
847 |
static int check_checksum(Service_T s) { |
static int check_checksum(Service_T s, char *report) { |
848 |
|
|
849 |
ASSERT(s); |
ASSERT(s); |
850 |
|
|
852 |
return FALSE; |
return FALSE; |
853 |
|
|
854 |
if( !check_md5(s->path, s->checksum->md5) ) { |
if( !check_md5(s->path, s->checksum->md5) ) { |
855 |
|
snprintf(report, STRLEN, "checksum test failed for %s", s->path); |
856 |
return TRUE; |
return TRUE; |
857 |
} |
} |
858 |
|
|
869 |
* Returns FALSE if the permission is the same or not defined |
* Returns FALSE if the permission is the same or not defined |
870 |
* for this service. |
* for this service. |
871 |
*/ |
*/ |
872 |
static int check_perm(Service_T s, mode_t mode) { |
static int check_perm(Service_T s, mode_t mode, char *report) { |
873 |
|
|
874 |
ASSERT(s); |
ASSERT(s); |
875 |
|
|
877 |
return FALSE; |
return FALSE; |
878 |
|
|
879 |
if( (mode & 07777) != s->perm->perm ) { |
if( (mode & 07777) != s->perm->perm ) { |
880 |
|
snprintf(report, STRLEN, |
881 |
|
"permission test failed for %s -- current permission is %o", |
882 |
|
s->path, mode&07777); |
883 |
return TRUE; |
return TRUE; |
884 |
} |
} |
885 |
|
|
897 |
* Returns FALSE if the uid is the same or not defined |
* Returns FALSE if the uid is the same or not defined |
898 |
* for this service. |
* for this service. |
899 |
*/ |
*/ |
900 |
static int check_uid(Service_T s, uid_t uid) { |
static int check_uid(Service_T s, uid_t uid, char *report) { |
901 |
|
|
902 |
ASSERT(s); |
ASSERT(s); |
903 |
|
|
905 |
return FALSE; |
return FALSE; |
906 |
|
|
907 |
if( uid != s->uid->uid ) { |
if( uid != s->uid->uid ) { |
908 |
|
snprintf(report, STRLEN, |
909 |
|
"uid test failed for %s -- current uid is %d", |
910 |
|
s->path, (int)uid); |
911 |
return TRUE; |
return TRUE; |
912 |
} |
} |
913 |
|
|
925 |
* Returns FALSE if the gid is the same or not defined |
* Returns FALSE if the gid is the same or not defined |
926 |
* for this service. |
* for this service. |
927 |
*/ |
*/ |
928 |
static int check_gid(Service_T s, gid_t gid) { |
static int check_gid(Service_T s, gid_t gid, char *report) { |
929 |
|
|
930 |
ASSERT(s); |
ASSERT(s); |
931 |
|
|
933 |
return FALSE; |
return FALSE; |
934 |
|
|
935 |
if( gid != s->gid->gid ) { |
if( gid != s->gid->gid ) { |
936 |
|
snprintf(report, STRLEN, |
937 |
|
"gid test failed for %s -- current gid is %d", |
938 |
|
s->path, (int)gid); |
939 |
return TRUE; |
return TRUE; |
940 |
} |
} |
941 |
|
|