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); |
91 |
|
static int check_perm(Service_T, mode_t); |
92 |
|
static int check_uid(Service_T, uid_t); |
93 |
|
static int check_gid(Service_T, gid_t); |
94 |
|
|
95 |
static void do_validate(Service_T, ProcessTree_T *, int); |
static void do_validate(Service_T, ProcessTree_T *, int); |
96 |
static int do_not_validate(Service_T); |
static int do_not_validate(Service_T); |
317 |
return FALSE; |
return FALSE; |
318 |
} |
} |
319 |
|
|
320 |
if(s->perm) { |
if(check_perm(s, stat_buf.st_mode)) |
321 |
if( (stat_buf.st_mode & 07777) != s->perm->perm ) { |
return FALSE; |
|
Event_post(s, EVENT_PERMISSION, |
|
|
"Event: '%s' permission test failed -- " |
|
|
"current permission: %o\n", |
|
|
s->name, stat_buf.st_mode&07777); |
|
|
return FALSE; |
|
|
} |
|
|
DEBUG("'%s' directory permission check passed [current permission=%o]\n", |
|
|
s->name, stat_buf.st_mode&07777); |
|
|
} |
|
322 |
|
|
323 |
if(s->uid) { |
if(check_uid(s, stat_buf.st_uid)) |
324 |
if( (int)stat_buf.st_uid != s->uid->uid ) { |
return FALSE; |
|
Event_post(s, EVENT_UID, |
|
|
"Event: '%s' uid test failed -- " |
|
|
"current uid: %d\n", |
|
|
s->name, (int)stat_buf.st_uid); |
|
|
return FALSE; |
|
|
} |
|
|
DEBUG("'%s' directory uid check passed [current uid=%d]\n", |
|
|
s->name, (int)stat_buf.st_uid); |
|
|
} |
|
325 |
|
|
326 |
if(s->gid) { |
if(check_gid(s, stat_buf.st_gid)) |
327 |
if( (int)stat_buf.st_gid != s->gid->gid ) { |
return FALSE; |
|
Event_post(s, EVENT_GID, |
|
|
"Event: '%s' gid test failed -- " |
|
|
"current gid: %d\n", |
|
|
s->name, (int)stat_buf.st_gid); |
|
|
return FALSE; |
|
|
} |
|
|
DEBUG("'%s' directory gid check passed [current gid=%d]\n", |
|
|
s->name, (int)stat_buf.st_gid); |
|
|
} |
|
328 |
|
|
329 |
return TRUE; |
return TRUE; |
330 |
|
|
354 |
if(check_checksum(s)) |
if(check_checksum(s)) |
355 |
return FALSE; |
return FALSE; |
356 |
|
|
357 |
if(s->perm) { |
if(check_perm(s, stat_buf.st_mode)) |
358 |
if( (stat_buf.st_mode & 07777) != s->perm->perm ) { |
return FALSE; |
|
Event_post(s, EVENT_PERMISSION, |
|
|
"Event: '%s' permission test failed -- " |
|
|
"current permission: %o\n", |
|
|
s->name, stat_buf.st_mode&07777); |
|
|
return FALSE; |
|
|
} |
|
|
DEBUG("'%s' file permission check passed [current permission=%o]\n", |
|
|
s->name, stat_buf.st_mode&07777); |
|
|
} |
|
359 |
|
|
360 |
if(s->uid) { |
if(check_uid(s, stat_buf.st_uid)) |
361 |
if( (int)stat_buf.st_uid != s->uid->uid ) { |
return FALSE; |
|
Event_post(s, EVENT_UID, |
|
|
"Event: '%s' uid test failed -- " |
|
|
"current uid: %d\n", |
|
|
s->name, (int)stat_buf.st_uid); |
|
|
return FALSE; |
|
|
} |
|
|
DEBUG("'%s' file uid check passed [current uid=%d]\n", |
|
|
s->name, (int)stat_buf.st_uid); |
|
|
} |
|
362 |
|
|
363 |
if(s->gid) { |
if(check_gid(s, stat_buf.st_gid)) |
364 |
if( (int)stat_buf.st_gid != s->gid->gid ) { |
return FALSE; |
|
Event_post(s, EVENT_GID, |
|
|
"Event: '%s' gid test failed -- " |
|
|
"current gid: %d\n", |
|
|
s->name, (int)stat_buf.st_gid); |
|
|
return FALSE; |
|
|
} |
|
|
DEBUG("'%s' file gid check passed [current gid=%d]\n", |
|
|
s->name, (int)stat_buf.st_gid); |
|
|
} |
|
365 |
|
|
366 |
for(sl= s->sizelist; sl; sl= sl->next) { |
for(sl= s->sizelist; sl; sl= sl->next) { |
367 |
if(!check_size_item(s, sl, (unsigned long)stat_buf.st_size, report)) { |
if(!check_size_item(s, sl, (unsigned long)stat_buf.st_size, report)) { |
394 |
return FALSE; |
return FALSE; |
395 |
} |
} |
396 |
|
|
397 |
if(s->perm) { |
if(check_perm(s, stat_buf.st_mode)) |
398 |
if( (stat_buf.st_mode & 07777) != s->perm->perm ) { |
return FALSE; |
|
Event_post(s, EVENT_PERMISSION, |
|
|
"Event: '%s' permission test failed -- " |
|
|
"current permission: %o\n", |
|
|
s->name, stat_buf.st_mode&07777); |
|
|
return FALSE; |
|
|
} |
|
|
DEBUG("'%s' device permission check passed [current permission=%o]\n", |
|
|
s->name, stat_buf.st_mode&07777); |
|
|
} |
|
399 |
|
|
400 |
if(s->uid) { |
if(check_uid(s, stat_buf.st_uid)) |
401 |
if( (int)stat_buf.st_uid != s->uid->uid ) { |
return FALSE; |
|
Event_post(s, EVENT_UID, |
|
|
"Event: '%s' uid test failed -- " |
|
|
"current uid: %d\n", |
|
|
s->name, (int)stat_buf.st_uid); |
|
|
return FALSE; |
|
|
} |
|
|
DEBUG("'%s' device uid check passed [current uid=%d]\n", |
|
|
s->name, (int)stat_buf.st_uid); |
|
|
} |
|
402 |
|
|
403 |
if(s->gid) { |
if(check_gid(s, stat_buf.st_gid)) |
404 |
if( (int)stat_buf.st_gid != s->gid->gid ) { |
return FALSE; |
|
Event_post(s, EVENT_GID, |
|
|
"Event: '%s' gid test failed -- " |
|
|
"current gid: %d\n", |
|
|
s->name, (int)stat_buf.st_gid); |
|
|
return FALSE; |
|
|
} |
|
|
DEBUG("'%s' device gid check passed [current gid=%d]\n", |
|
|
s->name, (int)stat_buf.st_gid); |
|
|
} |
|
405 |
|
|
406 |
/* Test devices */ |
/* Test devices */ |
407 |
if(s->devicelist) { |
if(s->devicelist) { |
809 |
|
|
810 |
ASSERT(s); |
ASSERT(s); |
811 |
|
|
812 |
if(!s->checksum) { |
if(!s->checksum) |
813 |
return FALSE; |
return FALSE; |
|
} |
|
814 |
|
|
815 |
if( !check_md5(s->path, s->checksum->md5) ) { |
if( !check_md5(s->path, s->checksum->md5) ) { |
816 |
Event_post(s, EVENT_CHECKSUM, "'%s' CHECKSUM ERROR for %s\n", |
Event_post(s, EVENT_CHECKSUM, "'%s' CHECKSUM ERROR for %s\n", |
823 |
return FALSE; |
return FALSE; |
824 |
|
|
825 |
} |
} |
826 |
|
|
827 |
|
|
828 |
|
/** |
829 |
|
* Returns TRUE if the permission was changed for associated |
830 |
|
* path and send an alert warning. |
831 |
|
* Returns FALSE if the permission is the same or not defined |
832 |
|
* for this service. |
833 |
|
*/ |
834 |
|
static int check_perm(Service_T s, mode_t mode) { |
835 |
|
|
836 |
|
ASSERT(s); |
837 |
|
|
838 |
|
if(!s->perm) |
839 |
|
return FALSE; |
840 |
|
|
841 |
|
if( (mode & 07777) != s->perm->perm ) { |
842 |
|
Event_post(s, EVENT_PERMISSION, |
843 |
|
"Event: '%s' permission test failed -- " |
844 |
|
"current permission: %o\n", |
845 |
|
s->name, mode&07777); |
846 |
|
return TRUE; |
847 |
|
} |
848 |
|
|
849 |
|
DEBUG("'%s' file permission check passed [current permission=%o]\n", |
850 |
|
s->name, mode&07777); |
851 |
|
|
852 |
|
return FALSE; |
853 |
|
|
854 |
|
} |
855 |
|
|
856 |
|
|
857 |
|
/** |
858 |
|
* Returns TRUE if the uid was changed for associated |
859 |
|
* path and send an alert warning. |
860 |
|
* Returns FALSE if the uid is the same or not defined |
861 |
|
* for this service. |
862 |
|
*/ |
863 |
|
static int check_uid(Service_T s, uid_t uid) { |
864 |
|
|
865 |
|
ASSERT(s); |
866 |
|
|
867 |
|
if(!s->uid) |
868 |
|
return FALSE; |
869 |
|
|
870 |
|
if( uid != s->uid->uid ) { |
871 |
|
Event_post(s, EVENT_UID, |
872 |
|
"Event: '%s' uid test failed -- " |
873 |
|
"current uid: %d\n", |
874 |
|
s->name, (int)uid); |
875 |
|
return TRUE; |
876 |
|
} |
877 |
|
|
878 |
|
DEBUG("'%s' device uid check passed [current uid=%d]\n", |
879 |
|
s->name, (int)uid); |
880 |
|
|
881 |
|
return FALSE; |
882 |
|
|
883 |
|
} |
884 |
|
|
885 |
|
|
886 |
|
/** |
887 |
|
* Returns TRUE if the gid was changed for associated |
888 |
|
* path and send an alert warning. |
889 |
|
* Returns FALSE if the gid is the same or not defined |
890 |
|
* for this service. |
891 |
|
*/ |
892 |
|
static int check_gid(Service_T s, gid_t gid) { |
893 |
|
|
894 |
|
ASSERT(s); |
895 |
|
|
896 |
|
if(!s->gid) |
897 |
|
return FALSE; |
898 |
|
|
899 |
|
if( gid != s->gid->gid ) { |
900 |
|
Event_post(s, EVENT_GID, |
901 |
|
"Event: '%s' gid test failed -- " |
902 |
|
"current gid: %d\n", |
903 |
|
s->name, (int)gid); |
904 |
|
return TRUE; |
905 |
|
} |
906 |
|
|
907 |
|
DEBUG("'%s' device gid check passed [current gid=%d]\n", |
908 |
|
s->name, (int)gid); |
909 |
|
|
910 |
|
return FALSE; |
911 |
|
|
912 |
|
} |
913 |
|
|
914 |
|
|
915 |
/** |
/** |